我在使用空手道框架生成报告时遇到了问题。我已经提到了链接https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/demo/DemoTestParallel.javahttps://github.com/intuit/karate#parallel-executionhttps://github.com/intuit/karate/tree/master/karate-demo#example-report确实与给出的结果相同,但是在生成报告时仍然遇到问题。请找到以下项目详细信息。POM.xml
<dependencies>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>0.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit4</artifactId>
<version>0.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>5.1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
测试赛跑者
public class TestRunner {
@Test
public void testParallel() {
Results results = Runner.path("classpath:testapis").tags("@test").parallel(5);
generateReport(results.getReportDir());
assertTrue(results.getErrorMessages(), results.getFailCount() == 0);
}
public static void generateReport(String karateOutputPath) {
Collection<File> jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] {"json"}, true);
List<String> jsonPaths = new ArrayList(jsonFiles.size());
jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath()));
Configuration config = new Configuration(new File("target"), "demo");
ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config);
reportBuilder.generateReports();
}
}
功能文件
@test
Feature: Title of your feature
I want to use this template for my feature file
Scenario: Title of your scenario
* url "https://jsonplaceholder.typicode.com"
Given path "todos/1"
When method GET
Then status 200
我只是以mvn clean test
身份执行
并在控制台中获得以下错误消息
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running testapis.TestRunner
23:24:41.844 [main] INFO com.intuit.karate.Runner - waiting for parallel features to complete ...
Karate version: 0.9.5
======================================================
elapsed: 0.06 | threads: 5 | thread time: 0.00
features: 0 | ignored: 0 | efficiency: 0.00
scenarios: 0 | passed: 0 | failed: 0
======================================================
Feb 23, 2020 11:24:42 PM net.masterthought.cucumber.ReportBuilder generateErrorPage
INFO: Unexpected error
net.masterthought.cucumber.ValidationException: None report file was added!
at net.masterthought.cucumber.ReportParser.parseJsonFiles(ReportParser.java:58)
at net.masterthought.cucumber.ReportBuilder.generateReports(ReportBuilder.java:88)
at testapis.TestRunner.generateReport(TestRunner.java:34)
at testapis.TestRunner.testParallel(TestRunner.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
执行了0个功能,但按照我给出的说明进行操作。
有人可以帮我解决这个问题。
如果执行了0个测试,这是正常的,则第三方黄瓜报告库将抛出此错误。
似乎您的pom.xml
没有正确设置资源:https://github.com/intuit/karate#folder-structure
如果您仍然被卡住,请执行以下过程:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue