touca::framework::mainthat is meant to be called from the main function of our test application to take over running our application for any given workflow.
mainfunction of the test framework that calls its different member functions in a specific order. Most member functions have a trivial default implementation that you can override and customize.
Workflow::executeis meant to describe how a particular test case should be executed. This is the function that we override to pass our test cases to the code under test.
Workflow::suiteis meant to describe how a list of our test cases should be obtained when we run the test tool. Since many test tools may use the same approach to obtain this list, we describe this logic in a separate instance of the
is_primeexample, we used a list of eight numbers as our set of inputs to the code under test. The following code snippet shows one way to represent this list by deriving from the Suite class:
--config-fileas shown below:
config.jsonmay have the following content:
suite.txtsimply lists our Test Cases:
suite.txt. Let us try to make this filename configurable.
Workflowclass through the
_optionsmember variable. This allows us to change the implementation of member function
suite()to the following:
suite-filea required configuration option. We can ensure that this option is always provided by implementing the member function
Workflow::parse_optionsand append the value parsed from the command line arguments to the member variable
Workflow::add_option. If we do so, it also makes sense to implement
Workflow::describe_optionsto provide a simple string that is shown to the user if they run the Test Tool with the option