Esempio n. 1
0
def test_no_testrail_case_logging(mapper, caplog):
    from xunit2testrail.vendor.xunitparser import TestCase as XunitCase
    xunit_case = XunitCase(classname='a.b.C', methodname='d[(12345)]')
    testrail_case = Case(custom_report_label='123456')
    mapper.map([xunit_case], [testrail_case])
    expected = "{0.classname}.{0.methodname} doesn't match".format(xunit_case)
    assert expected in caplog.text()
Esempio n. 2
0
def test_map_cases(mapper, xunit_names, testrail_names, expected):
    from xunit2testrail.vendor.xunitparser import TestCase as XunitCase
    xunit_cases = [XunitCase(classname='a.b.C',
                             methodname=x) for x in xunit_names]
    testrail_cases = [Case(custom_report_label=x,
                           title=x) for x in testrail_names]
    check_mapping(mapper.map(xunit_cases, testrail_cases), expected)
Esempio n. 3
0
def test_match_case(mapper, methodname, match_value, x_name_template,
                    map_len):
    from xunit2testrail.vendor.xunitparser import TestCase as XunitCase
    xunit_case = XunitCase(classname='a.b.C', methodname=methodname)
    case = Case(custom_report_label=match_value)
    mapper.xunit_name_template = x_name_template
    result = mapper.get_suitable_cases(xunit_case, [case])
    assert len(result) == map_len
Esempio n. 4
0
def test_empty_xunit_id(mapper, caplog):
    from xunit2testrail.vendor.xunitparser import TestCase as XunitCase
    xunit_case = XunitCase(classname='a.b.C', methodname='test_e[1]')
    mapper.xunit_name_template = '{id}'
    case = Case(custom_report_label=None)
    result = mapper.get_suitable_cases(xunit_case, [case])
    assert case not in result
    assert str(xunit_case) in caplog.text()
Esempio n. 5
0
def test_no_testrail_case_logging(caplog, template_mapper):
    from xunit2testrail.vendor.xunitparser import TestCase as XunitCase

    xunit_case = XunitCase(classname='a.b.C', methodname='d[(12345)]')
    testrail_case = client.Case(custom_report_label='123456')
    template_mapper.map([xunit_case], [testrail_case])
    expected = "`{}` doesn't match".format(xunit_case)
    assert expected in caplog.text
Esempio n. 6
0
def test_match_templates(x_tpl, tr_tpl, mapper, map_len, xcase_data,
                         tcase_data):
    from xunit2testrail.vendor.xunitparser import TestCase as XunitCase
    xunit_case = XunitCase(**xcase_data)
    case = Case(**tcase_data)

    mapper.xunit_name_template = x_tpl
    mapper.testrail_name_template = tr_tpl
    result = mapper.get_suitable_cases(xunit_case, [case])
    assert len(result) == map_len
Esempio n. 7
0
def test_error_map_logging(mapper, xunit_names, testrail_names, log_strings,
                           caplog):
    from xunit2testrail.vendor.xunitparser import TestCase as XunitCase
    xunit_cases = [XunitCase(classname='a.b.C',
                             methodname=x) for x in xunit_names]
    testrail_cases = [Case(custom_report_label=x,
                           title='title_{}'.format(x)) for x in testrail_names]
    try:
        mapper.map(xunit_cases, testrail_cases)
    except Exception:
        pass
    assert all([x in caplog.text() for x in log_strings])
def test_get_jenkins_report_url(reporter, classname, methodname, expected_url):

    from xunit2testrail.vendor.xunitparser import TestCase as XunitCase
    xunit_case = XunitCase(classname=classname, methodname=methodname)
    reporter.test_results_link = 'http://t_job/'
    assert expected_url == reporter.get_jenkins_report_url(xunit_case)
def xunit_case():
    from xunit2testrail.vendor.xunitparser import TestCase as XunitCase
    xunit_case = XunitCase(classname='a.TestClass', methodname='test_method')
    xunit_case.result = 'success'
    xunit_case.time = datetime.timedelta(seconds=1)
    return xunit_case