2016-12-19 22 views
0

SBTmavenに置き換えたScalaプロジェクトがあります。Mavenテストでテストが実行されない

私は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>myProjectName</groupId> 
    <artifactId>my.package.myProjectName</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name></name> 
    <url>http://maven.apache.org</url> 

    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
     <!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core_2.10 --> 
    <dependency> 
     <groupId>org.apache.spark</groupId> 
     <artifactId>spark-core_2.10</artifactId> 
     <version>1.6.0</version> 
    </dependency> 
    <!-- https://mvnrepository.com/artifact/org.scalatest/scalatest_2.11 --> 
    <dependency> 
     <groupId>org.scalatest</groupId> 
     <artifactId>scalatest_2.11</artifactId> 
     <version>3.0.1</version> 
    </dependency> 
    <!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-testkit_2.11 --> 
    <dependency> 
     <groupId>com.typesafe.akka</groupId> 
     <artifactId>akka-testkit_2.11</artifactId> 
     <version>2.4.14</version> 
    </dependency> 
    <!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-http-testkit_2.11 --> 
    <dependency> 
     <groupId>com.typesafe.akka</groupId> 
     <artifactId>akka-http-testkit_2.11</artifactId> 
     <version>10.0.0</version> 
    </dependency> 
    </dependencies> 

</project> 

が、私は上記のテキストで依存関係の一部を削除しました。

私はmvn testを実行すると、テストが実行されないという問題があります。

試験はsrc/test/scala/my/packageにあります。

名前にtestが含まれていませんが、名前の末尾にTestを追加しても実行されません。

+0

テストはまあ、私はScalaのプロジェクトではない持って – khmarbaise

+0

.... ... '/'のsrc /テスト/ javaの下に位置するように、プラスのパッケージ名を持っていると '* Test.java'のように名前を付ける必要がありますJavaのもの。 – octavian

+1

mavenには、あなたのscalaソースをコンパイルしてテストするためのプラグインが必要です。ここにプラグインhttps://github.com/davidB/scala-maven-pluginがあります。編集:例が古いです。 – roby

答えて

2

スカラソースをコンパイルしてテストするには、scala-maven-pluginをビルドに追加する必要があります。

<project> 
    ... 
    <build> 
     <sourceDirectory>src/main/scala</sourceDirectory> 
     <testSourceDirectory>src/test/scala</testSourceDirectory> 
     ... 
     <plugins> 
      <plugin> 
       <groupId>net.alchim31.maven</groupId> 
       <artifactId>scala-maven-plugin</artifactId> 
       <version>3.2.1</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>compile</goal> 
          <goal>testCompile</goal> 
         </goals> 
        </execution> 
       </executions> 
       <!-- explicit scala version not recommended--> 
       <!-- usually inferred from scala-library dependency--> 
       <configuration> 
        <scalaVersion>${scala.version}</scalaVersion> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 
+0

私はdocs http://davidb.github.io/scala-maven-plugin/ccに基づいて ' ...'や ' ...'を定義する必要はないと思います-mojo.html(参考文献http://docs.scala-lang.org/tutorials/scala-with-maven.html)... – khmarbaise

+0

良い、私はちょうどhttp:// davidb .github.io/scala-maven-plugin/usage.html – roby

関連する問題