def _factory(pattern=None): plan = testplan.TestplanMock( name="Logging TestPlan", test_filter=Pattern(pattern) if pattern else Filter(), ) plan.add(multitest.MultiTest(name="Logging Test", suites=suites)) return plan
def main(plan): multi_test_1 = MultiTest(name='Primary', suites=[Alpha(), Beta()], test_filter=Pattern('*:*:test_1')) multi_test_2 = MultiTest(name='Secondary', suites=[Gamma()]) plan.add(multi_test_1) plan.add(multi_test_2)
def main(plan): multi_test_1 = MultiTest( name="Primary", suites=[Alpha(), Beta()], test_filter=Pattern("*:*:test_1"), ) multi_test_2 = MultiTest(name="Secondary", suites=[Gamma()]) plan.add(multi_test_1) plan.add(multi_test_2)
# Run test cases that: # have a minimum priority of 5 # OR have a priority between 1 and 3 (inclusive) composed_filter_1 = priority_filter_1 | priority_filter_2 # Run test cases that: # Belong to a suite that inherits from BaseSuite # AND (have a minimum priority of 5 OR have a priority between 1 and 3) composed_filter_2 = subclass_filter & composed_filter_1 # We can also compose custom filters with the built-in filters as well: # Run test cases that: # Belong to suites that inherit from BaseSuite # AND have the name `test_2` composed_filter_3 = subclass_filter & Pattern("*:*:test_2") # Replace the `test_filter` argument with the # filters declared above to see how they work. @test_plan( name="Custom Test Filters", test_filter=priority_filter_1, # Using testcase level stdout so we can see filtered testcases stdout_style=Style("testcase", "testcase"), ) def main(plan): multi_test = MultiTest(name="Sample", suites=[Alpha(), Beta(), Gamma()])
pass @testcase(tags={'color': ('blue', 'red')}) def test_2(self, env, result): pass @testcase(tags={'color': 'yellow'}) def test_3(self, env, result): pass # Default (noop) filter, runs all tests default_filter = Filter() # Run all Multitest named `Primary` and all of its suites & testcases. pattern_filter_1 = Pattern('Primary') # Run `Alpha` suite (and all testcases) from `Primary` multitest. pattern_filter_2 = Pattern('Primary:Alpha') # Run `Alpha.test_1` from `Primary` multitest. pattern_filter_3 = Pattern('Primary:Alpha:test_1') # Run all testcases named `test_1` from all suites & multitests. pattern_filter_4 = Pattern('*:*:test_1') # Multi-pattern filtering, runs multitests with names `Primary` and `Secondary` pattern_filter_5 = Pattern.any('Primary', 'Secondary') # Run all multitests that end with `ary` (Primary & Secondary) pattern_filter_6 = Pattern('*ary')
@testcase def test_3(self, env, result): pass # In the example below, we have plan level test filter that will run # test cases that have the name `test_3` only. # # However on Multitest('Primary') we also have another test filter that # will run test cases with the name `test_1`. This filter will take precedence # over the plan level filter. @test_plan( name='Multi-level Filtering', test_filter=Pattern('*:*:test_3'), # Using testcase level stdout so we can see filtered testcases stdout_style=Style('testcase', 'testcase')) def main(plan): multi_test_1 = MultiTest(name='Primary', suites=[Alpha(), Beta()], test_filter=Pattern('*:*:test_1')) multi_test_2 = MultiTest(name='Secondary', suites=[Gamma()]) plan.add(multi_test_1) plan.add(multi_test_2) if __name__ == '__main__': sys.exit(not main())
pass @testcase(tags={"color": ("blue", "red")}) def test_2(self, env, result): pass @testcase(tags={"color": "yellow"}) def test_3(self, env, result): pass # Default (noop) filter, runs all tests default_filter = Filter() # Run all Multitest named `Primary` and all of its suites & testcases. pattern_filter_1 = Pattern("Primary") # Run `Alpha` suite (and all testcases) from `Primary` multitest. pattern_filter_2 = Pattern("Primary:Alpha") # Run `Alpha.test_1` from `Primary` multitest. pattern_filter_3 = Pattern("Primary:Alpha:test_1") # Run all testcases named `test_1` from all suites & multitests. pattern_filter_4 = Pattern("*:*:test_1") # Multi-pattern filtering, runs multitests with names `Primary` and `Secondary` pattern_filter_5 = Pattern.any("Primary", "Secondary") # Run all multitests that end with `ary` (Primary & Secondary) pattern_filter_6 = Pattern("*ary")
"simple": "server", "color": "blue" }) composite_filter_1_b = Or( Tags({"color": ("red", "yellow")}), TagsAll({ "simple": "server", "color": "blue" }), ) # Run tests that belong to multitest named `Primary` or tagged with `server` # categories (Pattern, Tag etc) is not supported via cmdline. composite_filter_2_a = Pattern("Primary") | Tags("server") composite_filter_2_b = Or(Pattern("Primary"), Tags("server")) # Bitwise AND operator (`&`) or `And` meta filter creates a new filter that # runs tests that pass all of the composed filters. # Run tests that have the name `test_2` and are tagged with `color = blue` composite_filter_3_a = Pattern("*:*:test_2") & Tags({"color": "blue"}) composite_filter_3_b = And(Pattern("*:*:test_2"), Tags({"color": "blue"})) # Bitwise negation (`~`) or `Not` meta filter creates a new filter that # runs tests that fail the original filter. # Run tests that do not have the name `test_1`
# Run tests tagged with `color = red` OR `color = yellow` # OR tagged with `server` AND `color = blue` composite_filter_1_a = Tags({'color': ('red', 'yellow')}) \ | TagsAll({'simple': 'server', 'color': 'blue'}) composite_filter_1_b = Or(Tags({'color': ('red', 'yellow')}), TagsAll({ 'simple': 'server', 'color': 'blue' })) # Run tests that belong to multitest named `Primary` or tagged with `server` # categories (Pattern, Tag etc) is not supported via cmdline. composite_filter_2_a = Pattern('Primary') | Tags('server') composite_filter_2_b = Or(Pattern('Primary'), Tags('server')) # Bitwise AND operator (`&`) or `And` meta filter creates a new filter that # runs tests that pass all of the composed filters. # Run tests that have the name `test_2` and are tagged with `color = blue` composite_filter_3_a = Pattern('*:*:test_2') & Tags({'color': 'blue'}) composite_filter_3_b = And(Pattern('*:*:test_2'), Tags({'color': 'blue'})) # Bitwise negation (`~`) or `Not` meta filter creates a new filter that # runs tests that fail the original filter. # Run tests that do not have the name `test_1`
@testcase def test_3(self, env, result): pass # In the example below, we have plan level test filter that will run # test cases that have the name `test_3` only. # # However on Multitest('Primary') we also have another test filter that # will run test cases with the name `test_1`. This filter will take precedence # over the plan level filter. @test_plan( name="Multi-level Filtering", test_filter=Pattern("*:*:test_3"), # Using testcase level stdout so we can see filtered testcases stdout_style=Style("testcase", "testcase"), ) def main(plan): multi_test_1 = MultiTest( name="Primary", suites=[Alpha(), Beta()], test_filter=Pattern("*:*:test_1"), ) multi_test_2 = MultiTest(name="Secondary", suites=[Gamma()]) plan.add(multi_test_1) plan.add(multi_test_2)