Scalatest maven plugin: ERROR: -c has been deprecated for a very long time and is no longer supported
Scalatest maven plugin: ERROR: -c has been deprecated for a very long time and is no longer supported
我正在使用 scalatest-maven-plugin latest 1.0 version, with source code here。尝试并行 运行 我的套件并使用以下配置:
<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-plugin 将 -c
传递给 scalatest CLI 而不是正确的 -P
.. 甚至更好 -P10
即要使用的线程数。
如何通过 Maven 将 -P10
传递给最大规模的进程?我已经尝试在 MAVEN_OPTS
环境变量或直接在 Maven CLI 中设置它,但它没有被拾取。
我也试过像这样配置 scalatest-maven-plugin:
<configuration>
<argLine>-P10</argLine>
</configuration>
但此参数传递给 java 进程而不是 Scalatest,因此它也失败了。
我创造了my own fork of the scalatest-maven-plugin, fixed the parallel issue and versioned it as 1.1-SNAPSHOT I had to also fix the build etc it was all broken. I included a directly downloadable compiled tarball version scalatest-maven-plugin_1.1-SNAPSHOT.tar.gz
然后为了测试它,fork my own version of a scala-maven-example that uses my own fork of the scalatest-maven-plugin 并修改了scalatest示例代码以显示加载每个Suite的Thread Id和执行每个Suite的第一个测试的Thread 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 ***
我正在使用 scalatest-maven-plugin latest 1.0 version, with source code here。尝试并行 运行 我的套件并使用以下配置:
<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-plugin 将 -c
传递给 scalatest CLI 而不是正确的 -P
.. 甚至更好 -P10
即要使用的线程数。
如何通过 Maven 将 -P10
传递给最大规模的进程?我已经尝试在 MAVEN_OPTS
环境变量或直接在 Maven CLI 中设置它,但它没有被拾取。
我也试过像这样配置 scalatest-maven-plugin:
<configuration>
<argLine>-P10</argLine>
</configuration>
但此参数传递给 java 进程而不是 Scalatest,因此它也失败了。
我创造了my own fork of the scalatest-maven-plugin, fixed the parallel issue and versioned it as 1.1-SNAPSHOT I had to also fix the build etc it was all broken. I included a directly downloadable compiled tarball version scalatest-maven-plugin_1.1-SNAPSHOT.tar.gz
然后为了测试它,fork my own version of a scala-maven-example that uses my own fork of the scalatest-maven-plugin 并修改了scalatest示例代码以显示加载每个Suite的Thread Id和执行每个Suite的第一个测试的Thread 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 ***