views:

56

answers:

1

I am running some Junit tests and Netbeans behaves strangely giving the report in "Output" window:

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)

The (5) tests are there. I have run mvn test which runs them but fails on OutOfMemoryError. Is this likely to be the cause of the Netbeans problem?

+1  A: 

Hello. How did you created your test file? Manually, or using NB wizard? (Tools - Create JUnit test from Java file's popup menu)

If you are using JUnit 3, all test methods in your test file must start with "test", e.g.

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

With JUnit 4, a '@Test' annotation is required, e.g.

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

Otherwise JUnit does not recognize the test and throws AssertionFailedError error.

Vafliik
Thanks. I have tried to make this Junit4 compliant (@Test, no junit.framework etc. but I suspect NB is still trying to use Junit3)
peter.murray.rust
You may add/remove JUnit libraries in the "Test Libraries" package of your NB project. Make sure, that there is only JUnit 4.x left.I also reccomend to create some test using the NB wizard - it will create correct test file. At least for inspiration for your own one :)
Vafliik