Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jenkins maven build not running JUnit tests

I have the exact same code, just being compiled in two different ways. One is a maven build in Spring, and the other is a maven build in Jenkins.

The Spring build produces

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building TestApplication 1.0.0-BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Woof ---
[INFO] Deleting TestApplication\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Woof ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ Woof ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 7 source files to TestApplication\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Woof ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ Woof ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Woof ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ Woof ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to TestApplication\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ Woof ---
[INFO] Surefire report directory: TestApplication\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.woof.bark.TestTest
Tests run: 5, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.667 sec <<< FAILURE!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

But the Jenkins build produces

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building TestApplication 1.0.0-BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Woof ---
[INFO] Deleting TestApplication\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Woof ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ Woof ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 7 source files to TestApplication\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Woof ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ Woof ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Woof ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ Woof ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to TestApplication\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ Woof ---
[INFO] Surefire report directory: TestApplication\target\surefire-reports
[JENKINS] Recording test results
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
Finished: SUCCESS

How do i get Jenkins to also run unit tests and stop build when a case fails?

Adding MAVEN_OPTS -DskipTests=false -Dmaven.test.failure.ignore=false does not work.

like image 391
Arfs Avatar asked Sep 26 '22 00:09

Arfs


1 Answers

Turns out i was missing a plugin in my POM.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.8.1</version>
</plugin>
like image 169
Arfs Avatar answered Oct 11 '22 16:10

Arfs