Display python unittest results in nice, tabular form

后端 未结 3 1560
心在旅途
心在旅途 2020-12-07 22:46

I am writing a Pythonic tool which validates the correctness of a certain system. Each validation is written as a Python unittest, and the report looks like:



        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 23:38

    This is not exactly what you are asking, but there are several options for having a readable test output there:

    • HTMLTestRunner generates easy to use HTML test reports in a tabular form. Here's a sample report.
    • nose-html-output plugin for nose test runner
    • unittest-xml-reporting - PyUnit-based test runner with JUnit like XML reporting
    • nose with --with-xunit option will produce junit xml style reports that are easy to read and convert

    Also see:

    • How to produce html unit test output in Python?
    • Python Unittest Reporting in HTML
    • unittest colored output (coloring the output can make results readable too)

    If you want to see test results in a tabular form in the console anyway, I think that a good idea would be to write your own nose plugin or test runner based on unittest.TestProgram as it was done in HTMLTestRunner.

    Hope that helps.

提交回复
热议问题