【发布时间】:2018-07-28 16:11:30
【问题描述】:
我正在尝试从命令行(Windows 10 中的 PowerShell)运行测试。 在问这个问题之前,我查看了几个来源并阅读了很多主题,例如
- How to run JUnit test cases from the command line
- https://github.com/junit-team/junit4/wiki/Getting-started
但是当我尝试像在 JUnit wiki 中那样从 PowerShell 运行测试时
cd E:\Dev\AutoTest\Example
java -cp .;/libs/junit-4.12.jar;/libs/hamcrest-core-1.3.jar org.junit.runner.JUnitCore tests.Booking.BookingTests
我得到了输出
CommandNotFoundException
如果我运行相同,但通过旧命令行 (cmd.exe):
cd E:\Dev\AutoTest\Example
java -cp .;E:\Dev\AutoTest\Example\libs\junit-4.12.jar;E:\Dev\AutoTest\Example\libs\hamcrest-core-1.3.jar org.junit.runner.JUnitCore tests.Booking.BookingTests
我得到了输出
java.lang.IllegalArgumentException:找不到类 [tests.Booking.BookingTests] 引起:java.lang.ClassNotFoundException:tests.Booking.BookingTests在 IDEA 中,项目结构如下所示:
在硬盘上的结构如下所示:
• “out”文件夹包含 *.class 文件
• “src”文件夹包含 *.java 文件
问题:
如何使用我的结构在 PowerShell 的命令行中运行 JUnit 测试用例?
【问题讨论】:
标签: java powershell junit command-line automated-tests