[英]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.