【发布时间】:2016-10-23 21:23:07
【问题描述】:
尝试做一些自动化测试。当我尝试在命令行中执行 junit 时出现错误,
尝试的命令
java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar org.junit.runner.JUnitCore C:/Users/path/workspace/CucumberConcept/src/ cucumber.CucumberRunner
java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar;C:/Users/path/workspace/CucumberConcept/src/ org.junit.runner.JUnitCore cucumber.CucumberRunner
java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar org.junit.runner.JUnitCore CucumberConcept.src.cucumber.CucumberRunner
java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar org.junit.runner.JUnitCore cucumber.CucumberRunner.CucumberRunner
java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar org.junit.runner.JUnitCore CucumberRunner.CucumberRunner
java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar org.junit.runner.JUnitCore CucumberRunner CucumberRunner
java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar org.junit.runner.JUnitCore CucumberRunner.java CucumberRunner
java -cp C:/Users/path/Downloads/selenium-java-3.0.1/lib/junit-4.12.jar org.junit.runner.JUnitCore CucumberRunner
Junit 代码:
package cucumber;
import org.junit.runner.RunWith;
import cucumber.api.junit.*;
import cucumber.api.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = {"pretty","json:target/json/output.json","html:target/html/"},
features = {"src/cucumber/"}
)
public class CucumberRunner {
}
命令行
C:\Users\path\CucumberConcept\src>java -classpath C:/Users/path/lib/junit-4.12.jar;classes org.junit.runner.JUnitCore cucumber.CucumberRunner
JUnit version 4.12
.E
Time: 0.004
There was 1 failure:
1) initializationError(org.junit.runner.JUnitCommandLineParseResult)
java.lang.IllegalArgumentException: Could not find class [cucumber.CucumberRunne
r]
at org.junit.runner.JUnitCommandLineParseResult.parseParameters(JUnitCom
mandLineParseResult.java:102)
at org.junit.runner.JUnitCommandLineParseResult.parseArgs(JUnitCommandLi
neParseResult.java:50)
at org.junit.runner.JUnitCommandLineParseResult.parse(JUnitCommandLinePa
rseResult.java:44)
at org.junit.runner.JUnitCore.runMain(JUnitCore.java:72)
at org.junit.runner.JUnitCore.main(JUnitCore.java:36)
Caused by: java.lang.ClassNotFoundException: cucumber.CucumberRunner
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.junit.internal.Classes.getClass(Classes.java:16)
at org.junit.runner.JUnitCommandLineParseResult.parseParameters(JUnitCom
mandLineParseResult.java:100)
... 4 more
FAILURES!!!
Tests run: 1, Failures: 1
【问题讨论】:
标签: java command-line junit cucumber automated-tests