为什么找不到课程? JUnit Runner错误

时间:2019-10-11 06:42:32

标签: java selenium magento junit

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class admin_login {
private static WebDriver driver;
private static StringBuffer verificationErrors = new StringBuffer();
private static String CHROMEDRIVER_FILE_PATH;

public static void setUp() throws Exception {
    CHROMEDRIVER_FILE_PATH = "D:/java/chromedriver.exe";
     System.setProperty("webdriver.chrome.driver", CHROMEDRIVER_FILE_PATH); 
     driver = new ChromeDriver(); 
     } 
public void T01() throws Exception{
    driver.get("https://gapm.magentoshop.net/admin_gapm");
    driver.findElement(By.id("username")).click();
    driver.findElement(By.id("username")).clear();
    driver.findElement(By.id("username")).sendKeys("james");
    driver.findElement(By.id("login")).clear();
    driver.findElement(By.id("login")).sendKeys("dlrndksk15!");
    driver.findElement(By.xpath("//form[@id='login-form']/fieldset/div[3]/div/button/span")).click();
    Thread.sleep(5000);
    assertEquals("Dashboard / Sulwhasoo Magento Admin", driver.getTitle());

}

@AfterClass public static void tearDown() throws Exception 
{ 
    driver.close(); 
    String verificationErrorString = verificationErrors.toString(); 
    if (!"".equals(verificationErrorString)) {
        fail(verificationErrorString);
        }
} 

}

Test.Java代码

并编译命令行

javac -cp C:\Users\user\.p2\pool\plugins\org.junit_4.12.0.v201504281640\junit.jar;D:\java\selenium-java-3.141.59\client-combined-3.141.59.jar -d C:\Users\user\eclipse-workspace\test\src\test admin_login.java

因此创建了一个类文件。

和junit运行器命令

java -cp C:\Users\user\.p2\pool\plugins\org.junit_4.12.0.v201504281640\junit.jar org.junit.runner.JUnitCore admin_login

结果错误

JUnit version 4.12
.E
Time: 0.001
There was 1 failure:
1) initializationError(org.junit.runner.JUnitCommandLineParseResult)
java.lang.IllegalArgumentException: Could not find class [admin_login]
        at org.junit.runner.JUnitCommandLineParseResult.parseParameters(JUnitCommandLineParseResult.java:102)
        at org.junit.runner.JUnitCommandLineParseResult.parseArgs(JUnitCommandLineParseResult.java:50)
        at org.junit.runner.JUnitCommandLineParseResult.parse(JUnitCommandLineParseResult.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: admin_login
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:415)
        at org.junit.internal.Classes.getClass(Classes.java:16)
        at org.junit.runner.JUnitCommandLineParseResult.parseParameters(JUnitCommandLineParseResult.java:100)
        ... 4 more

FAILURES!!!
Tests run: 1,  Failures: 1

做什么

  

找不到类[admin_login]

是平均值?

环境:Junit4,Windows cmd命令行

我已经用很多方法来运行它。

0 个答案:

没有答案