Jua*_*des 5 pom.xml maven-3 maven exec-maven-plugin
我正在使用exec-maven-plugin在maven项目中运行JavaScript单元测试
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>run-karma</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${node.bin.folder}/node</executable>
<workingDirectory>${project.basedir}</workingDirectory>
<arguments>
<argument>node_modules/karma/bin/karma</argument>
<argument>start</argument>
<argument>--single-run</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我假设如果我通过-DskipTests,将跳过整个测试阶段,但事实并非如此,只有在使用"Surefire,Failsafe和编译器插件"时才会尊重该skipTests标志.
问题:如何使执行取决于skipTests标志?
A_D*_*teo 10
您可以使用以下skip选项exec-maven-plugin:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<id>run-karma</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>cmd</executable>
<arguments>
<argument>/C</argument>
<argument>echo</argument>
<argument>hello</argument>
</arguments>
<skip>${skipTests}</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
注意${skipTests}作为其值的一部分的用法.另请注意,我推荐使用较新版本1.5.0.
运行:
mvn clean test -DskipTests
Run Code Online (Sandbox Code Playgroud)
输出将包含:
[INFO] Tests are skipped.
[INFO]
[INFO] --- exec-maven-plugin:1.5.0:exec (run-karma) @ sample-project ---
[INFO] skipping execute as per configuration
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
Run Code Online (Sandbox Code Playgroud)
执行时:
mvn clean test
Run Code Online (Sandbox Code Playgroud)
输出将是
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- exec-maven-plugin:1.5.0:exec (run-karma) @ sample-project ---
hello
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1608 次 |
| 最近记录: |