views:

1784

answers:

5

Is there a way to cause hudson to report a build as failed, rather than unstable, if only a single unit test fails? thanks.

A: 

If you're using Ant to drive the build, you can configure the JUnit task to halt on failure. Is that what you mean?

duffymo
I'm actually using maven...
Jeff Storey
But I don't want to stop the build on a test failure. Hudson just reports the build as unstable, but I want it to report as failed if 1 or more unit tests fail.
Jeff Storey
A: 

Look through your job configuration, I believe there is a property (check box) that says fail on test failure, or something of the sort. We use this on some of our projects at my work.

Otherwise if you want to use the Ant method as suggested maven can run ant tasks...

Martin Dale Lyness
+1  A: 

There are two properties to the junit task

errorProperty="maven.test.error"
failureProperty="maven.test.failure"

After the junit tag you should be able to do something like this

<fail message="Test failed!!!" if="maven.test.error" />
<fail message="Test failed!!!" if="maven.test.failure" />

But don't nail me on this

jitter
Nice idea if it works!
furtelwart
+2  A: 

Hudson actually enables the ignoring of test failures. It just needs to be put as a property in hudson. -Dmaven.test.failure.ignore=false

Jeff Storey
+1  A: 

It's actually not a good idea to fail the build if tests failed when using hudson. Problem is hudson will not report the state of test pass/fail if the build fails. If the build fails, hudson deems it to not have completed properly and thus does not act on the result.

Michael Wiles