我试着通过cmd编译一个JUnit/Selenium测试。我不能使用eclipse,因为它已经破坏了智能感应。我添加了一个"AssertionCustomException"公共类,在同一目录和相同的包中具有相同的文件名:
package de.auticon.zeiterfassung;
/**
* My custom exception class.
*/
public class AssertionCustomException extends Exception
{
//Parameterless Constructor
public AssertionCustomException() {}
public AssertionCustomException(String message)
{
super(message);
}
}
但是throw命令:
if (error){
throw AssertionCustomException;
} else {
try {
className = "has-error";
input = driver.findElement(By.className(className));
result = input.isDisplayed();
System.out.println("Page contains error: " + result);
assertTrue("Error: displayed", result);
} catch (NoSuchElementException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
fail("No Error message");
}
}
给出错误:
[javac] C:Sourceworkspace4ahubsrcdeauticonzeiterfassungTest_enter_day.java:247: error: cannot find symbol
[javac] throw AssertionCustomException;
[javac] ^
[javac] symbol: variable AssertionCustomException
[javac] location: class Test_enter_day
感谢任何帮助!
我们添加了throw new AssertionCustomException();
,感谢Jameson给出的正确答案!