简体   繁体   English

Maven不会通过詹金斯运行Scala测试

[英]maven does not run scala tests through jenkins

enter image description here When I run scala tests through Jenkins and maven, it gives me following output. 在此处通过Jenkins和Maven运行Scala测试时,它会为我提供以下输出。 I am not sure why it is not picking my scala test which is under src/test/scala. 我不确定为什么不选择src / test / scala下的scala测试。 The output in jenkins' console output is as follows- 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

enter image description here 在此处输入图片说明

Above is my folder structure. 上面是我的文件夹结构。 PFB my pom.xml- PFB我的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? 您能建议我如何执行我的Scala测试吗?

Thanks Abhishek Somani 感谢Abhishek Somani

add scala-maven-plugin plugin to be able to run scalatests using maven. 添加scala-maven-plugin插件,以便能够使用maven运行scalatests。 I tried your scenario, and it works only with scala-maven-plugin with testCompile goal. 我尝试了您的方案,它仅适用于具有testCompile目标的scala-maven-plugin

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. 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>

Or since you already have maven-scala-plugin , just add testCompile to your execution goal. 或者由于您已经具有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>

I know http://www.scalatest.org/user_guide/using_the_scalatest_maven_plugin mentions only scalatest-maven-plugin which is not true. 我知道http://www.scalatest.org/user_guide/using_the_scalatest_maven_plugin仅提及scalatest-maven-plugin ,但事实并非如此。 scalatest-maven-plugin tries to discover the tests but does run anything. scalatest-maven-plugin尝试发现测试,但是没有运行任何东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM