enter image description here当我通过Jenkins和maven运行scala测试时,它会给我以下输出。我不确定为什么它不是在src / test / scala下选择我的scala测试。 jenkins控制台输出中的输出如下 -
[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
以上是我的文件夹结构。 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>
您能否建议我如何执行我的scala测试?
由于 Abhishek Somani
答案 0 :(得分:0)
添加scala-maven-plugin
插件,以便能够使用maven运行scalatests。我尝试了您的方案,它仅适用于scala-maven-plugin
testCompile
目标。
scala-maven-plugin(以前的maven-scala-plugin - https://mvnrepository.com/artifact/org.scala-tools/maven-scala-plugin/2.15.2)用于 在maven中编译/测试/运行/记录scala代码。
<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>
或者您已经拥有maven-scala-plugin
,只需将testCompile
添加到您的执行目标中。
<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>
我知道http://www.scalatest.org/user_guide/using_the_scalatest_maven_plugin仅提及scalatest-maven-plugin
这不是真的。 scalatest-maven-plugin
试图发现测试,但确实运行了任何东西。