0
votes

I am using Robot Framework to automate onboard unit testing of a Linux based device.

The device has a directory /data/tests that contains a series of subdirectories, each subdirectory is a test module with 'run.sh' to be executed to run the unit test. For example :

/data/tests/module1/run.sh

/data/tests/module2/run.sh

I wrote a function that collects the subdirectory names in an array, and this is the list of test modules to be executed. The number of modules can vary daily.

@{modules}=     SSHLibrary.List Directories in Directory       /data/tests

Then another function (Module Test) that basically runs a FOR loop on the element list and executes the run.sh in each subdirectory, collects log data, and logs it to the log.html file.

The issue I am experiencing is that when the log.html file is created, there is one test case titled Module Test, and under the FOR loop, a 'var' entry for each element (test module). Under each 'var' entry are the results of the module execution.

Is it possible from within the FOR loop, to create a test case for each element and log results against it? Right now, if one of the modules / elements fails, I do not get accurate results, I still get a pass for the Module Test test case. I would like to log test cases Module 1, Module 2, ... , Module N, with logs and pass fail for each one. Given that the number of modules can vary from execution to execution, I cannot create static test cases, I need to be able to dynamically create the test cases once the number of modules has been determined for the test run.

Any input is greatly appreciated.

Thanks,

Dan.

2
you want to dynamically create code (modules) during runtime, pre or post compilation? Include some sample code of function Module Test please. Why can't you use data driven tests for the framework?lloyd

2 Answers

1
votes

You can write a simple script that dynamically create the robot test file by reading the /data/test/module*, then create one test case for each of the modules. In each test case, simply run the operating system command and check the return code (the run.sh). This way, you get one single test suite, with many test cases, each representing a module.

0
votes

Consider writing a bash script that would run robot test for each module, and then merge reports to one report with rebot script. Use a --name parameter in pybot script to differentiate tests in report.