[英]Serenity bdd generage reports on runtime
Is it possible to generate reports while test still executing. 在测试仍在执行时是否可以生成报告。 Passed Panding
通过平移
My pom.xml looks like this 我的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>
If I set <phase>post-integration-test</phase>
to <phase>pre-integration-test</phase>
then my report generated before test and this is it. 如果我将
<phase>post-integration-test</phase>
为<phase>pre-integration-test</phase>
那么我的报告就是在测试之前生成的,就是这样。 No test in reports. 报告中没有测试。 Can you please help me to figureout why?
您能帮我弄清楚为什么吗?
The reason for the behaviour you are seeing is fairly simple: As tests are being run Jbehave saves results of each test in target/jbehave/
as storyclass.html
and storyclass.stats
. 您看到的行为的原因非常简单:在运行测试时,Jbehave将每个测试的结果保存为
target/jbehave/
中的storyclass.html
和storyclass.stats
。 When the report generation runs, it consumes those files to generate your report under target/jbehave/reports
. 运行报告生成时,它将使用那些文件在
target/jbehave/reports
下生成target/jbehave/reports
。 By attempting to generate your reports before running the tests, you are generating reports with no input. 通过尝试在运行测试之前生成报告,您正在生成没有输入的报告。
With regards to how to achieve your desired outcome, I don't think there is any official way provided by Jbehave. 关于如何实现您期望的结果,我认为Jbehave没有提供任何官方方法。
I wouldn't recommend doing this but if I had to do it I would start by trying to add an @AfterStory step that runs report generation to update the reports each time a story finishes. 我不建议您这样做,但如果必须这样做,我将首先尝试添加一个@AfterStory步骤,该步骤运行报告生成,以在故事结束时更新报告。 Problem with this is that even if it works, each time this happens the whole report is re-generated which will get slower and slower with each story run in your test suite, so if you have a big suite you will end up adding a bit to your execution time.
问题是,即使工作正常,每次重新生成整个报告时,测试套件中运行的每个故事都会变得越来越慢,因此,如果您拥有大型套件,您最终会添加一些内容到您的执行时间。 You could then take it a step further and have your step do some custom light-weight report generation to give you a temporary status report that appends rather then re-creates the reports which can be replaced by the full report generated by Jbehave post execution.
然后,您可以更进一步,并让您执行一些自定义的轻量级报告生成,以为您提供一个临时状态报告,该报告会附加,而不是重新创建可以由Jbehave执行后生成的完整报告替换的报告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.