2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【TDD日記】テスト駆動開発の輪読会をするので、Go,Python,TypeScriptの xUnit環境をClaudeで1分で作った日

Posted at

はじめに

問題

  • xUnitを手元で動かす環境がない

解決策

  • Claudeに以下のプロンプトを渡して、1分で環境構築をしてもらった

新しいフォルダを作って、 golang, python, TypeScriptでTestDrivenDevelopmentの練習ができる環境を作ってください。

結果

  • TDDの肝である、最小ステップ(Redのテストを書く)を3言語分を間近でみれた

    1. Red: テストが失敗することを確認(現在の状態)
    2. Green: calculator.* ファイルの TODO を実装してテストを通す
    3. Refactor: コードを改善
      Screenshot 2025-11-28 at 15.11.03.png
  • 具体的には、1分で以下のような環境を構築してくれました

TDD練習環境が完成しました。

  作成したフォルダ構造

  tdd-practice/
  ├── golang/
  │   ├── go.mod
  │   ├── calculator.go        # 実装ファイル(TODO)
  │   └── calculator_test.go   # テストファイル
  ├── python/
  │   ├── requirements.txt     # pytest依存関係
  │   ├── pytest.ini           # pytest設定
  │   ├── calculator.py        # 実装ファイル(TODO)
  │   └── test_calculator.py   # テストファイル
  └── typescript/
      ├── package.json
      ├── tsconfig.json
      ├── jest.config.js
      └── src/
          ├── calculator.ts       # 実装ファイル(TODO)
          └── calculator.test.ts  # テストファイル

  使い方

  Go

  cd tdd-practice/golang
  go test -v              # テスト実行

  Python

  cd tdd-practice/python
  pip install -r requirements.txt  # 初回のみ
  pytest -v               # テスト実行

  TypeScript

  cd tdd-practice/typescript
  npm test               # テスト実行
  npm run test:watch     # ウォッチモード

  TDDの流れ

  1. Red: テストが失敗することを確認(現在の状態)
  2. Green: calculator.* ファイルの TODO を実装してテストを通す
  3. Refactor: コードを改善

  各言語の calculator.*
  ファイルには未実装の関数があり、対応するテストはすでに書かれています。
  関数を実装してテストを通してください。
  

おわりに

  • 早速初回の xUnit Testを Redのテストを3言語分走らせました
  • これから、テスト駆動開発を学んで、僕たちのプロダクトでも、以下を実現していきます
    • 動作する綺麗なコードを書く
    • 不安をなくし、本当に難しい問題に思考リソースを割く(コトに向かう)
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?