我尝试通过 cmd 使用 ant 编译 JUnit/Selenium 测试。我不能使用 Eclipse,因为它破坏了 Intellisense。
我在同一目录和同一包中添加了一个具有相同文件名的“AssertionCustomException”公共(public)类:
package de.auticon.zeiterfassung;
/**
* My custom exception class.
*/
public class AssertionCustomException extends Exception
{
//Parameterless Constructor
public AssertionCustomException() {}
public AssertionCustomException(String message)
{
super(message);
}
}
但是抛出命令:
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:\Source\workspace4\ahub\src\de\auticon\zeiterfassung\Test_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();
,感谢詹姆森给出正确答案!
关于java ant compile 在同一个包的同一个目录中找不到类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40234086/