From: Jean Privat Date: Fri, 27 May 2016 02:25:30 +0000 (-0400) Subject: nitunit: improve summary of results X-Git-Url: http://nitlanguage.org nitunit: improve summary of results Signed-off-by: Jean Privat --- diff --git a/src/nitunit.nit b/src/nitunit.nit index 878d3f2..bed744c 100644 --- a/src/nitunit.nit +++ b/src/nitunit.nit @@ -98,19 +98,59 @@ end var file = toolcontext.opt_output.value if file == null then file = "nitunit.xml" page.write_to_file(file) -# print docunits results -print "DocUnits:" -if modelbuilder.unit_entities == 0 then - print "No doc units found" -else if modelbuilder.failed_entities == 0 and not toolcontext.opt_noact.value then - print "DocUnits Success" + +# Print results +printn "Docunits: Entities: {modelbuilder.total_entities}; Documented ones: {modelbuilder.doc_entities}; With nitunits: {modelbuilder.unit_entities}" +if modelbuilder.unit_entities == 0 or toolcontext.opt_noact.value then + print "" +else + printn "; Failures: " + var cpt = modelbuilder.failed_entities + if toolcontext.opt_no_color.value then + print cpt + else if cpt == 0 then + print "0".green.bold + else + print cpt.to_s.red.bold + end +end +printn "Test suites: Classes: {modelbuilder.total_classes}; Test Cases: {modelbuilder.total_tests}" +if modelbuilder.total_tests == 0 or toolcontext.opt_noact.value then + print "" +else + printn "; Failures: " + var cpt = modelbuilder.failed_tests + if toolcontext.opt_no_color.value then + print cpt + else if cpt == 0 then + print "0".green.bold + else + print cpt.to_s.red.bold + end end -print "Entities: {modelbuilder.total_entities}; Documented ones: {modelbuilder.doc_entities}; With nitunits: {modelbuilder.unit_entities}; Failures: {modelbuilder.failed_entities}" -# print testsuites results -print "\nTestSuites:" -if modelbuilder.total_tests == 0 then - print "No test cases found" -else if modelbuilder.failed_tests == 0 and not toolcontext.opt_noact.value then - print "TestSuites Success" + +var total = modelbuilder.unit_entities + modelbuilder.total_tests +var fail = modelbuilder.failed_entities + modelbuilder.failed_tests +if toolcontext.opt_noact.value then + # nothing +else if total == 0 then + var head = "[NOTHING]" + if not toolcontext.opt_no_color.value then + head = head.yellow + end + print "{head} No unit tests to execute." +else if fail == 0 then + var head = "[SUCCESS]" + if not toolcontext.opt_no_color.value then + head = head.green.bold + end + print "{head} All {total} tests passed." +else + var head = "[FAILURE]" + if not toolcontext.opt_no_color.value then + head = head.red.bold + end + print "{head} {fail}/{total} tests failed." + + exit 1 end -print "Class suites: {modelbuilder.total_classes}; Test Cases: {modelbuilder.total_tests}; Failures: {modelbuilder.failed_tests}"