@@ -2751,17 +2751,20 @@ def __init__(self, id=None, testplan=None, **kwargs):
27512751 a new test run based on specified test plan (required). Other
27522752 parameters are optional and have the following defaults:
27532753
2754- build ..... "unspecified"
2755- errata..... related errata
2756- product ... test run product
2757- version ... test run product version
2758- summary ... <test plan name> on <build>
2759- notes ..... ""
2760- manager ... current user
2761- tester .... current user
2762- tags ...... None
2763-
2764- Tags should be provided as a list of tag names.
2754+ build ....... "unspecified"
2755+ errata....... related errata
2756+ product ..... test run product
2757+ version ..... test run product version
2758+ summary ..... <test plan name> on <build>
2759+ notes ....... ""
2760+ manager ..... current user
2761+ tester ...... current user
2762+ tags ........ None
2763+ testcases ... test cases to be included
2764+
2765+ Tags should be provided as a list of tag names. Test cases can
2766+ be provided as a list of test case objects or a list of ids. By
2767+ default all CONFIRMED test cases are linked to the created run.
27652768 """
27662769
27672770 # Prepare attributes, check test run hash, initialize
@@ -2804,7 +2807,7 @@ def search(**query):
28042807
28052808 def _create (self , testplan , product = None , version = None , build = None ,
28062809 summary = None , notes = None , manager = None , tester = None , tags = None ,
2807- errata = None , ** kwargs ):
2810+ errata = None , testcases = None , ** kwargs ):
28082811 """ Create a new test run. """
28092812
28102813 hash = {}
@@ -2846,9 +2849,17 @@ def _create(self, testplan, product=None, version=None, build=None,
28462849 hash ["manager" ] = manager .id
28472850 hash ["default_tester" ] = tester .id
28482851
2849- # Include all CONFIRMED test cases and tag with supplied tags
2850- hash ["case" ] = [case .id for case in testplan
2851- if case .status == CaseStatus ("CONFIRMED" )]
2852+ # Prepare the list of test cases to be included in the test run
2853+ # If testcases parameter is non-empty only selected cases will
2854+ # be added, otherwise all CONFIRMED cases will be linked.
2855+ if testcases is not None :
2856+ hash ["case" ] = [case .id if isinstance (case , TestCase ) else case
2857+ for case in testcases ]
2858+ else :
2859+ hash ["case" ] = [case .id for case in testplan
2860+ if case .status == CaseStatus ("CONFIRMED" )]
2861+
2862+ # Tag with supplied tags
28522863 if tags : hash ["tag" ] = "," .join (tags )
28532864
28542865 # Submit to the server and initialize
@@ -2979,6 +2990,23 @@ def testDisabledCasesOmitted(self):
29792990 testcase .status = original
29802991 testcase .update ()
29812992
2993+ def test_include_only_selected_cases (self ):
2994+ """ Include only selected test cases in the new run """
2995+ testcase = TestCase (self .testcase .id )
2996+ testplan = TestPlan (self .testplan .id )
2997+ # No test case should be linked
2998+ testrun = TestRun (testplan = testplan , testcases = [])
2999+ self .assertTrue (testcase .id not in
3000+ [caserun .testcase .id for caserun in testrun ])
3001+ # Select test case by test case object
3002+ testrun = TestRun (testplan = testplan , testcases = [testcase ])
3003+ self .assertTrue (testcase .id in
3004+ [caserun .testcase .id for caserun in testrun ])
3005+ # Select test case by id
3006+ testrun = TestRun (testplan = testplan , testcases = [testcase .id ])
3007+ self .assertTrue (testcase .id in
3008+ [caserun .testcase .id for caserun in testrun ])
3009+
29823010
29833011# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29843012# Test Case Class
0 commit comments