0

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?

E-Riz
  • 31,431
  • 9
  • 97
  • 134
V Ts
  • 1
  • 1
  • 1
    How is your build scripted? Maven? Gradle? Ant? Something else? – E-Riz Apr 01 '16 at 11:49
  • 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 Apr 01 '16 at 14:21
  • 1
    It would probably help to show the Ant script. – E-Riz Apr 01 '16 at 17:06
  • 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 Apr 04 '16 at 06:11
  • @cheffe You are right, totally wrong expression, it's not a Jenkins thing! – V Ts Apr 20 '16 at 11:11

1 Answers1

0

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!

Community
  • 1
  • 1
V Ts
  • 1
  • 1
  • I still have a problem executing a few tests with Ant though... These tests extend TestCase(JUnit3) and use JUnit4 annotations. The difference is that they are executed with the SpringJUnit4ClassRunner. Eclipse executes them thanks to @RunWith(SpringJUnit4ClassRunner.class). Ant does not recognise the annotations ,like in the other case. I do not know if there is a way to force Ant to run these tests with SpringJunit4ClassRunner instead of JUnit3 runner... – V Ts Apr 20 '16 at 12:09