You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/userguide/src/ExecutingTestCases/ConfiguringExecution.rst
+56-11Lines changed: 56 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -515,13 +515,9 @@ the executable test suite structure and modify it as needed. The visitor
515
515
interface is explained as part of the `Robot Framework API documentation
516
516
<visitor interface_>`_, and it possible to modify executed `test suites
517
517
<running.TestSuite_>`_, `test cases <running.TestCase_>`_ and `keywords
518
-
<running.Keyword_>`_ using it. The example below ought to give an idea of
518
+
<running.Keyword_>`_ using it. The examples below ought to give an idea of
519
519
how model modifiers can be used and how powerful this functionality is.
520
520
521
-
.. sourcecode:: python
522
-
523
-
../api/code_examples/select_every_xth_test.py
524
-
525
521
When a model modifier is taken into use on the command line using the
526
522
:option:`--prerunmodifier` option, it can be specified either as a name of
527
523
the modifier class or a path to the modifier file. If the modifier is given
@@ -531,12 +527,25 @@ name must include both like `module.ModifierClass`. If the modifier is given
531
527
as a path, the class name must be same as the file name. For most parts this
532
528
works exactly like when `specifying a test library to import`__.
533
529
534
-
If a modifier requires arguments, like the example above does, they can be
530
+
If a modifier requires arguments, like the examples below do, they can be
535
531
specified after the modifier name or path using either a colon (`:`) or a
536
532
semicolon (`;`) as a separator. If both are used in the value, the one first
537
533
is considered the actual separator.
538
534
539
-
For example, if the above model modifier would be in a file
535
+
If more than one model modifier is needed, they can be specified by using
536
+
the :option:`--prerunmodifier` option multiple times. If similar modifying
537
+
is needed before creating results, `programmatic modification of results`_
538
+
can be enabled using the :option:`--prerebotmodifier` option.
539
+
540
+
Example: Select Every Xth Test
541
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
542
+
In this code snippet, the prerun modifier causes the framework to skip over or filter out any test case that isn't Xth one, where Xth is a number passed in as an argument on the command line.
543
+
544
+
.. sourcecode:: python
545
+
546
+
../api/code_examples/select_every_xth_test.py
547
+
548
+
If the above model modifier is in a file
540
549
:file:`SelectEveryXthTest.py`, it could be used like this::
541
550
542
551
# Specify the modifier as a path. Run every second test.
@@ -546,10 +555,46 @@ For example, if the above model modifier would be in a file
546
555
# SelectEveryXthTest.py must be in the module search path.
If more than one model modifier is needed, they can be specified by using
550
-
the :option:`--prerunmodifier` option multiple times. If similar modifying
551
-
is needed before creating results, `programmatic modification of results`_
552
-
can be enabled using the :option:`--prerebotmodifier` option.
558
+
559
+
Example: Filter Out Test Cases or Suite By Name
560
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
561
+
The following prerun modifier removes any test case in which the user-defined string is found in the test name or in the test's parent or ancestor suites. This prerun modifier is like a negative version of the flags --suite and --test because test cases or test suites are excluded from the test run by name instead of tag.
562
+
563
+
.. sourcecode:: python
564
+
565
+
../api/code_examples/filtertc.py
566
+
567
+
Assuming the module that contained this prerun modifier is in the module search path and the module name is filtertc, then it could be used like this::
568
+
569
+
##Specify modifier by name where the namespace requires the module name since it differs from the class name.
This means that any test case in any of the data sources that has the string 'Create Table' in the test name is excluded from the test run. In addition, any test case whose parent or ancester suites have the string database are also excluded from the test run.
573
+
574
+
575
+
Example: Skip Setups and Teardowns
576
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
577
+
When debugging test cases, a tester may need to temporarily disable a teardown or setup so that system under test is in a state that can be easily debugged. The following prerun modifier can disable setups and teardowns in either suites or test cases.
578
+
579
+
.. sourcecode:: python
580
+
581
+
../api/code_examples/disable.py
582
+
583
+
Assuming the module that contained this prerun modifier is in the module search path and the module name is disable, then execute this command to disable setup and teardowns for both suites and test cases.::
584
+
585
+
##Specify modifier by name where the namespace requires the module name since it differs from the class name.
0 commit comments