How to use the junitparser.TestSuite function in junitparser

To help you get started, we’ve selected a few junitparser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / watson-assistant-workbench / scripts / functions_test_evaluate.py View on Github external
logger.critical("Cannot open evaluation JUnit XML output file '%s'", junitFileName)
            sys.exit(1)

    try:
        inputJson = json.load(inputFile)
    except ValueError as e:
        logger.critical("Cannot decode json from test output file '%s', error '%s'", args.inputFileName, str(e))
        sys.exit(1)

    if not isinstance(inputJson, list):
        logger.critical("Test output json is not array!")
        sys.exit(1)

    # run evaluation
    xml = JUnitXml()
    suite = TestSuite(os.path.splitext(os.path.basename(args.inputFileName))[0]) # once we support multiple test files then for each one should be test suite created
    xml.add_testsuite(suite)
    suite.timestamp = str(datetime.datetime.now()) # time of evaluation, not the testing it self (evaluations could differ)
    #suite.hostname = ''
    testCounter = 0
    for test in inputJson:
        case = TestCase()
        suite.add_testcase(case)

        if not isinstance(test, dict):
            errorMessage = "Input test array element {:d} is not dictionary. Each test has to be dictionary, please see doc!".format(testCounter)
            logger.error(errorMessage)
            case.result = Error(errorMessage, 'ValueError')
            continue

        logger.info("Test number %d, name '%s'", testCounter, test.get('name', '-'))
        case.name = test.get('name', None)
github zephyrproject-rtos / zephyr / scripts / ci / check-compliance.py View on Github external
github_token = ''
    gh = None
    if args.github:
        github_token = os.environ['GH_TOKEN']
        gh = Github(github_token)

    if args.status and args.sha != None and args.repo and gh:
        set_status(gh, args.repo, args.sha)
        sys.exit(0)

    if not args.commits:
        sys.exit(1)

    suite = TestSuite("Compliance")
    docs = {}
    for Test in ComplianceTest.__subclasses__():
        t = Test(suite, args.commits)
        t.run()
        suite.add_testcase(t.case)
        docs[t.case.name] = t._doc

    xml = JUnitXml()
    xml.add_testsuite(suite)
    xml.update_statistics()
    xml.write('compliance.xml')

    if args.github:
        repo = gh.get_repo(args.repo)
        pr = repo.get_pull(int(args.pull_request))
        commit = repo.get_commit(args.sha)
github nuxeo / nuxeo-drive / tools / jenkins / junit / merge.py View on Github external
def process_xml(self, path: Path) -> None:
        if not path.exists():
            return
        print(f"Processing {path}")
        suites = JUnitXml.fromfile(path)
        if isinstance(suites, TestSuite):
            suites = [suites]
        for suite in suites:
            self.add_tests(suite)
github nuxeo / nuxeo-drive / tools / jenkins / junit / merge.py View on Github external
def build(self) -> None:
        self.mainsuite = TestSuite("Drive")

        self.process_xml(self.folder / "final.xml")

        for idx in (2, 1):
            # First add the results from the reruns (suffixed with "2")
            # then the first runs, to add successes before failures.
            for results in Path(self.folder).glob(f"**/*.{idx}.xml"):
                self.process_xml(results)

        print("End of processing")
        print_suite(self.mainsuite)

        xml = JUnitXml()
        xml.add_testsuite(self.mainsuite)
        xml.write(self.folder / self.output)