CleanCut / green

Green is a clean, colorful, fast python test runner.
MIT License
785 stars 75 forks source link

JUnit Report doesn't have testcase timing details #208

Closed tattah closed 4 years ago

tattah commented 4 years ago

Thanks for developing this great package. IMHO its the best Python unit testrunner that I have come across. I have been using it for about a year along with the other tools below for the reasons given, whilst Unit, Integration and Acceptance testing:

As an enhancement, I'd like to suggest adding an output to file option (e.g. -o|--outfile filename) that would write the test result output to a file in an existing structured format. For instance:

    green -vv --outfile <my_results.xml> ./some/python/package

Either JUnit, NUnit2 or both would be my suggested output format as both are well known, used by many other tools and there is no real benefit creating a custom format.

Not sure how much effort this would be but this would make green not just great for development/test development (which it already is) but also great for test reporting.

Benefits

tattah commented 4 years ago

Apologies, I just realized that green 2.16.1 has the -j|--junit-report option but I noticed that the generated JUnit report doesn't have testcase timings details.

CleanCut commented 4 years ago

On first glance, this might be easy by recording timing in result.py's ProtoTestResult using startTest to initiate timing and stopTest to measure and record it. Then the information would need to be plumbed through to the JUnit logic and hooked in.

/cc @fchauvel who contributed JUnit support and might be interested in this.

bkmd11 commented 4 years ago

I am interested in working on this enhancement, would that be alright? I do have a question on what the end objective is. Should the output file have time taken for each individual test, or the total time for the entire test suite?

CleanCut commented 4 years ago

I am interested in working on this enhancement, would that be alright?

Yes!

Should the output file have time taken for each individual test, or the total time for the entire test suite?

I don't know the answer to that myself. I would start by looking up some example JUnit reports.

jeansaad commented 4 years ago

@bkmd11, I believe that the output file should have the time taken for a <testcase>, <testsuite>, and <testsuites>. Have a look at https://www.ibm.com/support/knowledgecenter/SSQ2R2_9.1.1/com.ibm.rsar.analysis.codereview.cobol.doc/topics/cac_useresults_junit.html for more information.

CleanCut commented 4 years ago

Included in Green 3.2.0 (just released).