0
votes

I ran a few thousand JUnit tests in Jenkins. Some tests fail with a No tests found in ....Test. I noticed that these tests are problematic because they combine the JUnit3 and the JUnit4 approach. To be more specific these tests:

  • extend MyTestCase which extends TestCase (JUnit3)
  • the test methods' names don't end in ...test. They have the @Test annotation instead. (JUnit4)

The thing is that when I run these tests in Eclipse I don't get the same error. The tests run normally and they either pass or fail. So my question is this: How is it possible that Jenkins cannot find the tests whereas Eclipse can? Can I configure Jenkins somehow, in order to run these tests?

1
How is your build scripted? Maven? Gradle? Ant? Something else? - E-Riz
The script that I run via Jenkins is an Ant script. In Eclipse I ran the "problematic" ...Test.java files separately(right click --> Run As --> JUnit Test). - V Ts
It would probably help to show the Ant script. - E-Riz
Jenkins of its' own does not find anything, it is the build tool (Ant, Maven, etc.) that does this. As you are using Ant the problem lies there. - cheffe
@cheffe You are right, totally wrong expression, it's not a Jenkins thing! - V Ts

1 Answers

0
votes

The tests run in Eclipse with a JUnit4 runner thanks to a @RunWith() annotation. However, ant seems to ignore the annotations and execute the tests as JUnit3 tests because they extend TestCase. I managed to solve this based on this post from @AlexanderMiles. Thanks a lot!