Today, you can create a small library that will act as a listener as well that can do a runtime check which tests have been selected. I am using Robot Framework 3.1.2 here.
It basically needs two things
- A
start_suite method from the listener API. This method will be invoked at the start of every suite or until it returns an explicit False. When invoked a parameter called attributes will be passed to it. This parameter is a dictionary, that has the following key/value pair, "tests: Names of the tests this suite has as a list. Does not include tests of the possible child suites.".
- A keyword that will log all test names and could be used from
Suite Setup.
lib.py
from robot.api import logger
class lib(object):
ROBOT_LIBRARY_SCOPE = 'TEST SUITE' # define library scope
ROBOT_LISTENER_API_VERSION = 2 # select listener API
ROBOT_LIBRARY_VERSION = 0.1
def __init__(self):
self.ROBOT_LIBRARY_LISTENER = self # tell the framework that it will be a listener library
self.attributes = None
def _start_suite(self, name, attributes):
self.attributes = attributes
def log_suite_test_names(self):
for test in self.attributes['tests']:
logger.info(test)
globals()[__name__] = lib
test.robot
*** Settings ***
Library lib
Suite Setup log suite test names
*** Test Cases ***
Test 1
[Tags] A
No Operation
Test 11
[Tags] A B
No Operation
Test 111
[Tags] A B C
No Operation
Test 1111
[Tags] A B C D
No Operation
Results when launched like: robot --pythonpath . --include C test.robot
