在Netbeans下运行测试时出现问题

时间:2009-12-09 13:06:18

标签: unit-testing netbeans

我正在运行一些Junit测试,Netbeans在“输出”窗口中给出报告的行为奇怪:

Testcase: warning(junit.framework.TestSuite$1):        FAILED
No tests found in uk.ac.cam.ch.wwmm.chemicaltagger.ChemistryPOSTaggerTest
junit.framework.AssertionFailedError: No tests found in uk.ac.cam.ch.wwmm.chemicaltagger.ChemistryPOSTaggerTest


Test uk.ac.cam.ch.wwmm.chemicaltagger.ChemistryPOSTaggerTest FAILED (crashed)
test:
BUILD SUCCESSFUL (total time: 12 seconds)

(5)测试在那里。我运行了mvn test运行它们但是在OutOfMemoryError上失败了。这可能是Netbeans问题的原因吗?

1 个答案:

答案 0 :(得分:1)

您是如何创建测试文件的?手动,还是使用NB向导? (工具 - 从Java文件的弹出菜单中创建JUnit测试)

如果您使用的是JUnit 3,则测试文件中的所有测试方法都必须以“test”开头,例如

public void testFoo() { //some testing here :) }

使用JUnit 4时,需要一个'@Test'注释,例如

@Test
public void myOwnTestFoo() { //...}

否则JUnit无法识别测试并抛出AssertionFailedError错误。