Upgrade to Pro — share decks privately, control downloads, hide ads and more …

生成AIではじめるテスト駆動開発

Avatar for puku0x puku0x
November 13, 2025

 生成AIではじめるテスト駆動開発

Avatar for puku0x

puku0x

November 13, 2025
Tweet

More Decks by puku0x

Other Decks in Technology

Transcript

  1. 6

  2. 11 テスト駆動開発 • 期待される動作をリストアップする • Red-Green-Refactorを繰り返す ◦ Red: テストを⼀つ書いて失敗させる ◦

    Green: コードを変更して成功させる ◦ Refactor: コードを整理する https://shop.ohmsha.co.jp/shopdetail/000000004967/
  3. 13

  4. 19 使いやすく⼯夫 • 元のプロンプトはC#⽤なので利⽤⾔語に合わせて差し替え • スラッシュコマンドからの起動にも対応 --- description: 'TDD Red

    Phase - Write Failing Tests First' mode: 'tdd-red' tools: ['edit', 'search', 'runCommands', 'github/*', 'problems', 'changes', 'testFailure'] --- # TDD Red Phase - Write Failing Tests First Write front end tests using Jest and React Testing Library that describe the desired behavior from GitHub issue requirements before any implementation exists. When finished, prompt the user to enter `/tdd-green` to proceed to the next phase.
  5. 21 元のコード(Viteのテンプレから抜粋) export function App() { const [count, setCount] =

    useState(0); return ( <> <button type="button" onClick={() => setCount((count) => count + 1)}>increment</button> <p>count is {count}</p> </> ); }
  6. 22 元のテスト(任意) describe('App', () => { it('should increment when increment

    button is clicked', async () => { const { user } = setup({}); expect(screen.getByText('count is 0')).toBeInTheDocument(); await user.click(screen.getByRole('button', { name: 'increment' })); expect(screen.getByText('count is 1')).toBeInTheDocument(); }); });
  7. 30 OpenAI DevDay 2025 https://www.youtube.com/watch?v=Gr41tYOzE20 • 約7時間のコード⽣成 ◦ ⼈間の指⽰は最⼩限 •

    考え⽅はTDDと同じ ◦ 計画を作成 ◦ テストを書く ◦ 実装&テストを通す ◦ 計画を更新