下面請(qǐng)把 com/company/HelloWorld.java文件中的return "Hello World!";改成return "Hello world!!",并在../JunitTest/builde目錄運(yùn)行下運(yùn)行ant runtests。
我們會(huì)看到如下情形:
……………………………………
……………………………………
runtests:
[junit] .F
[junit] Time: 0.01
[junit] There was 1 failure:
[junit] 1) testSayHello(test.com.company.HelloWorldTest)junit.framework.Comp
arisonFailure: expected:<...World...> but was:<...world!...>
[junit] at test.com.company.HelloWorldTest.testSayHello(Unknown Source)
[junit] at sun.reflect.NativeMethodAclearcase/" target="_blank" >ccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
[junit] FAILURES!!!
[junit] Tests run: 1, Failures: 1, Errors: 0
BUILD FAILED
我們可以看到,這是JUNIT測試用例未正常運(yùn)行通過的錯(cuò)誤信息。