java ant compile在同一个包中的同一目录中找不到类

时间:2016-10-25 07:39:55

标签: java ant compiler-errors

我尝试使用cm通过cmd编译JUnit / Selenium测试。我不能使用eclipse,它已经破坏了Intellisense。 我在同一目录和相同的包中添加了一个“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:\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

任何帮助表示赞赏!

1 个答案:

答案 0 :(得分:0)

我们添加了throw new AssertionCustomException();,感谢Jameson给出了正确答案!