我是黄瓜并行执行的新手。我需要用黄瓜插件“cucumber-jvm-parallel-plugin”并行执行黄瓜TestCases。 当我运行pom.xml文件时它会抛出一个错误。请让我知道我的错误。
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.127 s <<< FAILURE! - in TestRunner.Parallel01IT
[ERROR] initializationError(TestRunner.Parallel01IT) Time elapsed: 0.009 s <<< ERROR!
cucumber.runtime.CucumberException: Couldn't load plugin class: com.project.CustomHtmlFormatter
Caused by: java.lang.ClassNotFoundException: com.project.CustomHtmlFormatter
以下是项目结构。
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.project</groupId>
<artifactId>Steps</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
.....
</dependencies>
<build>
<!-- COPY RESOURCES TO TARGET/ -->
<resource>
<directory>../../Cucumber5/src/test/resources/features</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>4.1.0</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>generate-test-sources</phase>
<goals>
<goal>generateRunners</goal>
</goals>
<configuration>
<glue>
<package>com.project.Steps</package>
</glue>
<outputDirectory>../../Cucumber5/src/target/generatedTestSources/</outputDirectory>
<featuresDirectory>../../Cucumber5/src/target/classes/</featuresDirectory>
<cucumberOutputDir>../../Cucumber5/src/target</cucumberOutputDir>
<plugins>
<plugin>
<name>json</name>
</plugin>
<plugin>
<name>com.project.CustomHtmlFormatter</name>
<extension>html</extension>
</plugin>
</plugins>
<!-- CucumberOptions.strict property -->
<strict>true</strict>
<monochrome>true</monochrome>
<useTestNG>false</useTestNG>
<namingScheme>pattern</namingScheme>
<namingPattern>Parallel{c}IT</namingPattern>
<parallelScheme>FEATURE</parallelScheme>
<!-- Specify a custom package name for generated sources. Default
is no package. -->
<packageName>TestRunner</packageName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<!-- 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>
</plugins>
</build>
</project>
在Parallel01IT.java文件下运行pom.xml文件后 产生。
package TestRunner;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
strict = true,
features = {"E:/workspaceTAAP/Cucumber5/src/target/classes/tester.feature"},
plugin = {"json:E:/workspaceTAAP/Cucumber5/src/target/1.json", "com.project.CustomHtmlFormatter:E:/workspaceTAAP/Cucumber5/src/target/1.html"},
monochrome = true,
tags = {},
glue = {"com.project.Steps"})
public class Parallel01IT {
}
答案 0 :(得分:0)
错误,因为类CustomHtmlFormatter
未包含在com.project
包中。并且程序包com.project
不存在于您的项目中。首先创建适当的包和类。