简体   繁体   English

使用 JUnit 进行单元测试

[英]unit test using JUnit

I'm using NetBeans 7.4, and this is my first example with JUnit so i have this WARNING in the output console:我正在使用 NetBeans 7.4,这是我使用 JUnit 的第一个示例,因此我在输出控制台中有此警告:

WARNING: multiple versions of ant detected in path for junit 
         jar:file:/C:/Program%20Files%20(x86)/NetBeans%207.4/extide/ant/lib/ant.jar!/org/apache/tools/ant/Project.class
     and jar:file:/C:/Program%20Files%20(x86)/glassfish-4.0/glassfish/modules/ant.jar!/org/apache/tools/ant/Project.class
Testsuite: utilitaire.TraitementFichierTest
copyFile
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0,069 sec

------------- Standard Output ---------------
copyFile
------------- ---------------- ---------------
Testcase: testCopyFile(utilitaire.TraitementFichierTest):   FAILED
expected:<false> but was:<true>
junit.framework.AssertionFailedError: expected:<false> but was:<true>
    at utilitaire.TraitementFichierTest.testCopyFile(TraitementFichierTest.java:52)


Test utilitaire.TraitementFichierTest FAILED

What you have is a test failure, multiple junit versions(from Netbeans bundled & galssfish) is just a warning, doesn't cause a failure您所拥有的是测试失败,多个 junit 版本(来自 Netbeans bundled 和 galssfish)只是一个警告,不会导致失败

    testCopyFile(utilitaire.TraitementFichierTest):   FAILED
expected:<false> but was:<true>
junit.framework.AssertionFailedError: expected:<false> but was:<true>
    at utilitaire.TraitementFichierTest.testCopyFile(TraitementFichierTest.java:52)

Check TraitementFichierTest.java line 52, you assert for a false, but gets a true, that is the cause for failure.检查 TraitementFichierTest.java 第 52 行,您断言为 false,但得到了 true,这就是失败的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM