testing - How to list the slowest JUnit tests in a multi-module Maven build -
how can list slowest junit tests in multi-module maven build?
this should accross modules.
a hudson/jenkins solution do.
disclaimer: apologize bash solution, although works , fits in 1 line :-). if impatient, go bottom.
first need find test-*.xml
files produced maven-surefire-plugin
. run after mvn test
in root directory of project discover test results in submodules:
$ find . -iname "test-*.xml"
fortunately format of these files pretty straightforward, simple grep
, have need:
$ grep -h "<testcase" `find . -iname "test-*.xml"`
now sed
magic extract invocation time, test case class , method name:
$ sed 's/<testcase time="\(.*\)" classname="\(.*\)" name="\(.*\)".*/\1\t\2.\3/'
there's nothing more left sort result , display longest running tests:
$ sort -rn | head
promised one-liner:
$ grep -h "<testcase" `find . -iname "test-*.xml"` | sed 's/<testcase time="\(.*\)" classname="\(.*\)" name="\(.*\)".*/\1\t\2.\3/' | sort -rn | head
amazingly, results reasonable (activiti 5.1 multi-module code-base taken example):
3.029 org.activiti.examples.variables.jpa.jpavariabletest.teststorejpaentityasvariable 2.904 org.activiti.engine.test.forms.formstest.testtaskformpropertydefaultsandformrendering 1.594 org.activiti.engine.test.api.mgmt.managementservicetest.testgetjobexceptionstacktrace 1.114 org.activiti.examples.variables.jpa.jpavariabletest.testupdatejpaentityvalues 1.006 org.activiti.engine.test.db.enginerebootprocessdefinitioncachetest.teststartprocessinstancebyidafterreboot 0 org.activiti.engine.test.pvm.pvmvariablestest.testvariables 0 org.activiti.engine.test.pvm.pvmscopewaitstatetest.testwaitstatescope 0 org.activiti.engine.test.pvm.pvmscopesandconcurrencytest.testconcurrentpathsgoingintoscope 0 org.activiti.engine.test.pvm.pvmeventtest.testnestedactivitieseventsontransitionevents 0 org.activiti.engine.test.pvm.pvmeventtest.testembeddedsubprocessevents
Comments
Post a Comment