예제 #1
0
def test_combined_result():
    """
    Test that the combined result string and short result value are correct
    :return:
    """
    textmatrix = matrix.TextReportMatrix()
    short, result = textmatrix.combined_result([PASSED, SKIPPED])

    assert short == textmatrix.short_outcome(PARTIAL_PASS)
    assert result == PARTIAL_PASS.title()

    short, result = textmatrix.combined_result([PASSED, FAILED])
    assert short == textmatrix.short_outcome(PARTIAL_FAIL)
    assert result == PARTIAL_FAIL.title()

    short, result = textmatrix.combined_result([FAILED, FAILED])
    assert short == textmatrix.short_outcome(TOTAL_FAIL)
    assert result == TOTAL_FAIL.title()

    short, result = textmatrix.combined_result([PASSED])
    assert short == textmatrix.short_outcome(PASSED)
    assert result == PASSED.title()

    short, result = textmatrix.combined_result([SKIPPED, SKIPPED])
    assert short == textmatrix.short_outcome(UNTESTED)
    assert result == UNTESTED.title()
예제 #2
0
def run(args):
    """
    Run this tool
    :param args:
    :return:
    """
    opts = PARSER.parse_args(args) if args else PARSER.parse_args()
    inputs = opts.REPORTS
    util = None
    if opts.merge_output:
        util = merge.Merger()
        for inputfile in inputs:
            util.add_report(inputfile)

        xmltext = util.toxmlstring()
        with open(opts.merge_output, "w") as outfile:
            outfile.write(xmltext)
    elif opts.text_matrix:
        util = matrix.TextReportMatrix()
        for filename in inputs:
            util.add_report(filename)
        print(util.summary())
    elif opts.html_matrix:
        util = matrix.HtmlReportMatrix(os.path.dirname(opts.html_matrix))
        for filename in inputs:
            util.add_report(filename)
        with open(opts.html_matrix, "w") as outfile:
            outfile.write(util.summary())

    if util:
        if opts.fail:
            failed = util.failures()
            if len(failed) >= opts.fail:
                sys.exit(len(failed))
        if opts.skip:
            skipped = util.skips()
            if len(skipped) >= opts.fail:
                sys.exit(len(skipped))

    if not util:
        # legacy interface that we need to preserve
        # no options, one or two args, first is input file, optional second is output

        if len(opts.REPORTS) > 2:
            PARSER.print_usage()
            sys.exit(1)

        if len(opts.REPORTS) == 2:
            outfilename = opts.REPORTS[1]
        else:
            outfilename = opts.REPORTS[0] + ".html"

        report = parser.Junit(args[0])
        html = report.html()

        with open(outfilename, "wb") as outfile:
            outfile.write(html.encode('utf-8'))
예제 #3
0
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)
예제 #4
0
def run(args):
    """
    Run this tool
    :param args:
    :return:
    """
    (opts, args) = PARSER.parse_args(args) if args else PARSER.parse_args()
    if not len(args):
        PARSER.print_usage()
        sys.exit(1)

    if opts.merge_output:
        merger = merge.Merger()
        for inputfile in args:
            merger.load_report(inputfile)

        xmltext = merger.toxmlstring()
        with open(opts.merge_output, "w") as outfile:
            outfile.write(xmltext)
    elif opts.text_matrix:
        tmatrix = matrix.TextReportMatrix()
        for filename in args:
            tmatrix.add_report(filename)
        print(tmatrix.summary())
    elif opts.html_matrix:
        hmatrix = matrix.HtmlReportMatrix(os.path.dirname(opts.html_matrix))
        for filename in args:
            hmatrix.add_report(filename)
        with open(opts.html_matrix, "w") as outfile:
            outfile.write(hmatrix.summary())
    else:
        outfilename = args[0] + ".html"
        if len(args) > 1:
            outfilename = args[1]

        report = parser.Junit(args[0])
        html = report.html()

        with open(outfilename, "wb") as outfile:
            outfile.write(html.encode('utf-8'))