我希望更改Serenity報告中的CSS和徽標。另外我想在Serenity報告中添加一些自定義文本或鏈接到某些測試。與生成Excel報告一樣,我希望在報告的測試步驟中提供它的鏈接。達到此目的的最佳方法是什麼?如何自定義寧靜報告BDD
回答
定製CSS和圖像的一種方法是使用Maven Resources Plugin,如下所示。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-web.xml</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${basedir}/target/site/serenity/images</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/images</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
佩斯你在 「的src /主/資源/圖像」 的圖像。即您的名稱爲「serenity-logo.png」的徽標,因爲HTML代碼具有此名稱。您可以添加CSS文件以及要替換的CSS文件的相對路徑。
運行測試後,只需運行命令「mvn process-resources」。這將取代文件,然後你有一個網站與您的圖像和CSS文件定製。
這不是最好的解決方案,但可以快速修復您的報告。
我發現了一個更好,更清潔的方式來定製寧靜報告。基本上,我們可以使用不同的版本號生成我們自己的Serenity-reports-resources項目,並配置我們的項目以使用我們自定義的報告資源構建版本,而不是正式報告資源。該setps要做到這一點如下:從
下載來源:
https://github.com/serenity-bdd/serenity-core.git
修改建搖籃設置來生成自己的「寧靜 - 報告 - 資源」的jar文件。打開「build.gradle」文件。 2.1添加 「mavenLocal()」 到存儲庫:
buildscript { repositories { mavenLocal() .....
2.2添加的Maven插件發佈
apply plugin: 'maven-publish'
2.3更改子項目的版本號。將行:
version = rootProject.version
爲
version = '0.0.0.1'
注:使用您爲了追蹤您的報告點的變化所需的版本號。對於子項目「寧靜報告資源」
3.1運行
publishing/publishToMavenLocal
運行
安裝報表網站在當地的倉庫一個新的Maven的依賴。在其他環境中運行測試時,在您需要的地方發佈或部署此版本。mvn clean build
配置您的項目不包括官方的「serenity-report-resources」依賴項,而是添加你的項目。
4.1在依賴項部分添加沒有報告的serenity-core。
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
<exclusions>
<exclusion>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-report-resources</artifactId>
</exclusion>
</exclusions>
</dependency>
4。2添加您的自定義報告依賴項。使用您以前使用過的相同版本號。
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-report-resources</artifactId>
<version>0.0.0.1</version>
</dependency>
4.3配置serenity插件依賴項以使用您的自定義報告構建。
<!-- Serenity plugin -->
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.maven.version}</version>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
<exclusions>
<exclusion>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-report-resources</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-report-resources</artifactId>
<version>0.0.2</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
現在,當你運行的「SerenityRunner」測試中,它應該找到你的自定義報表的資源構建,而不是正式的寧靜報告建立。
如果我們可以將生成報告所需的資源的位置配置爲來自同一框架的靜態或系統屬性,那將會更好。讓看看我能做些什麼:-)
我希望它能幫助, 保持對黑客
- 1. 寧靜BDD報告命名
- 2. maven selenium寧靜bdd開放index.html測試後自動報告
- 3. 寧靜BDD與JUnit - 報告沒有格式化
- 4. 寧靜BDD超時錯誤
- 5. 寧靜BDD - 使用pagefactory
- 6. 寧靜報告標誌變化
- 7. 提取測試輸出寧靜BDD
- 8. 寧靜BDD趣味功能按組
- 9. 寧靜:如何從報告中隱藏測試數據?
- 10. 我如何生成寧靜報告與jbehave從thucydides遷移
- 11. Sitecore 6 WFFM:如何自定義報告?
- 12. 如何自定義Axapta報告「SysReportAuto」?
- 13. 如何自定義testng報告?
- 14. SQL Server 2008報告服務報告定義自定義擴展
- 15. 自定義TestNG報告
- 16. SpecFlow的自定義報告
- 17. 自定義報告頁面
- 18. Workfront API自定義報告
- 19. CRM自定義報告
- 20. 自定義JUnit報告?
- 21. 獲取自定義報告
- 22. 自定義Oracle AWR報告
- 23. 的報告「」報告定義
- 24. Dynamics AX 2009 - 自定義自動報告
- 25. 從寧靜報告中刪除忽略/跳過的場景
- 26. 寧靜報告沒有顯示錶格,餅圖,徽標等
- 27. 如何構建和實施自助式自定義報告?
- 28. SourceSafe報告 - 如何以可用格式獲取自定義報告?
- 29. 如何獲取RDLC報告以運行報告自定義代碼?
- 30. 報告服務+報告參數和自定義下拉長度
我一直在尋找有一段時間了答案,似乎沒有被任何研究在這方面所做的任何地方。我建議你從_serenity-report-resources-x.x.xx.jar_開始,並熟悉** Serenity **如何構建其報告。此外,請務必查看[this](http://stackoverflow.com/questions/38913415/serenity-reports-logo-change/38917386#38917386)瞭解如何更改徽標。 – JDelorean