> ## 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.

# テストとリファクタリング

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>;
};

<div id="overview">
  ## 概要
</div>

Devin は既存のコードベースを分析し、改善が必要な箇所を特定したり、共有されたリファクタリング要件に沿って、機能を損なうことなく実行できます。

<div id="common-use-cases">
  ## よくあるユースケース
</div>

1. テストカバレッジの作成および拡充
2. コードのリファクタリングおよび最適化
3. API エンドポイントの開発および変更
4. パフォーマンスの改善
5. コードレビューおよび品質保証
6. [API リファレンス](/ja/api-reference/overview) を使用した自動テストワークフロー

<div id="example-prompts">
  ## プロンプト例
</div>

<AccordionGroup>
  <Accordion title="単体テストの作成" icon="magnifying-glass">
    <PromptBlock>
      ```txt 単体テストの作成 theme={null}
      https://github.com/markedjs/marked をセットアップし、コマンドラインツールを --output/-o フラグ付きで実行したうえで、--output フラグをテストする単体テストを追加してもらえますか？
      すでに bin.test.js に、参考にできる類似のテストがあるはずです。
      ```
    </PromptBlock>
  </Accordion>

  <Accordion title="エンドポイントのリファクタリング" icon="gear-code">
    <PromptBlock>
      ```txt エンドポイントのリファクタリング theme={null}
      現在、ユーザーが <endpoint> に POST を送信すると、<describe endpoint behavior> を行っています。<explain reasoning> ため、このエンドポイントを 2 つの別々のエンドポイントに分割したほうがよいです。
      <Describe what the first endpoint should do>。
      <Describe what the second endpoint should do>。
      テストは、<explain how Devin can test each endpoint to verify it's on the right track> ことで行ってください。
      ```
    </PromptBlock>
  </Accordion>

  <Accordion title="一般的なリファクタリング" icon="code">
    <PromptBlock>
      ```txt 一般的なリファクタリング theme={null}
      Slack サーバー内で、AppRegistry を別ファイルに切り出してリファクタリングしてください。
      ```
    </PromptBlock>
  </Accordion>
</AccordionGroup>

<div id="example-sessions">
  ## セッションの例
</div>

<div id="code-coverage-tutorial">
  ### コードカバレッジチュートリアル
</div>

詳細なチュートリアルを通じて、テストカバレッジを体系的に向上させる方法を学びます。

* 包括的なユニットテストの作成
* カバレッジギャップの特定
* 不足しているテストケースの実装

[コードカバレッジチュートリアルを表示](/ja/use-cases/tutorials/code-coverage)

<div id="connect4-code-refactor">
  ### Connect4 コードリファクタリング
</div>

次を示す完全なリファクタリングセッションです:

* コード構造の改善
* コンポーネントの分離
* パフォーマンスの最適化
* テストカバレッジの強化

**セッションを表示:**
[https://app.devin.ai/sessions/8965de5e3ae0436985bf3dd2e1a5b4af](https://app.devin.ai/sessions/8965de5e3ae0436985bf3dd2e1a5b4af)
