def test_matrix_html(tmpdir): """ Test loading multiple reports :return: """ htmatrix = matrix.HtmlReportMatrix(str(tmpdir)) htmatrix.add_report(get_filepath("junit-simple_suite.xml")) htmatrix.add_report(get_filepath("junit-simple_suites.xml")) assert len(htmatrix.reports) == 2 result = htmatrix.summary() assert result.endswith("</html>")
def test_parser(): """ Test the junit parser directly :return: """ junit = parser.Junit(filename=get_filepath("junit-simple_suite.xml")) assert len(junit.suites) == 1 assert len(junit.suites[0].properties) == 3 junit = parser.Junit(filename=get_filepath("junit-simple_suites.xml")) assert len(junit.suites) == 1 assert len(junit.suites[0].properties) == 3 junit = parser.Junit(filename=get_filepath("junit-complex_suites.xml")) assert len(junit.suites) == 66
def test_runner_simple(tmpdir): """ Test the stand-alone app with a simple fairly empty junit file :param tmpdir: py.test tmpdir fixture :return: """ testfile = get_filepath("junit-simple_suites.xml") outfile = os.path.join(tmpdir.strpath, "report.html") runner.run([testfile, outfile]) assert os.path.exists(outfile)
def run_runner(tmpdir, filename): """ Run the junit2html program against the given report and produce a html doc :param tmpdir: :param filename: :return: """ testfile = get_filepath(filename=filename) outfile = os.path.join(tmpdir.strpath, "report.html") runner.run([testfile, outfile]) assert os.path.exists(outfile)
def test_parser_stringreader(): """ Test the junit parser when reading strings :return: """ with open(get_filepath("junit-complex_suites.xml"), "r") as data: junit = parser.Junit(xmlstring=data.read()) assert len(junit.suites) == 66 assert junit.suites[0].name == "Untitled suite in /Users/niko/Sites/casperjs/tests/suites/casper/agent.js" assert junit.suites[0].package == "tests/suites/casper/agent" assert junit.suites[0].classes["tests/suites/casper/agent"].cases[1].name == "Default user agent matches /plop/"
def test_parser(): """ Test the junit parser directly :return: """ junit = parser.Junit(filename=get_filepath("junit-simple_suite.xml")) assert len(junit.suites) == 1 assert len(junit.suites[0].properties) == 3 junit = parser.Junit(filename=get_filepath("junit-simple_suites.xml")) assert len(junit.suites) == 1 assert len(junit.suites[0].properties) == 3 junit = parser.Junit(filename=get_filepath("junit-complex_suites.xml")) assert len(junit.suites) == 66 junit = parser.Junit(filename=get_filepath("junit-cute2.xml")) assert len(junit.suites) == 6 junit = parser.Junit(filename=get_filepath("junit-unicode.xml")) assert len(junit.suites) == 1 assert len(junit.suites[0].classes) == 1 # different report structure, both files contain unicode symbols junit = parser.Junit(filename=get_filepath("junit-unicode2.xml")) assert len(junit.suites) == 1 assert len(junit.suites[0].classes) == 1
def test_runner_merge(tmpdir): """ Test merging multiple files :param tmpdir: :return: """ filenames = ["junit-complex_suites.xml", "junit-cute2.xml", "junit-unicode.xml"] filepaths = [] for filename in filenames: filepaths.append( os.path.join(tmpdir.strpath, get_filepath(filename))) newfile = os.path.join(tmpdir.strpath, "merged.xml") args = ["--merge", newfile] args.extend(filepaths) runner.run(args) assert os.path.exists(newfile)
def test_matrix_load(tmpdir): """ Test loading multiple reports :return: """ textmatrix = matrix.TextReportMatrix() textmatrix.add_report(get_filepath("junit-simple_suite.xml")) textmatrix.add_report(get_filepath("junit-simple_suites.xml")) textmatrix.add_report(get_filepath("junit-unicode.xml")) textmatrix.add_report(get_filepath("junit-unicode2.xml")) textmatrix.add_report(get_filepath("junit-cute2.xml")) textmatrix.add_report(get_filepath("junit-jenkins-stdout.xml")) assert len(textmatrix.reports) == 6 result = textmatrix.summary() print(result)