使用exec-maven-plugin时如何防止测试运行 [英] How can I prevent tests from being run when using 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>
我以为如果我通过了 问题:如何使执行取决于 您可以使用exec-maven-plugin的rel ="noreferrer"> 请注意 运行: 输出将包含: 执行时: 输出应为 I am running JavaScript unit tests in a maven project using exec-maven-plugin I was under the assumption that if I passed Question: How can I make that execution depend on the You can use the Note the usage of Running: The output would contain: While executing: The output would be
这篇关于使用exec-maven-plugin时如何防止测试运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!-DskipTests
,将跳过整个测试阶段,但事实并非如此,时被接受
skipTests
标志?skip
选项如下:<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>
${skipTests}
的用法作为其值的一部分.还要注意,我使用了推荐的新版本1.5.0
.mvn clean test -DskipTests
[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
mvn clean test
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
<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>
-DskipTests
, the entire test phase would be skipped but that's not the case, the skipTests
flag is only honored when using "Surefire, Failsafe and the Compiler Plugin"skipTests
flag?skip
option of the exec-maven-plugin
as following:<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>
${skipTests}
as part of its value. Also note I used a newer version, 1.5.0
, recommended.mvn clean test -DskipTests
[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
mvn clean test
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