Python script to generate JUnit report from another testing result

后端 未结 6 1849
悲哀的现实
悲哀的现实 2021-02-01 21:53

I have an acceptance test case, the result is plain text. I want to use Jenkins to show the result, and the JUnit format is suitable for me.

So I want to check whether t

6条回答
  •  被撕碎了的回忆
    2021-02-01 22:31

    you can use junitxml (Python JUnit XML reporter)

    on PyPI: http://pypi.python.org/pypi/junitxml

    if you had a standard unittest test suite called suite. you could run it, and write results to an xml file like this:

    import junitxml
    
    fp = file('results.xml', 'wb')
    result = junitxml.JUnitXmlResult(fp)
    result.startTestRun()
    TestSuite(suite).run(result)
    result.stopTestRun()
    

    or to discover tests and print xml to stdout:

    python -m junitxml.main discover
    

    another option is to use nose and run your suite with:

    nosetests --with-xunit
    

提交回复
热议问题