2
5

More than 1 year has passed since last update.

もう怖くないSpring × Junit5 ~前編~

Last updated at Posted at 2021-12-15

はじめに

テスト?なにそれ、美味しいの?
テスト?俺の実装完璧だし。テストなんていらん。
テスト?Junit?なんかコワイ。。。((((;゚Д゚))))ガクガクブルブル

っていう人もそうでない人もJunitと触れ合いましょう。

テストクラスの作り方

eclipseの例

1.作りたいテストを選ぶ

20190725もう怖くないspring×Junit5.png

2.テスト作るウィザード立ち上げる

もう怖くないspring×Junit5.png

3.テストフォルダを選択する

もう怖くないspring×Junit5.png

4.できた!

もう怖くないspring×Junit5.png

単純なテスト

1.普通のテストを作る

もう怖くないspring×Junit5.png

2.わざとエラーになるように作る

もう怖くないspring×Junit5.png

3.実行!の前にいくつかポイント

もう怖くないspring×Junit5.png
hamcrest Matcherについてはこちらご参照ください。

4.実行!

5もう怖くないspring×Junit5.png

5.結果(エラー)

もう怖くないspring×Junit5.png

6.通るように直す

もう怖くないspring×Junit5.png

7.実行結果(成功)

もう怖くないspring×Junit5.png

最後に

もう怖くないSpring × Junit5 ~中編~につづく

2
5
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
5