1
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?

More than 3 years have passed since last update.

単体テストのケース出しとテストクラスコメントの書き方とその他学んだこと

Posted at

この記事は

新人エンジニアが単体テストを作る上で教わったことや自分で学んだことをまとめたものです。
順次更新予定。

テストケースの出し方のポイント

  • テスト対象のクラスから条件文(if文、for文、try-catchブロック)を探し、それぞれの分岐を書き出す
    • for文は「処理に入らなかった場合」「1回だけループした場合」「3回ループした場合」の3分岐を書き出す
  • ありうるパターンを出せるだけ出して、後から無意味なものを削る
    • 漏れを防ぐため
  • パターン出しはエクセル等を使って表にする
  • 自分の作っているシステム外が要因となって起きるケースは想定しなくてよい

テストクラスのコメント

  • そのテストを実行するにあたって必要な手順があれば、ケースの前に書く
1
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
1
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?