I have file test.robot with test cases.
How can i get the list of this test cases without activating the tests, from command line or python?
You can use ${TEST_NAME} if you want the name of test case inside a suite, ${SUITE_NAME} to get the name of the file which contains the test cases ( Generally referred as Test Suite).
If you used Pass Execution to skip your tests, you can pass an optional SKIP tag at the end so that the case will be tagged as SKIP in the log/report. Eg: Pass Execution Skipping this test SKIP. Here SKIP is the tag that will be added to this test case and it will show up in your log/report as a tag.
To execute robot tests in your prompt, type: robot path/to/tests. 'path/to/tests' should be a name of a suite file or a suite directory.
Clicking on New Scalar will open the following screen to create the variable and the value we need to replace with when the variable in used inside test cases. We get ${} for the Name field. The name of the variable is ${url}. The value is − http://localhost/robotframework/login.html.
For v3.2 and up:
In RobotFramework 3.2 the parsing APIs have been rewritten, so the answer from Bryan Oakley won't work on these versions anymore.
The proper code that is compatible with both pre-3.2 and post-3.2 versions is the following:
from robot.running import TestSuiteBuilder
from robot.model import SuiteVisitor
class TestCasesFinder(SuiteVisitor):
def __init__(self):
self.tests = []
def visit_test(self, test):
self.tests.append(test)
builder = TestSuiteBuilder()
testsuite = builder.build('testsuite/')
finder = TestCasesFinder()
testsuite.visit(finder)
print(*finder.tests)
Further reading:
TestSuiteBuilder
class referenceIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With