2015-02-05 73 views
4

我正在使用maven scala測試插件,如here所述。我定義了兩個測試類,並把它們src/test/scala下:Maven不會運行scala測試

enter image description here

測試正在尋找類似如下:

class LoginTest extends FlatSpec with ShouldMatchers with WebBrowser with Eventually with IntegrationPatience { 
    ... 
} 

pom.xml包含以下依賴性/配置:

<dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.11</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.seleniumhq.selenium</groupId> 
     <artifactId>selenium-java</artifactId> 
     <version>2.44.0</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.scalatest</groupId> 
     <artifactId>scalatest_2.11</artifactId> 
     <version>2.2.1</version> 
     <scope>test</scope> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <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>WDF TestSuite.txt</filereports> 
      </configuration> 
      <executions> 
       <execution> 
        <id>test</id> 
        <goals> 
         <goal>test</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>org.scala-tools</groupId> 
      <artifactId>maven-scala-plugin</artifactId> 
      <version>2.15.2</version> 
      <executions> 
       <execution> 
        <id>scala-compile</id> 
        <goals> 
         <goal>compile</goal> 
         <goal>testCompile</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

當我運行mvn test時,我收到消息:

[INFO] --- scalatest-maven-plugin:1.0:test (test) @ selenium --- 
Discovery starting. 
Discovery completed in 30 milliseconds. 
Run starting. Expected test count is: 0 
DiscoverySuite: 
Run completed in 91 milliseconds. 
Total number of tests run: 0 
Suites: completed 1, aborted 0 
Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0 
No tests were executed. 

調用從Intellij測試帶來了一個消息:

0 test class found in package '<default package>' 
+2

使用斯卡拉,Maven的插件(Maven的斯卡拉 - 插件已被棄用)我是兩者的作者。抱歉不知道你的問題 – 2015-02-06 12:45:19

回答

0

過類似的問題 MVN安裝發現的測試,MVN測試不

0

我不得不作出2個改變了這工作我case:

  1. 更改filereport的名稱,刪除空間:<filereports>WDFTestSuite.txt</filereports>
  2. 明確說不能跳過測試:<skipTests>false</skipTests>

所以配置塊看起來是這樣的:

    <configuration> 
         <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory> 
         <junitxml>.</junitxml> 
         <filereports>WDFTestSuite.txt</filereports> 
         <skipTests>false</skipTests> 
        </configuration>