我试图将一个maven插件cucumber-jvm-parallel-plugin合并到我的Cucumber-JVM代码中,但遇到了一些问题...我认为我已经正确地配置了pom.xml
,但是我的cucumber特性仍然是一个接一个地运行,而不是并行地运行。
我遵循了两个教程,但找不到哪里出错了,或者如果这是意料之中的:
下面是我的程序结构:
├── features/
│ └── api/
│ ├── 006-Email.feature
│ └── 999-Login.feature
├── results/
│ └── api-json.json
└── src/
└── java/
├── pom.xml
├── src/
│ └── test/
│ └── java/
│ └── com/
│ └── mycompany/
│ └── commonapps/
│ └── queuemanager/
│ ├── Globals.java
│ ├── GmailHelper.java
│ ├── HttpDeleteWithBody.java
│ ├── JsonHelper.java
│ ├── RequestHelper.java
│ ├── RunApiTest.java
│ ├── ThreadedSteps.java
│ └── UserHelper.java
└── steps/
└── com/
└── mycompany/
└── commonapps/
└── queuemanager/
├── GivenSteps.java
├── Setup.java
├── ThenSteps.java
└── WhenSteps.java
<build>
<resources>
<resource>
<directory>../../features/api/</directory>
</resource>
</resources>
</build>
<plugin>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
...
<configuration>
...
<featuresDirectory>${project.build.directory}/classes/active/</featuresDirectory>
...
</configuration>
</plugin>
然后,在我运行Maven Test
之后,所有.feature
文件都编译到target/test-classes/parallel**it.class
中。每个功能文件一个。
因此,我告诉maven-surefire-plugin并行运行所有
文件,这些文件是cucumber-jvm-parallel-plugin创建的特性文件。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>acceptance-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<forkCount>5</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/Parallel*IT.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
我的pom.xml是:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.commonapps</groupId>
<artifactId>e2e-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
...
</dependencies>
<build>
<!-- COPY RESOURCES TO TARGET/ -->
<resources>
<!-- copies features to target: "${project.build.directory}/classes/active/" -->
<resource>
<directory>../../features/api/</directory>
</resource>
</resources>
<!-- RUN EACH CUCUMBER FEATURE FILE AS A FORK -->
<plugins>
<plugin>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>generate-test-sources</phase>
<goals>
<goal>generateRunners</goal>
</goals>
<configuration>
<glue>com.mycompany.commonapps.queuemanager</glue>
<outputDirectory>${project.build.directory}/generated-test-sources</outputDirectory>
<featuresDirectory>${project.build.directory}/classes/active/</featuresDirectory>
<cucumberOutputDir>${project.build.directory}</cucumberOutputDir>
<format>json</format>
<!--<strict>true</strict>
<monochrome>true</monochrome>
<useTestNG>false</useTestNG>
<namingScheme>simple</namingScheme>-->
<parallelScheme>FEATURE</parallelScheme>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!-- RUN ALL CLASSES CREATED BY cucumber-jvm-parallel-plugin IN PARALLEL -->
<executions>
<execution>
<id>acceptance-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<forkCount>5</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/Parallel*IT.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<!-- ADD ../../STEPS/ TO THE SOURCE -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>steps/</source>
<source>src/test/java/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@RunWith(Cucumber.class)
@CucumberOptions(plugin={"pretty","json:../../results/api-json.json"}, glue={"com.mycompany.commonapps.queuemanager"}, features={"../../features/api/active"})
public class RunApiTest {
}
...
[INFO] ------------------------------------------------------------------------
[INFO] Building e2e Server Tests 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocated to commons-io:commons-io:jar:1.3.2
[INFO]
[INFO] --- build-helper-maven-plugin:1.7:add-source (add-source) @ e2e--server ---
[INFO] Source directory: /media/ifc-dev-1/ESD-ISO/e2e-/src/java/steps added.
[INFO] Source directory: /media/ifc-dev-1/ESD-ISO/e2e-/src/java/src/test/java added.
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ e2e--server ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 7 resources
[INFO] Copying 2 resources
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ e2e--server ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 12 source files to /media/ifc-dev-1/ESD-ISO/e2e-/src/java/target/classes
[INFO] /media/ifc-dev-1/ESD-ISO/e2e-/src/java/src/test/java/com/mycompany/commonapps/queuemanager/GmailHelper.java: /media/ifc-dev-1/ESD-ISO/e2e-/src/java/src/test/java/com/mycompany/commonapps/queuemanager/GmailHelper.java uses unchecked or unsafe operations.
[INFO] /media/ifc-dev-1/ESD-ISO/e2e-/src/java/src/test/java/com/mycompany/commonapps/queuemanager/GmailHelper.java: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- cucumber-jvm-parallel-plugin:1.2.1:generateRunners (generateRunners) @ e2e--server ---
[INFO] Adding /media/ifc-dev-1/ESD-ISO/e2e-/src/java/target/generated-test-sources to test-compile source root
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ e2e--server ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /media/ifc-dev-1/ESD-ISO/e2e-/src/java/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ e2e--server ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 10 source files to /media/ifc-dev-1/ESD-ISO/e2e-/src/java/target/test-classes
[INFO] /media/ifc-dev-1/ESD-ISO/e2e-/src/java/src/test/java/com/mycompany/commonapps/queuemanager/GmailHelper.java: /media/ifc-dev-1/ESD-ISO/e2e-/src/java/src/test/java/com/mycompany/commonapps/queuemanager/GmailHelper.java uses unchecked or unsafe operations.
[INFO] /media/ifc-dev-1/ESD-ISO/e2e-/src/java/src/test/java/com/mycompany/commonapps/queuemanager/GmailHelper.java: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ e2e--server ---
[INFO] Surefire report directory: /media/ifc-dev-1/ESD-ISO/e2e-/src/java/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.mycompany.commonapps.queuemanager.RunApiTest
....
*Tests run one by one properly*
...
Tests run: 31, Failures: 2, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:40 min
[INFO] Finished at: 2016-11-10T15:49:11-08:00
[INFO] Final Memory: 20M/261M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project e2e--server: There are test failures.
[ERROR]
[ERROR] Please refer to /media/ifc-dev-1/ESD-ISO/e2e-/src/java/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
有人看到我做错了什么吗?
outputdirectory
正确创建,并包含一组并行**it.class文件featuredirectory
被正确访问。cucumberoutputdir
在构建后根本不会被创建。我终于让它起作用了!为了使测试并行运行,我必须做以下工作:
>
我将maven-surefire-plugin
执行标记中的一些字段移动到
configuration
标记中。我移动了这个部分:
<forkCount>5</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/*IT.class</include>
</includes>
maven-surefire-plugin
现在看起来像这样: <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<forkCount>5</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/*IT.class</include>
</includes>
</configuration>
</plugin>
因为cucumber-jvm-parallel-plugin
现在正在运行这个节目,所以我不得不删除我的cucumber runner类。我是这样评论出来的:
java prettyprint-override"> /*
@RunWith(Cucumber.class)
@CucumberOptions(plugin={"pretty","json:../../results/api-json.json"}, glue={"com.mycompany.commonapps.queuemanager"}, features={"../../features/api/active"})
*/
public class RunApiTest {
}
就这样了。由于parallel**it.class
是在哪里创建的,所以是maven-surefire-plugin
工作不正常。
如何使用Maven在以下位置运行cucumber测试。 源文件夹'src/main/java'和'src/main/resources'包括在每个源文件夹中创建的包'com.testing.testproject.login'中的步骤定义和功能文件。 这是我的POM文件: 提前道谢。
我正在努力获得Cucumber-JVM V4.0.0与JUnit/Maven一起工作的新并行执行特性。 如前所述,如果在POM中相应地配置和,并使用依赖项注入来共享状态(我使用的是Pico Continer),那么Cucumber特性应该并行执行。 如果有用的话,下面是我的runner类(com.softwareAutomation.world是DI类) 请参阅下面从Maven运行时的失败堆栈跟踪
我正试图在Maven中基于cucumber标记运行一套JUnitCucumber特性。我可以让它们按顺序运行,但不能并行运行。我找到了一个名为小胡瓜的软件包,它可以帮我解决这个问题。 然而,我无法让测试运行,我看了github上的示例maven项目,它在Cucumber.class运行良好,但在西葫芦上抛出一个错误。 任何帮助将不胜感激。 我已在pom中包括以下内容 我是在召唤我的跑步者。 我得到
Cucumber测试没有并行运行(Cucumber jvm并行插件)? 如果我使用runner类执行测试,一次将执行一个功能文件,但是当将以下插件添加到POM文件时,似乎没有功能文件执行? 即使我指向了正确的功能文件文件夹? 我的POM文件:
我正在使用 jvm cucumber并行插件,并希望重新运行我失败的测试用例。需要在 文件中进行哪些更改。
我所拥有的 我正在使用Selenium WebDriver运行Cucumber JVM来自动化我们的系统测试用例。这些测试用例目前使用XRay测试管理插件存储在JIRA中。XRay还提供了获取特性文件以及将结果上传到JIRA的API。 我已经创建了一个自定义的JIRA实用程序类来下载测试作为特性文件,并将测试结果从JIRA中上载到JIRA中,同时还演示了它的工作原理。它们分别在Cucumber R