Reputation: 483
enter image description hereWhen I run scala tests through Jenkins and maven, it gives me following output. I am not sure why it is not picking my scala test which is under src/test/scala. The output in jenkins' console output is as follows-
[INFO] [scalatest:test {execution: test}]
[36mRun starting. Expected test count is: 0[0m
[32mDiscoverySuite:[0m
[36mRun completed in 905 milliseconds.[0m
[36mTotal number of tests run: 0[0m
[36mSuites: completed 1, aborted 0[0m
[36mTests: succeeded 0, failed 0, ignored 0, pending 0[0m
[32mAll tests passed.[0m
Above is my folder structure. PFB my pom.xml-
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hsbc.ftp.bigdata</groupId>
<artifactId>rpf</artifactId>
<version>${rpf.release.version}</version>
<distributionManagement>
<repository>
<id>dsnexus-releases</id>
<name>Nexus Release Repository</name>
<url>https://dsnexus.uk.hibm.hsbc:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>dsnexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>https://dsnexus.uk.hibm.hsbc:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.version>2.10.5</scala.version>
</properties>
<build>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<sourceDirectory>src/main</sourceDirectory>
<resources>
<resource>
<directory>src/main</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.scala</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<index>true</index>
<manifest>
<mainClass>com.hsbc.ftp.rpf.driver.RPFDriver</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>WDFTestSuite.txt</filereports>
<skipTests>false</skipTests>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-hive_2.10</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.4</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>jodaExt</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-convert</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.10</artifactId>
<version>1.9.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
could you please suggest how can I have my scala test executed?
Thanks Abhishek Somani
Upvotes: 0
Views: 1328
Reputation: 31192
add scala-maven-plugin
plugin to be able to run scalatests using maven. I tried your scenario, and it works only with scala-maven-plugin
with testCompile
goal.
The scala-maven-plugin (previously maven-scala-plugin - https://mvnrepository.com/artifact/org.scala-tools/maven-scala-plugin/2.15.2) is used for compiling/testing/running/documenting scala code in maven.
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<parallel>false</parallel>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>test-suite.log</filereports>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Or since you already have maven-scala-plugin
, just add testCompile
to your execution goal.
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
I know http://www.scalatest.org/user_guide/using_the_scalatest_maven_plugin mentions only scalatest-maven-plugin
which is not true. scalatest-maven-plugin
tries to discover the tests but does run anything.
Upvotes: 1