comscom@Wiki
test(テストを実行する)
最終更新:
dotcom
-
view
compile(コンパイル)の続きです。
ありました。
Z:\maventest\src\test\java\jp\co\dotcom\AppTest.java
createした時にサンプルで作ってくれてたやつです。
じゃあやってみましょうテスト。
Junitをうごかしてもらうコマンド
叩くコマンドは以下の通り。
mvn test
短くて簡単で覚えやすい。。
実行してみる。
こんな感じ。
Z:\maventest>mvn test [INFO] Scanning for projects... [INFO] ---------------------------------------------------------------------------- [INFO] Building maventest [INFO] task-segment: [test] [INFO] ---------------------------------------------------------------------------- [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] [INFO] Nothing to compile - all classes are up to date [INFO] [resources:testResources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:testCompile] [INFO] Compiling 1 source file to Z:\maventest\target\test-classes [INFO] [surefire:test] [INFO] Surefire report directory: Z:\maventest\target\surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running jp.co.dotcom.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.063 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3 seconds [INFO] Finished at: Fri May 16 16:15:59 JST 2008 [INFO] Final Memory: 4M/11M [INFO] ------------------------------------------------------------------------ Z:\maventest>
※対象のpom.xmlがあるディレクトリに移動してコマンドを叩くのを忘れずに!
BUILD SUCCESSFULってでてますよ。成功?
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
で、テストが1つでフェイルもエラーもすっとばしもないよ、ってことが分かるです。
mvn testが成功しなかったときの例
ちなみにテストが落ちるとこういう感じ。
Z:\maventest>mvn test [INFO] Scanning for projects... [INFO] ---------------------------------------------------------------------------- [INFO] Building maventest [INFO] task-segment: [test] [INFO] ---------------------------------------------------------------------------- [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] [INFO] Nothing to compile - all classes are up to date [INFO] [resources:testResources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:testCompile] [INFO] Compiling 1 source file to Z:\maventest\target\test-classes [INFO] [surefire:test] [INFO] Surefire report directory: Z:\maventest\target\surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running jp.co.dotcom.AppTest Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.079 sec <<< FAILURE! Results : Failed tests: testApp(jp.co.dotcom.AppTest) Tests run: 1, Failures: 1, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] There are test failures. Please refer to Z:\maventest\target\surefire-reports for the individual test results. [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven w