簡體   English   中英

如何使報告在機器人框架中動態分類?

[英]How to make reports dynamically categorised in robot framework?

我想在每次執行完成時將報告保存在不同的目錄中,但它應該在自動化執行本身中動態完成

在命令行執行中指定報告目錄路徑不是我要找的那個,但它需要手動輸入才能將報告放在特定目錄中。

一旦測試開始運行,您就無法更改輸出的位置。 您唯一的解決方案是使用命令行選項。

我們可以用來動態生成報告的另一種方法是根據當前時間戳創建輸出目錄並在那里生成機器人結果。

例如,在下面的 Maven robotframework 插件中, “outputDirectory”標簽具有存儲 Robot 結果的位置。 該位置帶有時間戳,因此機器人的每次運行都會在不同的目錄中生成報告。

<plugin>
    <groupId>org.robotframework</groupId>
    <artifactId>robotframework-maven-plugin</artifactId>
    <version>1.4.7</version>
    <executions>
        <execution>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <testCasesDirectory>
            ....
        </testCasesDirectory>
        <variableFiles>
            <variableFiles>....</variableFiles>
        </variableFiles>
        <outputDirectory>/myloca/reports/${maven.build.timestamp}/</outputDirectory>
        <libdoc/>
        <testdoc/>
    </configuration>
</plugin>

您可以使用腳本從標准輸入功能中讀取參數文件,為 Robot Framework 生成命令行參數。

要根據某些邏輯為報告創建一個文件夾,例如將文件夾命名為當前時間並將其設置為輸出目錄,可以這樣做:

import datetime
import os

time = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")

dirpath = str(time)

if not os.path.exists(dirpath):
    os.makedirs(dirpath)

print('--outputdir ' + dirpath)

您必須像這樣執行測試:

python OutputDirArgumentFile.py | robot --argumentfile STDIN my_test.robot

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM