Sámal Rasmussen
Sámal Rasmussen

Reputation: 3515

How to run junit tests at build time in netbeans and jenkins?

I'm trying to set up a project to run junit tests at build time, so that every member of the team and the Jenkins build server runs the tests when it builds.

I believe we have set up a fairly standard webproject in Netbeans, but I can't seem to find anyone solving this problem on stackoverflow or google.

How would you go about doing this?

Upvotes: 1

Views: 1531

Answers (2)

Halko Karr-Sajtarevic
Halko Karr-Sajtarevic

Reputation: 2278

Never modify your build-impl.xml! Netbeans regenerates this file when you perform any changes to your project.

The better approach would be to modify your build.xml and add a post-jar task:

<target name="-post-jar" depends="test"/>

Upvotes: 1

S&#225;mal Rasmussen
S&#225;mal Rasmussen

Reputation: 3515

Go to file: /nbproject/build-impl.xml and fidn the dist target. It should look like this:

<target depends="init,compile,-pre-dist,do-dist,-post-dist" description="Build distribution (WAR)." name="dist"/>

Copy paste it into /build.xml, and add the "test" target into it:

<target depends="init,compile,test,-pre-dist,do-dist,-post-dist" description="Build distribution (WAR)." name="dist"/>

This was in Netbeans 7.3. It now builds and runs the tests on every build, also on the Jenkins build server.

Upvotes: 1

Related Questions