Generate log for each iteration in test

I’m doing an Android app test with Appium. The test is configured for 200 iterations and is expected to take about 2 days:

*** Test Cases ***
Very Long Test
    FOR  ${i}  IN RANGE  200
        TRY
            Doing testing...
        EXCEPT
            Increment a variable signifying the number of fails...
        ELSE
            Increment a variable signifying the number of successes
        FINALLY
            Cleanup of appdata etc..
        END
    END

I’ve used the try/except/else/finally structure to avoid having the whole test abort due to some error. We’re interested in the stability of the components that are being tested. But being such a long test, where stopping to look what might’ve caused the crash and then restarting it, is not possible.

Wondering if there’s a way of getting around this? I’d quite like to get a log after each iteration, or even better, of the iteration that registered a failure. That way, I could, like a 100 iterations in, have a look and ensure I haven’t messed something up unrelated to the actually components we’re testing.

I suggest you do the logging to a file using Append to File. You can even prepare it to be HTML with a nice table.

2 Likes

Hi Ben,

Actually there is only 1 test here, Very Long Test, everything under that is a keyword.

If you wanted 200 tests in the same file I would suggest using Test templates and that may still be useful to you?

But as you want a separate result file for each iteration, I’ll suggest you take the top level loop out of robot framework and use a shell script (batch file on windows)

By making the loop for 200 iterations external from robot framework, lets you pass the iteration number as part of the result folder/filename, you can use one or more of-d --outputdir dir, -o --output file, -l --log file & -r --report file to control the output (see robot -h for details)

Let me know if you need help creating a shell script (I’ll need to know which OS you are using)

Dave.

1 Like