我在 netbeans 6.9.1 中有一个 maven 项目,里面有一个 junit 4.4 测试类。
在 netbeans 上下文菜单中,我可以“清理和构建”我的项目,并且在输出中我可以看到,我的测试类是由 surefire 找到并运行的。
现在我从上下文菜单“调试测试文件”中选择,在输出中它就像
--- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ <project-name> --- 编译2个源文件到<project-path>\target\test-classes
--- maven-surefire-plugin:2.7.2:test (default-cli) @ <project-name> --- Surefire 报告目录:<project-path>\target\surefire-reports
测试
没有要运行的测试。
到目前为止我检查过的内容:
构建项目找到测试文件,但仍然存在 <testSourceDirectory> 并且正确
*.pom 依赖项中只有一个 junit - 4.4
类文件本身看起来像
导入 junit.framework.TestCase;
导入 org.junit.Test;
公共类 SomeTest 扩展 TestCase { @Test public void testFoo() throws Exception { / --- /} }
调试的 netbeans 动作描述看起来像
执行目标:test-compile surefire:test
设置属性: jpda.listen=true maven.surefire.debug=-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} jpda.stopclass=${packageClassName} failIfNoTests=false // 这是我的补充,没有它仍然失败 forkMode=once test=${className}
项目 *.pom 文件中的任何地方都没有安全插件部分