[英]Serenity bdd generage reports on runtime
在测试仍在执行时是否可以生成报告。 通过平移
我的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.insurance.abc</groupId>
<artifactId>insurance</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-jbehave</artifactId>
<version>1.13.0</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>1.1.37-rc.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<!--<executions>
<execution>
<id>add-integration-test-source-as-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/it/java</source>
</sources>
</configuration>
</execution>
</executions>-->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>1.1.37-rc.6</version>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>1.1.37-rc.6</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
如果我将<phase>post-integration-test</phase>
为<phase>pre-integration-test</phase>
那么我的报告就是在测试之前生成的,就是这样。 报告中没有测试。 您能帮我弄清楚为什么吗?
您看到的行为的原因非常简单:在运行测试时,Jbehave将每个测试的结果保存为target/jbehave/
中的storyclass.html
和storyclass.stats
。 运行报告生成时,它将使用那些文件在target/jbehave/reports
下生成target/jbehave/reports
。 通过尝试在运行测试之前生成报告,您正在生成没有输入的报告。
关于如何实现您期望的结果,我认为Jbehave没有提供任何官方方法。
我不建议您这样做,但如果必须这样做,我将首先尝试添加一个@AfterStory步骤,该步骤运行报告生成,以在故事结束时更新报告。 问题是,即使工作正常,每次重新生成整个报告时,测试套件中运行的每个故事都会变得越来越慢,因此,如果您拥有大型套件,您最终会添加一些内容到您的执行时间。 然后,您可以更进一步,并让您执行一些自定义的轻量级报告生成,以为您提供一个临时状态报告,该报告会附加,而不是重新创建可以由Jbehave执行后生成的完整报告替换的报告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.