Skip to content

Commit 84e9f5f

Browse files
authored
Merge pull request #38 from JFoederer/keep-direct-model-options-local
Keep direct model options local
2 parents e01a935 + f72ed5e commit 84e9f5f

8 files changed

Lines changed: 64 additions & 3 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ Treat this test suite model-based seed=eag-etou-cxi-leamv-jsi
199199

200200
Using `seed=new` will force generation of a new reusable seed and is identical to omitting the seed argument. To completely bypass seed generation and use the system's random source, use `seed=None`. This has even more variation but does not produce a reusable seed.
201201

202+
### Option management
203+
204+
If you want to set configuration options for use in multiple test suites without having to repeat them, the keywords __Set model-based options__ and __Update model-based options__ can be used to configure RobotMBT library options. _Set_ takes the provided options and discards any previously set options. _Update_ allows you to modify existing options or add new ones. Reset all options by calling _Set_ without arguments. Direct options provided to __Treat this test suite model-based__ take precedence over library options and affect only the current test suite.
205+
206+
Tip: [Robot dictionaries](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#dictionary-variable) (`&{ }`) can be used to group related options and pass them as one set.
207+
202208
## Disclaimer
203209

204210
Please note that this library is in a premature state and hasn't reached its first official (1.0) release yet. Developments are ongoing within the context of the [TiCToC](https://tictoc.cs.ru.nl/) research project. Interface changes are still frequent, and no deprecation warnings are being issued yet.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*** Settings ***
2+
Suite Setup Run keywords Set suite variable ${test_count} ${0}
3+
... AND Treat this test suite Model-based bonus_scenario=${True}
4+
Suite Teardown Should be equal ${test_count} ${3}
5+
Library robotmbt processor_lib=suiterepeater
6+
7+
*** Test Cases ***
8+
only test case
9+
Set suite variable ${test_count} ${test_count+1}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*** Settings ***
2+
Suite Setup Run keywords Set suite variable ${test_count} ${0}
3+
... AND Treat this test suite Model-based
4+
Suite Teardown Should be equal ${test_count} ${2}
5+
Library robotmbt processor_lib=suiterepeater
6+
7+
*** Test Cases ***
8+
only test case
9+
Set suite variable ${test_count} ${test_count+1}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*** Settings ***
2+
Documentation In this suite one of the processor options is set on the higher level suite,
3+
... which is then reused in both sub suites. The first sub suite adds their own value
4+
... for a second configuration option, the second suite does not use that option at
5+
... all. The second suite should be unaffected by the option set in the preceeding
6+
... suite.
7+
Suite Setup Set model-based options repeat=2
8+
Library robotmbt processor_lib=suiterepeater
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*** Settings ***
2+
Suite Setup Run keywords Set suite variable ${test_count} ${0}
3+
... AND Treat this test suite Model-based repeat=3
4+
Suite Teardown Should be equal ${test_count} ${3}
5+
Library robotmbt processor_lib=suiterepeater
6+
7+
*** Test Cases ***
8+
only test case
9+
Set suite variable ${test_count} ${test_count+1}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*** Settings ***
2+
Suite Setup Run keywords Set suite variable ${test_count} ${0}
3+
... AND Treat this test suite Model-based
4+
Suite Teardown Should be equal ${test_count} ${2}
5+
Library robotmbt processor_lib=suiterepeater
6+
7+
*** Test Cases ***
8+
only test case
9+
Set suite variable ${test_count} ${test_count+1}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*** Settings ***
2+
Documentation In this suite one of the processor options is set on the higher level suite,
3+
... which is then used in both sub suites. The first sub suite overrules the library
4+
... setting with their own value, the second library doesn't. The second suite should
5+
... be unaffected by the overruled option from the preceeding suite.
6+
Suite Setup Set model-based options repeat=2
7+
Library robotmbt processor_lib=suiterepeater

robotmbt/suitereplacer.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,18 @@ def treat_model_based(self, **kwargs):
7777
model info that is included in the test steps, the test cases are modifed, mixed and
7878
matched to create unique traces and achieve more test coverage quicker.
7979
80-
Any arguments are handled as if using keyword `Update model-based options`
80+
Any arguments must be named arguments. They are passed on as options to the selected model-based
81+
processor. If an option was already set on library level (See: `Set model-based options` and
82+
`Update model-based options`, then these arguments take precedence over the library option and
83+
affect only the current test suite.
8184
"""
8285
self.robot_suite = self.current_suite
8386

8487
logger.info(f"Analysing Robot test suite '{self.robot_suite.name}' for model-based execution.")
85-
self.update_model_based_options(**kwargs)
88+
local_settings = self.processor_options.copy()
89+
local_settings.update(kwargs)
8690
master_suite = self.__process_robot_suite(self.robot_suite, parent=None)
87-
modelbased_suite = self.processor_method(master_suite, **self.processor_options)
91+
modelbased_suite = self.processor_method(master_suite, **local_settings)
8892
self.__clearTestSuite(self.robot_suite)
8993
self.__generateRobotSuite(modelbased_suite, self.robot_suite)
9094

0 commit comments

Comments
 (0)