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

标签 java ant compiler-errors

我尝试通过 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/

相关文章:

java - Mule - 测试具有以 Mule 属性作为文件路径的入站/出站端点的流

ant - 如何使用 Ant(或 Maven)动态创建 jaxb.in​​dex 文件

java - Ant 构建脚本中的 JUnit 尝试删除 .svn 目录但失败

compiler-errors - 在Android Studio中编译Cocos 2d-x-3.15.1项目时发生错误

objective-c - 如何解决链接器命令失败,退出代码为1(使用-v查看调用)

java - JTable可以通过用户拖动鼠标来调整大小吗

java.sql.SQLException : Access denied for user 'wineship' @'localhost' (using password: YES) 异常

java - @DeclareMixin 添加其他类不可见的方法

ant - 如何在 Ant 的 basedir 路径中获取最后一个文件夹的名称?

node.js - 安装nodetime时编译出错