1

I have a Maven-managed Java project that includes JUnit tests -- nothing unusual. Recently, I started getting broken builds on my machine, but Hudson stayed happy. I realized that I had made a change that broke a unit test, but noticed that Hudson wasn't running the unit test. Most of my tests ran fine, but everything in one of my packages was totally absent. Not listed as 'skipped', but actually missing.

Now, I didn't set up this Hudson instance, and I'm not a guru, so I wasn't sure where to start. In no particular order:

  • I looked at the project settings page, and copied the exact Maven command line being used and ran it locally. There are some Hudson-specific profile settings in the POM, so I thought it was worth a shot. Missing tests still run (and fail).
  • I tried to look at old executions, to see if maybe it was a recent change. Unfortunately, we only keep 5 old builds, so dead end there.
  • I checked the POM carefully to see if anything might ever cause it to exclude tests -- not a Maven genius but I can say pretty confidently that there shouldn't be anything, and anyway it shouldn't matter because of bullet #1
  • I downloaded the Hudson workspace. Interestingly, there's a test-classes directory under /target which has .class files for all the missing tests, but /target/surefire-reports has no matching output files

I feel like I must be missing some kind of setting somewhere, or at least some kind of logfile that would indicate how this is happening -- maybe the tests are failing so badly as to nuke the Surefire process that invoked them before it can write about the failure? -- but like I said, Hudson newb. What should my next move be?


UPDATE: Installed Jenkins locally and tried to reproduce. I'm losing my mind: it still fails to run quite a few tests, even if I log in myself, go to the Jenkins job workspace, and build

  • under my own account
  • using my own local m2 repo (from a network drive)
  • using the same Maven / Java binaries (from a network drive)
  • running the same OS

As far as I can tell, the source on the two machines is identical, my environment should be the same (same account)... I can't think of any differences, except of course that a lot of tests don't run on the Jenkins box.

Coderer
  • 25,844
  • 28
  • 99
  • 154
  • 2
    If you can log into the Hudson box somehow and become the user that's running the Hudson builds, run that same Maven command there and see what happens. – Ryan Stewart Aug 05 '11 at 04:02
  • what is your goal and options ( inside the job config )? can you post screenshot of your config? Thanks. – Rudy Aug 16 '11 at 07:37
  • Unfortunately this Hudson is on an internal network and is airgapped from the Internet, so bringing over a screenshot is not trivial. I'm working on reproducing the tests-not-running issue interactively; if I can't track that down I'll follow up here. – Coderer Aug 16 '11 at 19:20

2 Answers2

2

I just had this exact problem and I'm willing to bet that some of your tests weren't following the standard naming convention; *Test.java. Surefire by default only picks up tests adhering to a certain naming convention; http://maven.apache.org/plugins/maven-surefire-plugin/examples/inclusion-exclusion.html

Ben Logan
  • 166
  • 2
  • 9
  • 1
    I was under the impression that this was the difference between JUnit 3 and JUnit 4. No? – Coderer Dec 29 '11 at 19:41
  • The problem described here could be caused by a couple of things. You are possibly correct - but my explanation is still a possibility. In my scenario I was using TestNG and I had simply not realised that by default the Maven plugin expects test classes to be strictly named. There is no way of knowing if this was the original authors problem. – Ben Logan Jan 10 '12 at 13:06
0

I'm almost positive that this is not Hudson's fault, or even strictly Maven's fault. I think it's a JUnit bug, and I'll chase it down in this other question.

Community
  • 1
  • 1
Coderer
  • 25,844
  • 28
  • 99
  • 154