Question

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

Was it helpful?

Solution

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

OTHER TIPS

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.

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

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

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...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top