> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 一晩で未テストのモジュール8個をテストする

export const UseCaseHero = ({title, description, prompt, category, features, devinUrl, agent, intent, playbookId, type}) => {
  const encodedPrompt = encodeURIComponent(prompt || '');
  const tag = 'docs-use-case-gallery';
  const utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=hero-cta';
  const agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  const devinHref = type === 'schedule' ? 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + (prompt ? '&prompt=' + encodedPrompt : '') : type === 'review' ? 'https://app.devin.ai/review?' + utm : agent === 'ada' ? 'https://app.devin.ai/search?' + utm + '&noSubmit=true' + (prompt ? '&prompt=' + encodedPrompt : '') : devinUrl ? devinUrl.includes('?') ? devinUrl + '&' + utm + agentParams : devinUrl + '?' + utm + agentParams : prompt ? 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encodedPrompt : 'https://app.devin.ai/?' + utm + agentParams;
  const buttonLabel = type === 'schedule' ? 'Schedule in Devin ↗' : type === 'review' ? 'Set Up Devin Review ↗' : agent === 'advanced' ? 'Try in Devin ↗' : agent === 'dana' ? 'Try in Dana ↗' : agent === 'ada' ? 'Try in Ask Devin ↗' : 'Try in Devin ↗';
  const featureList = features ? features.split(',').map(f => f.trim()) : [];
  return <div className="uc-hero">
      <div className="uc-hero-inner">
        <div className="uc-hero-left">
          <h1 className="uc-hero-title">{title}</h1>
          <p className="uc-hero-desc">{description}</p>
          <div>
            <a href={devinHref} target="_blank" rel="noopener noreferrer" className="try-in-devin-btn">
              {buttonLabel}
            </a>
          </div>
        </div>
        <div className="uc-hero-meta">
          <div className="uc-meta-item">
            <span className="uc-meta-label">Author</span>
            <span className="uc-meta-value">Cognition</span>
          </div>
          <div className="uc-meta-item">
            <span className="uc-meta-label">Category</span>
            <span className="uc-meta-value">{category}</span>
          </div>
          {featureList.length > 0 && <div className="uc-meta-item">
              <span className="uc-meta-label">Features</span>
              <span className="uc-meta-value">{featureList.join(', ')}</span>
            </div>}
        </div>
      </div>
    </div>;
};

export const PromptBlock = ({children, type, agent, intent, playbookId}) => {
  var utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=prompt-block';
  var tag = 'docs-use-case-gallery';
  var agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  var label = type === 'schedule' ? 'Schedule in Devin' : type === 'playbook' ? 'Create Playbook' : type === 'knowledge' ? 'Add to Knowledge' : agent === 'advanced' ? 'Try in Devin' : agent === 'dana' ? 'Try in Dana' : agent === 'ada' ? 'Try in Ask Devin' : 'Try in Devin';
  var buildUrl = function (text) {
    var encoded = encodeURIComponent(text);
    if (type === 'schedule') return 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + '&prompt=' + encoded;
    if (type === 'playbook') return 'https://app.devin.ai/settings/playbooks/create?' + utm + '&body=' + encoded;
    if (type === 'knowledge') return 'https://app.devin.ai/knowledge?' + utm + '&body=' + encoded;
    if (agent === 'ada') return 'https://app.devin.ai/search?' + utm + '&noSubmit=true&prompt=' + encoded;
    return 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encoded;
  };
  const ref = React.useRef(null);
  const [href, setHref] = React.useState('#');
  React.useEffect(() => {
    if (!ref.current) return;
    var codeEl = ref.current.querySelector('pre code');
    if (codeEl) {
      var text = codeEl.textContent.trim();
      if (text) setHref(buildUrl(text));
    }
    var header = ref.current.querySelector('[data-component-part="code-block-header"]');
    if (header && !header.querySelector('.prompt-block-devin-link')) {
      var link = document.createElement('a');
      link.href = href;
      link.target = '_blank';
      link.rel = 'noopener noreferrer';
      link.className = 'prompt-block-devin-link';
      link.style.cssText = 'display:inline-flex;align-items:center;gap:6px;text-decoration:none;color:#fff;font-size:11px;font-weight:500;padding:4px 10px;border-radius:6px;white-space:nowrap;background:#317CFF;transition:background 0.2s;margin-left:8px;';
      link.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg> ' + label;
      link.onmouseenter = function () {
        link.style.background = '#2968D9';
      };
      link.onmouseleave = function () {
        link.style.background = '#317CFF';
      };
      header.appendChild(link);
    }
    var existingLink = ref.current.querySelector('.prompt-block-devin-link');
    if (existingLink && href !== '#') existingLink.href = href;
  });
  return <div className="prompt-block" ref={ref}>{children}</div>;
};

<UseCaseHero title="一晩で未テストの8モジュールをテスト" description="夜の間に8つのDevinセッションを並列起動し、それぞれがカバレッジの低い別々のモジュール向けに単体テストを書き、朝までにPR（プルリクエスト）をオープンします。" prompt="テストカバレッジレポートを実行し、行カバレッジが50%未満のモジュールを8つ特定してください。そのうえで、モジュールごとに1つずつDevinセッションを並列で一括起動し、各セッションでテスト作成用プレイブックを使ってカバレッジを80%以上に引き上げてください。各モジュールごとに個別のPRを作成してオープンしてください。" category="Devinの最適化" features="高度, プレイブック" agent="advanced" intent="batch" />

<div className="uc-detail-wrapper">
  <Tip>手動でのセットアップが面倒ですか？このページのリンクを Devin のセッションに貼り付けて、すべてのセットアップを依頼してください。</Tip>

  <Steps>
    <Step title="テスト作成のためのプレイブックを作成する">
      あなたの e コマースのモノレポには 30 以上のモジュールがありますが、十分なテストカバレッジがあるのは一部だけです。全体のカバレッジを 44% から 80% に引き上げたいと考えており、その出発点としてカバレッジが最も低い 8 つのモジュールから始めます。並列セッションを開始する前に、8 つすべてのセッションが一貫した方法でテストを書けるようにするための [プレイブック](/ja/product-guides/creating-playbooks) が必要です。

      Devin にプレイブックの作成を依頼してください。任意のセッションでテスト方針を説明するだけです:

      <PromptBlock agent="advanced" intent="create">
        ```txt Create a test-writing playbook theme={null}
        Create a playbook for writing unit tests in our monorepo. It should enforce:
        1. Use Vitest with TypeScript. Import from `vitest`.
        2. Follow the AAA pattern (Arrange, Act, Assert).
        3. Mock external dependencies — never call real APIs, databases, or third-party services.
        4. Use test helpers from `src/test/helpers.ts` (e.g., `createMockUser()`, `setupTestDB()`).
        5. Place test files at `{module}/__tests__/{filename}.test.ts`.
        6. Cover success paths, error paths, and edge cases for every exported function.
        7. Run `npm test -- --coverage --reporter=json` and verify the module exceeds 80% line coverage.
        8. Open a PR with the new tests. Include the before/after coverage numbers in the PR description.
        ```
      </PromptBlock>

      このプレイブックは、すべての並列セッションで共有される共通の指示セットになります。さらに、テストユーティリティやモックのパターン、プロジェクト固有の注意点 (例: "always call `resetMocks()` in `afterEach`") について [Knowledge](/ja/product-guides/knowledge) にエントリを追加することもできます。
    </Step>

    <Step title="午後6時に並列セッションを8つ起動します">
      勤務日の終わりに、[Devin のホームページ](https://app.devin.ai/?utm_source=docs\&utm_medium=use-case-gallery) から新しい Devin セッションを開き、バッチタスクの内容を記述します。

      1. ドロップダウンメニューからテスト作成用のプレイブックを選択します
      2. プロンプトでタスク内容を記述します:

      <PromptBlock agent="advanced" intent="batch">
        ```txt Overnight test coverage batch — 8 modules theme={null}
        Run `npm run test:coverage` against our repo. Identify the 8 modules
        with the lowest line coverage (skip anything under src/generated/).

        For each module, start a parallel Devin session using the selected playbook.
        Each session should:
        - Read the module's source code and any existing tests
        - Write new unit tests to bring line coverage above 80%
        - Run the full test suite to confirm nothing breaks
        - Open a PR with the new test files and a before/after coverage summary
        ```
      </PromptBlock>

      3. 提案されたセッションを確認します。Devin は各モジュールの現在のカバレッジを一覧表示し、作成するセッションを確認します:

      ```
      提案されたセッション（8モジュール、すべてカバレッジ50%未満）:
        1. src/services/PaymentService — 31% coverage
        2. src/services/UserService — 38% coverage
        3. src/api/routes/billing — 42% coverage
        4. src/middleware/auth — 44% coverage
        5. src/services/NotificationSvc — 47% coverage
        6. src/components/Checkout — 49% coverage
        7. src/utils/validation — 51% coverage
        8. src/services/SearchService — 53% coverage

      8つの並列セッションを開始しますか？ (y/n)
      ```

      4. バッチを承認したら、あとはノートパソコンを閉じるだけです。8つのセッションが、それぞれ別々のDevinマシン上で同時に起動し、各セッションがあなたのプレイブックに従って独立して実行されます。
    </Step>

    <Step title="朝起きたら8件のPRが届いている">
      朝までに各セッションが完了し、それぞれ自分用のPRを作成します。リポジトリには8件のPRが作成されており、それぞれに新しいテストファイルとカバレッジサマリーが含まれています。

      ```
      Module                       | Before | After  | PR     | Status
      -----------------------------|--------|--------|--------|--------
      src/services/PaymentService  |  31%   |  87%   | #412   | Ready
      src/services/UserService     |  38%   |  84%   | #413   | Ready
      src/api/routes/billing       |  42%   |  91%   | #414   | Ready
      src/middleware/auth           |  44%   |  82%   | #415   | Ready
      src/services/NotificationSvc |  47%   |  85%   | #416   | Ready
      src/components/Checkout      |  49%   |  83%   | #417   | Ready
      src/utils/validation         |  51%   |  93%   | #418   | Ready
      src/services/SearchService   |  53%   |  86%   | #419   | Ready

      Overall coverage: 44% -> 68% (+24 pts across targeted modules)
      ```

      PR はどの順番でマージしても問題ありません。各セッションは自分のモジュールに対して新しいテストファイルを追加するだけなので、コンフリクトはまれです。2 つのセッションが共有のテストヘルパーに変更を加えた場合は、手動でコンフリクトを解消するか、Devin に修正を依頼してください。
    </Step>

    <Step title="次のティア向けに2回目のバッチを実行する">
      1回の夜間バッチ実行だけでは、コードベース全体で80%の目標には届きません。次の夜には、次にカバレッジが低いモジュール群に対してフォローアップを実行します:

      <PromptBlock agent="advanced" intent="batch">
        ```txt 2回目の夜間カバレッジパス theme={null}
        現在の全体カバレッジは68%で、80%が必要です。もう一度カバレッジレポートを実行し、
        カバレッジが低いモジュールを新たに6つ特定してください（すでに80%以上のものはskip）。
        同じテスト作成手順書を使って、新しいバッチを開始してください。
        ```
      </PromptBlock>

      また、重要なユーザーフローについては、ユニットテストからインテグレーションテストに切り替えることもできます:

      <PromptBlock agent="advanced" intent="batch">
        ```txt 重要フロー向けのバッチインテグレーションテスト theme={null}
        最も重要なユーザーフローを5つ特定してください（サインアップ、ログイン、チェックアウト、
        パスワードリセット、アカウント削除）。それぞれに対して並列セッションを開始し、
        Playwright を使ってエンドツーエンドのインテグレーションテストを書いてください。
        各セッションでは、ハッピーパスに加えて2〜3個のエラーシナリオをテストしてください。
        ```
      </PromptBlock>

      2晩の並列セッションで、コードベースのカバレッジを50%未満から80%以上まで引き上げることができます。これは、エンジニアが数週間専任で取り組んでようやく達成できる作業量に相当します。
    </Step>
  </Steps>
</div>
