Java 当JUnit类有多个导入时,如何从Windows CMD窗口运行JUnit测试?
以下是我的JUnit测试类: 包com.bynarystudio.tests.storefrontJava 当JUnit类有多个导入时,如何从Windows CMD窗口运行JUnit测试?,java,selenium,junit,classpath,Java,Selenium,Junit,Classpath,以下是我的JUnit测试类: 包com.bynarystudio.tests.storefront import java.util.List; import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import com.bynarystudio.tests.BaseWebTest; public class
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.bynarystudio.tests.BaseWebTest;
public class SmokeTests extends BaseWebTest {
@Test
public void StoreFrontMegaNavTest(){
webDriver.get(default_homepage);
String source = webDriver.getPageSource();
Assert.assertTrue(source.contains("some text"));
}
}
如何从命令行运行此测试?当我尝试使用从其目录中运行它时
java -cp junit.textui.TestRunner SmokeTests.java
我得到以下错误
Could not find the main class: SmokeTests.java. Program will exit.
我认为这与我的类路径设置不正确有关。但我不知道,因为我对Java是全新的。来自.NET、C#和Visual Studio的整个类路径问题毫无意义。即使我已将所有文件正确地添加到Eclipse中的项目中(我知道,因为测试在Eclipse中运行良好),它也绝对不会从命令行运行或编译。首先,您混合了两件事:
- 当前目录
- 来自c:/jars的所有jar文件/*
- 工作目录中deps目录中的所有jar文件
java-cp。;c:/jars/*;吸烟测试
yourpackage-是SmokeTests类的包,如果您没有在SmokeTests.java中定义包,请将其留空首先,您混合了两件事:
- 当前目录
- 来自c:/jars的所有jar文件/*
- 工作目录中deps目录中的所有jar文件
java-cp。;c:/jars/*;吸烟测试 yourpackage-是SmokeTests类的包,如果您没有在SmokeTests.java中定义包,请将其留空