Ejemplo 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()
Ejemplo 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)
Ejemplo 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
Ejemplo 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()
Ejemplo n.º 5
0
def test_print_run_url(reporter, mocker):
    stdout = mocker.patch('sys.stdout', new=StringIO())
    run = mock.Mock(url='http://report_url/')
    mocker.patch.object(reporter, 'find_testrail_cases', return_value=[Case()])
    mocker.patch.object(reporter,
                        'get_or_create_plan',
                        return_value=Plan('test_plan'))
    mocker.patch.object(reporter, 'create_test_run', return_value=run)
    reporter.execute()
    assert stdout.getvalue() == ('[TestRun URL] http://report_url/\n')
Ejemplo 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
Ejemplo 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])
Ejemplo n.º 8
0
def test_add_result_to_case(reporter, xunit_case):
    testrail_case = Case()
    xunit_case.message = u'успешно'
    xunit_case.stderr = u'stderr message сообщение'
    xunit_case.stdout = u'stdout message сообщение'
    xunit_case.trace = u'trace сообщение'
    report_url = reporter.get_jenkins_report_url(xunit_case)
    reporter.add_result_to_case(testrail_case, xunit_case)
    comment = testrail_case.result.comment
    assert report_url in comment
    assert reporter.env_description in comment
    assert xunit_case.message in comment
    assert xunit_case.stderr not in comment
    assert xunit_case.stdout not in comment
    assert xunit_case.trace in comment
Ejemplo n.º 9
0
def test_send_skipped_param(reporter, xunit_case_skipped, send_skipped):
    reporter.send_skipped = send_skipped
    testrail_case = Case()
    reporter.add_result_to_case(testrail_case, xunit_case_skipped)
    assert send_skipped == (testrail_case.result is not None)