product=PRODUCT, summary="Test Case {0}".format(case_count + 1), status=CASESTATUS) # Add a couple of random tags and the default tester testcase.tags.add([random.choice(TAGS) for counter in range(10)]) testcase.tester = random.choice(TESTERS) testcase.update() cases.append(testcase) # Create master test plan (parent of all) master = nitrate.TestPlan( name=MASTER_TESTPLAN_NAME, product=PRODUCT, version=VERSION, type=PLANTYPE) nitrate.info("* {0}".format(master)) master.testcases.add(cases) master.update() # Create child test plans for plan_count in range(options.plans): testplan = nitrate.TestPlan( name="Test Plan {0}".format(plan_count + 1), product=PRODUCT, version=VERSION, parent=master, type=PLANTYPE) # Link all test cases to the test plan testplan.testcases.add(cases) testplan.update() nitrate.info(" * {0}".format(testplan))
Simple example showing the main features of the python-nitrate module. Covered are testplan, testrun, testcase creation, logging, setting the log level, cache level and color mode, test case linking, attributes adjustments and updating the changes to the server. """ import nitrate from nitrate import info, log # Set log level, cache level and color mode nitrate.set_log_level(nitrate.LOG_DEBUG) nitrate.set_cache_level(nitrate.CACHE_OBJECTS) nitrate.set_color_mode(nitrate.COLOR_AUTO) # Initialize an existing test plan info("Initializing an existing test plan") general_plan = nitrate.TestPlan(3781) print general_plan # Logging, catching errors nitrate.set_log_level(nitrate.LOG_INFO) info("Initializing a bad test plan") try: log.info("Inspecting the test plan") bad_plan = nitrate.TestPlan(1) print bad_plan except nitrate.NitrateError, error: log.error("Bad test plan id ({0})".format(error)) # Iterate over all test plan's test cases info("Inspecting test plan's test cases")
category=CATEGORY, product=PRODUCT, summary="Test Case {0}".format(case_count + 1), status=CASESTATUS) # Add a couple of random tags and the default tester testcase.tags.add([random.choice(TAGS) for counter in range(10)]) testcase.tester = random.choice(TESTERS) testcase.update() cases.append(testcase) # Create master test plan (parent of all) master = nitrate.TestPlan(name=MASTER_TESTPLAN_NAME, product=PRODUCT, version=VERSION, type=PLANTYPE) nitrate.info("* {0}".format(master)) master.testcases.add(cases) master.update() # Create child test plans for plan_count in range(options.plans): testplan = nitrate.TestPlan(name="Test Plan {0}".format(plan_count + 1), product=PRODUCT, version=VERSION, parent=master, type=PLANTYPE) # Link all test cases to the test plan testplan.testcases.add(cases) testplan.update() nitrate.info(" * {0}".format(testplan))