Note that there are some explanatory texts on larger screens.

plurals
  1. POMaven fails to run unit tests on cloudbees
    primarykey
    data
    text
    <p>I have a Maven based Android project setup for ci on cloudbees. My Jenkins job is just running the 'install' goal after retrieving the src from BitBucket. Everything builds fine. The only issue is that the unit tests fail to run. </p> <p>Running exactly the same goal in IntelliJ (locally) does find and run the unit tests. </p> <p>My pom looks like this --></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;com.odl&lt;/groupId&gt; &lt;artifactId&gt;GhostRunner&lt;/artifactId&gt; &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt; &lt;packaging&gt;apk&lt;/packaging&gt; &lt;name&gt;GhostRunner&lt;/name&gt; &lt;properties&gt; &lt;platform.version&gt; 4.1.1.4 &lt;/platform.version&gt; &lt;/properties&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;com.google.android&lt;/groupId&gt; &lt;artifactId&gt;android&lt;/artifactId&gt; &lt;version&gt;${platform.version}&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.robolectric&lt;/groupId&gt; &lt;artifactId&gt;robolectric&lt;/artifactId&gt; &lt;version&gt;2.0-alpha-1&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;junit&lt;/groupId&gt; &lt;artifactId&gt;junit&lt;/artifactId&gt; &lt;version&gt;4.8.2&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.j256.ormlite&lt;/groupId&gt; &lt;artifactId&gt;ormlite-android&lt;/artifactId&gt; &lt;version&gt;4.45&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.j256.ormlite&lt;/groupId&gt; &lt;artifactId&gt;ormlite-core&lt;/artifactId&gt; &lt;version&gt;4.45&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.j256.ormlite&lt;/groupId&gt; &lt;artifactId&gt;ormlite-jdbc&lt;/artifactId&gt; &lt;version&gt;4.45&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.mockito&lt;/groupId&gt; &lt;artifactId&gt;mockito-all&lt;/artifactId&gt; &lt;version&gt;1.8.4&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;com.jayway.maven.plugins.android.generation2&lt;/groupId&gt; &lt;artifactId&gt;android-maven-plugin&lt;/artifactId&gt; &lt;version&gt;3.6.0&lt;/version&gt; &lt;configuration&gt; &lt;androidManifestFile&gt;${project.basedir}/AndroidManifest.xml&lt;/androidManifestFile&gt; &lt;assetsDirectory&gt;${project.basedir}/assets&lt;/assetsDirectory&gt; &lt;resourceDirectory&gt;${project.basedir}/res&lt;/resourceDirectory&gt; &lt;nativeLibrariesDirectory&gt;${project.basedir}/src/main/native&lt;/nativeLibrariesDirectory&gt; &lt;sdk&gt; &lt;platform&gt;16&lt;/platform&gt; &lt;/sdk&gt; &lt;undeployBeforeDeploy&gt;true&lt;/undeployBeforeDeploy&gt; &lt;/configuration&gt; &lt;extensions&gt;true&lt;/extensions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;version&gt;3.0&lt;/version&gt; &lt;configuration&gt; &lt;source&gt;1.6&lt;/source&gt; &lt;target&gt;1.6&lt;/target&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt; &lt;version&gt;2.15&lt;/version&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre> <p>The jenkins output like this --></p> <pre><code>[INFO] --- maven-surefire-plugin:2.15:test (default-test) @ GhostRunner --- [INFO] No tests to run. mojoSucceeded org.apache.maven.plugins:maven-surefire-plugin:2.15(default-test) [JENKINS] Recording test results mojoStarted com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0(default-emma) </code></pre> <p>Another interesting point is that I can remove the surefire dependency and the unit tests still run fine against the install goal in IntelliJ. For some reason Maven is just not seeing the tests when run from Jenkins on Cloudbees.</p> <p>Wisdom received gratefully.</p> <p><strong>Here's what cloudbees had to say ::</strong></p> <blockquote> <p>The issue here is that IntelliJ is compiling the test classes for you and putting those classes into the ${project.build.testOutputDirectory} for you.</p> <p>You can replicate this failure locally by getting IntelliJ to execute clean install (hold ⌘ while clicking on the lifecycle goals)</p> <p>There are two ways to solve this problem.</p> <p>Tell Maven that your test sources are not in the standard place</p> <p>Put your test sources into the standard place.</p> <p>When you are dealing with lots of plugins, some of which not written by the Apache Maven team or the Codehaus Mojo team, going with the standard directory layout is the best way. Plugins subject to the review of the Apache Maven or Codehaus Mojo communities will usually pick up the changes when you tell Maven that you are using a non-standard layout. Plugins not subject to that review process can often not be aware of how to work correctly and as such you end up forced to align with the standard layout.</p> <p>Stephen Connolly CloudBees, Inc</p> </blockquote> <p>I've re-organized my project to reflect the Maven norm but it's still not running the tests on the cloudbees server. </p> <p>Here's the relevant output from the jenkins console output ::</p> <pre><code>[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ GhostRunner --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /scratch/jenkins/workspace/ghost runner/src/test/resources mojoSucceeded org.apache.maven.plugins:maven-resources-plugin:2.6(default-testResources) mojoStarted org.apache.maven.plugins:maven-compiler-plugin:3.0(default-testCompile) [INFO] No sources to compile [INFO] [INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ GhostRunner --- mojoSucceeded org.apache.maven.plugins:maven-compiler-plugin:3.0(default-testCompile) mojoStarted org.apache.maven.plugins:maven-surefire-plugin:2.15(default-test) [INFO] [INFO] --- maven-surefire-plugin:2.15:test (default-test) @ GhostRunner --- [INFO] No tests to run. </code></pre> <p>I guess the important bit is </p> <blockquote> <p>No sources to compile</p> </blockquote> <p>Somehow it still doesn't know where the tests are.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload