在使用execmaven插件时,如何防止运行测试
我正在使用execmaven插件在一个maven项目中运行JavaScript单元测试在使用execmaven插件时,如何防止运行测试,maven,maven-3,pom.xml,exec-maven-plugin,Maven,Maven 3,Pom.xml,Exec Maven Plugin,我正在使用execmaven插件在一个maven项目中运行JavaScript单元测试 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.3</version> <executions> <execu
<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>
org.codehaus.mojo
问题:如何使执行取决于skipTests
标志?您可以使用exec maven插件的选项
,如下所示:
<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>
输出将包括:
[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
我猜您可以将运行karma测试包装到脚本中,并在那里检查skipTests属性是否已设置,然后决定运行node/karma命令。另一个解决方案可能是将此配置移动到配置文件中并使用激活:或者仅在需要时激活它。感谢指向exec maven插件的链接,对我没有首先访问该插件感到惭愧:)顺便说一句,它在1.3版上运行良好。
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