JUnit 5控制台找不到测试

时间:2018-02-16 09:23:37

标签: unit-testing ant junit5

我在Ant构建脚本中使用JUnit5控制台。但是我的项目中没有找到任何测试。

我在终端中使用了以下命令:

-jar lib\junit-platform-console-standalone-1.1.0-RC1.jar --class-path bin --scan-class-path

返回:

[36m.[0m
[36m+--[0m [36mJUnit Jupiter[0m [32m[OK][0m
[36m'--[0m [36mJUnit Vintage[0m [32m[OK][0m

Test run finished after 27 ms
[         2 containers found      ]
[         0 containers skipped    ]
[         2 containers started    ]
[         0 containers aborted    ]
[         2 containers successful ]
[         0 containers failed     ]
[         0 tests found           ]
[         0 tests skipped         ]
[         0 tests started         ]
[         0 tests aborted         ]
[         0 tests successful      ]
[         0 tests failed          ]

我获得了Ant脚本的相同输出:

<target name="test" depends="compile" description="Runs JUnit Tests">
    <java jar="lib\junit-platform-console-standalone-1.1.0-RC1.jar" fork="true">
        <arg value="d ."/>
        <arg value="-details verbose"/>
    </java>
</target>

2 个答案:

答案 0 :(得分:1)

我修复了它:参数必须是行:

<target name="test" depends="test-javac" description="Runs JUnit Tests">
    <java jar="${junit.jar}" fork="true">

        <arg line="--class-path bin"/>
        <arg line="--scan-class-path"/>
        <arg line="--reports-dir reports"/>

        <!-- Available options: [ascii,unicode]-->
        <arg line="details-theme unicode"/>

        <!-- Available options: [none,flat,tree,verbose]-->
        <arg line="--details tree"/>
    </java>
</target>

答案 1 :(得分:0)

您需要指定启动程序可以找到已编译测试类的位置。有关详细信息,请参阅https://junit.org/junit5/docs/current/user-guide/#running-tests-console-launcher

您的测试类如何命名?它们是由“javac”直接存储在“bin /”下吗?

也许这里发布的答案和评论Unable to run tests with JUnit5 Console Launcher很有帮助。