简体   繁体   中英

How to make reports dynamically categorised in robot framework?

I want to keep reports in different directory every time the execution is done, but it should be done dynamically in automation execution itself

specifying the reports directory path in command line execution is not the one I am looking for, that is there but it needs manual input to place the reports in particular directory.

Once the test starts running you cannot change the location of the outputs. Your only solution is to use a command line option.

The other alternative which we can use to dynamically generate reports, is to create output directory based on current timestamp and generate Robot results there.

For example, in the below Maven robotframework plugin, the "outputDirectory" tag has location where Robot results will be stored. This location is timestamped due to which every run of robot will generate report in different directory.

<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>

You can use a script to generate command line arguments for Robot Framework using the Reading argument files from standard input functionality.

To create a folder for the reports based on some logic, for example to name the folder as the current time and set that as the output directory , something like this can be done:

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)

You have to execute your tests like:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM