2016-10-06 52 views
0

我使用scalatest-maven-plugin最新1.0版本,其中source code here。試圖並行運行我的套房和使用以下配置:Scalatest maven插件:錯誤:-c已被棄用很長時間,不再支持

<build><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> 
     <htmlreporters>${project.build.directory}/html/scalatest</htmlreporters>      
     <parallel>true</parallel> 
    </configuration> 
    <executions> 
     <execution> 
      <id>test</id> 
      <goals> 
       <goal>test</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin></build> 

導致以下Maven構建錯誤:

[INFO] 
[INFO] --- scalatest-maven-plugin:1.0:test (test) @ myproject --- 
Exception in thread "ScalaTest-main" java.lang.IllegalArgumentException: ERROR: -c has been deprecated for a very long time and is no longer supported, to prepare for reusing it for a different purpos 
e in the near future. Please change all uses of -c to -P. 
     at org.scalatest.tools.ArgsParser$.checkArgsForValidity(ArgsParser.scala:46) 
     at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:857) 
     at org.scalatest.tools.Runner$.main(Runner.scala:827) 
     at org.scalatest.tools.Runner.main(Runner.scala) 

基本上scalatest - Maven的插件是通過-c到scalatest CLI而不是正確的-P ..或甚至更好-P10即使用的線程數。

如何通過Maven將-P10傳遞給scalatest進程?我試圖直接在MAVEN_OPTS環境變量或Maven CLI中設置它,但它沒有被拾取。

我也曾嘗試配置scalatest - Maven的插件是這樣的:

<configuration> 
    <argLine>-P10</argLine> 
</configuration> 

但此參數是傳遞給Java進程,而不是到Scalatest所以它失敗了。

回答

1

我創建了my own fork of the scalatest-maven-plugin,修復了並行問題,並將其版本化爲1.1-SNAPSHOT我還必須修復構建等。我包括一個直接下載的編譯壓縮包版本scalatest-maven-plugin_1.1-SNAPSHOT.tar.gz

然後對其進行測試,分叉my own version of a scala-maven-example使用my own fork of the scalatest-maven-plugin和修改scalatest樣本代碼,以顯示用於加載每個執行每個套件的第一測試套件和線程ID線程ID 。我還讓當前的線程在每個點上休眠10秒,以查看發生了什麼。所有scalatest套件都由單個線程加載,並行執行,如果並行啓用。

這是使用<parallel>false</parallel>結果:

[INFO] --- scalatest-maven-plugin:1.1-SNAPSHOT:test (test) @ scala-maven-testing --- 
Discovery starting. 
** loading 'net.lockney.AcceptanceTest' Suite with ThreadId=1 
==> executing 'Simple thing state' test with ThreadId=1 
** loading 'net.lockney.MatcherExampleSuite' Suite with ThreadId=1 
** loading 'net.lockney.SimpleSpec' Suite with ThreadId=1 
** loading 'net.lockney.SimpleSuite' Suite with ThreadId=1 
Discovery completed in 19 seconds, 98 milliseconds. 
Run starting. Expected test count is: 8 
AcceptanceTest: 
As a user 
I want to be able to create a simple thing and implicitly start it 
So that I can then turn it off 
And see that it is stopped 
Feature: Simple thing state 
    Scenario: User stops thing when it's already on 
    Given An initialized thing, that has not been started 
    When User stops it again 
    Then We should see that it is stopped 
==> executing 'equality' test with ThreadId=1 
MatcherExampleSuite: 
- equality 
==> executing 'SimpleObject' should 'accept a String' test with ThreadId=1 
- string matchers *** FAILED *** 
    "something" did not end with substring "some" (MatcherExampleSuite.scala:29) 
SimpleSpec: 
SimpleObject 
- should accept a String 
- should even accept really long Strings 
==> executing 'An empty Set should have size 0' test with ThreadId=1 
... 
Run completed in 28 seconds, 300 milliseconds. 
Total number of tests run: 8 
Suites: completed 5, aborted 0 
Tests: succeeded 6, failed 2, canceled 0, ignored 0, pending 0 
*** 2 TESTS FAILED *** 

,這是使用<parallel>true</parallel><parallelThreads>10</parallelThreads>結果:

[INFO] --- scalatest-maven-plugin:1.1-SNAPSHOT:test (test) @ scala-maven-testing --- 
Discovery starting. 
** loading 'net.lockney.AcceptanceTest' Suite with ThreadId=1 
==> executing 'Simple thing state' test with ThreadId=1 
** loading 'net.lockney.MatcherExampleSuite' Suite with ThreadId=1 
** loading 'net.lockney.SimpleSpec' Suite with ThreadId=1 
** loading 'net.lockney.SimpleSuite' Suite with ThreadId=1 
Discovery completed in 30 seconds, 904 milliseconds. 
Run starting. Expected test count is: 8 
MatcherExampleSuite: 
SimpleSuite: 
AcceptanceTest: 
SimpleSpec: 
SimpleObject 
As a user 
I want to be able to create a simple thing and implicitly start it 
So that I can then turn it off 
And see that it is stopped 
Feature: Simple thing state 
==> executing 'An empty Set should have size 0' test with ThreadId=13 
==> executing 'SimpleObject' should 'accept a String' test with ThreadId=12 
==> executing 'equality' test with ThreadId=11 
... 
Run completed in 40 seconds, 706 milliseconds. 
Total number of tests run: 8 
Suites: completed 5, aborted 0 
Tests: succeeded 6, failed 2, canceled 0, ignored 0, pending 0 
*** 2 TESTS FAILED ***