C0deAttack
C0deAttack

Reputation: 24667

mvn test does not find JUnit Tests

I have a a test class which is named xxxTest.java so the test class if found. But the unit tests within the class are not run when I execute mvn test.

I am using JUnit 4 and the test method's are annotated with @Test. eg.

@Test
public void shouldDoSomeAsserting() {
    // unit test impl
}

If I rename that test method so it is name testShouldDoSomeAsserting() then mvn test does find and execute that unit test.

I was under the impression that when I use @Test as long as the method was public and void that it would be considered a test method.

Have I missed something?

Thanks.

Upvotes: 1

Views: 375

Answers (2)

C0deAttack
C0deAttack

Reputation: 24667

I've got it working by manually specifying a provider; more details here: Surefire JUnit 4 config

Upvotes: 2

Chris B
Chris B

Reputation: 9259

Are you absolutely sure you are using JUnit 4? This sounds like JUnit 3 behaviour.

I made a minimal sample project and I couldn't recreate your problem. The test runs as expected.

The sample project is here: https://gist.github.com/1888802

Maybe you can get some kind of hint from it.

Upvotes: 2

Related Questions