我是cucumber可扩展代码的新手,我需要帮助。我正在使用java 8和maven,并希望生成cucumber可扩展报告。但每次我得到以下错误:
cucumber.runtime.CucumberException: Couldn't load plugin class: com.cucumber.listener.ExtentCucumberFormatter. It does not implement cucumber.api.Plugin
Pom.xml文件是:
<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>CucumberFramwork</groupId>
<artifactId>ExtendReport</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ExtendReport</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports-cucumber4-adapter</artifactId>
<version>1.0.7</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.5</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Runner类代码:
package runners;
import java.io.File;
import org.junit.AfterClass;
import org.junit.runner.RunWith;
import com.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/functionalTests",
glue = { "stepDefinitions" },
plugin = {
"com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html" },
monochrome = true)
public class TestRunner {
@AfterClass
public static void writeExtentReport() {
try {
Reporter.loadXMLConfig(new File("C:\\Software\\WprkSpace\\ExtendReport\\Configs\\extent-config.xml"));
}
catch (Exception e) {
e.printStackTrace();
}
//Reporter.loadXMLConfig("/ExtendReport/Configs/extent-config.xml");
}
}
我得到这个错误:
cucumber.runtime.CucumberException: Couldn't load plugin class: com.cucumber.listener.ExtentCucumberFormatter. It does not implement cucumber.api.Plugin
at cucumber.runtime.formatter.PluginFactory.loadClass(PluginFactory.java:178)
at cucumber.runtime.formatter.PluginFactory.pluginClass(PluginFactory.java:165)
at cucumber.runtime.formatter.PluginFactory.getPluginClass(PluginFactory.java:222)
at cucumber.runtime.formatter.PluginFactory.isStepDefinitionReporterName(PluginFactory.java:205)
at cucumber.runtime.RuntimeOptions$ParsedPluginData.addPluginName(RuntimeOptions.java:357)
at cucumber.runtime.RuntimeOptions.parse(RuntimeOptions.java:159)
at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:90)
at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:85)
at cucumber.runtime.RuntimeOptionsFactory.create(RuntimeOptionsFactory.java:23)
at cucumber.api.junit.Cucumber.<init>(Cucumber.java:56)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
尝试将此 2 依赖项与以下相同版本一起使用:
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.2</version>
</dependency>
更多信息在这里:
用于cucumber的范围报告插件
POM分析说-
首先,让我们对创建数据块报告的这些库有一个基本的了解
1. Vimal Selvam库:下面是所需的maven依赖项和示例测试,以演示如何进行配置设置。
Maven Dependency
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.1.1</version>
</dependency>
请注意,Java 8和添加ExtentReport v3.1.1的依赖项是强制性的。为此,请将以下内容粘贴到pom.xml中:
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.1</version>
</dependency>
cucumber流道文件
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"src/test/resources/features"},
glue = {"com.cucumber.stepdefinitions"},
plugin = {"com.cucumber.listener.ExtentCucumberFormatter:output/report.html"}
)
public class RunCukesTest {
@AfterClass
public static void teardown() {
Reporter.loadXMLConfig(new File("src/test/resources/extent-config.xml"));
Reporter.setSystemInfo("user", System.getProperty("user.name"));
Reporter.setSystemInfo("os", "Mac OSX");
Reporter.setTestRunnerOutput("Sample test runner output message");
}
}
上述设置将在输出目录中生成报告,名称为report.html.
2.范围适配器:美容是,您不需要编写任何代码来以这种方式生成报告,除了在下面的运行器中设置适配器。
Maven Dependency
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports-cucumber4-adapter</artifactId>
<version>1.0.6</version>
</dependency>
将com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter插件添加到运行程序。
@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"})
public class RunCukesTest {
// ..
}
报告输出目录-../Project Directory/test Output/HtmlReport
要点:我们不能直接混合
首先,您可以添加下面的cucumber最小依赖集。
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>4.2.6</version>
<scope>test</scope>
</dependency>
第二,考虑到不使用扩展适配器的情况,在POM.XML**下添加扩展依赖项。
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.5</version>
</dependency>
在此工作流中,不要将com . avent stack . extent reports . cucumber . adapter . extentcuumberadapter插件添加到流道中。
作为最后一个 Hooks 类,我们编写针对每个场景执行的范围代码。
公共类钩子 {
private final static Logger log = Logger.getLogger(Hooks.class);
static volatile int x = 0;
@Before
public void setUpScenario(Scenario scenario){
ExtentTestManager.startTest("Scenario No . " + (x = x + 1) + " : " + scenario.getName());
ExtentTestManager.getTest().log(Status.INFO, "Scenario No . "+ x + " Started : - " + scenario.getName());
}
@After
public void afterScenario(Scenario scenario){
String videoFile= Utility.stopAUTTestRecorder();
try{
if(scenario.isFailed()){
ExtentTestManager.addScreenShotsOnFailure();
//------------------------- Attaching video in the Report -------------------------
String failedTestVideo = "<a href=\"" + videoFile + "\">Download Failed Test Case Video</a>";
ExtentTestManager.embedVideoLink(failedTestVideo);
//scenario.write(failedTestVideo);
}
}
ExtentManager.getReporter().flush();
}
}
我想问一下URLClassLoader。我写了一篇主要的文章。运行良好的jar文件。现在我想让它能够从它的一个文件夹加载插件。我写了它,直到它找到了答案。jar文件在文件夹中,可以在其中列出它们的类(它们的名称、路径)。问题是,当我要求他查找该类(用于创建它的实例)时,他们找不到它从我的主jar文件继承的类,如下所示: 因此,当我要求UrlClassLoader解析“ExpansionA”类时,它
这是我面临的问题,有人能帮我吗?? 线程“main”java中出现异常。lang.UnsatifiedLinkError:无法加载库“libtesseract3051”:本机库(win32-x86-64/[[libtesseract3051.dll] 请给点解决办法谢谢
我试图升级cucumber以使用并行执行功能,结果导致报表门户出现问题。 在相容性矩阵中,它说: cucumberjava和cucumberjUnit的版本- 4.0.0 - 4.2.6cucumber代理4.0.0的测试版本 我尝试了不同版本的Cucumber4.0。0, 4.2.3, 4.2.2, 4.2.6号cucumber制剂4.0。上面说 cucumber.runtime.Cucumbe
当我试图构建我的项目时,我有以下错误:
每当我运行cucumber功能时,我都会收到以下错误。但是,脚本工作正常,但每次执行功能文件时都会出现此警告消息。这是怎么回事?
版本:3.8.2.201610040743平台:Eclipse Neon.1(4.6.1)这是我的版本插件org.springsource.ide.eclipse.commons.gettingstarted无法加载类org.springsource.ide.eclipse.commons.gettingstarted.dashboard.欢迎仪表板