report test execution statistics as teamcity service messages

This commit is contained in:
Dmitry Jemerov
2014-12-02 21:48:03 +01:00
parent 0e5601ffde
commit bbeae5cd2e
2 changed files with 12 additions and 4 deletions
@@ -186,15 +186,21 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
return ourApplication;
}
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public static void reportTestExecutionStatistics() {
System.out.println("----- TEST STATISTICS -----");
UsefulTestCase.logSetupTeardownCosts();
System.out.println(String.format("Application reinitializations: %d", MockApplication.INSTANCES_CREATED));
System.out.println(String.format("Test projects opened: %d", ProjectManagerImpl.TEST_PROJECTS_CREATED));
System.out.println(String.format("##teamcity[buildStatisticValue key='ideaTests.appInstancesCreated' value='%d']",
MockApplication.INSTANCES_CREATED));
System.out.println(String.format("##teamcity[buildStatisticValue key='ideaTests.projectInstancesCreated' value='%d']",
ProjectManagerImpl.TEST_PROJECTS_CREATED));
long totalGcTime = 0;
for (GarbageCollectorMXBean mxBean : ManagementFactory.getGarbageCollectorMXBeans()) {
System.out.println(String.format("Garbage collection in memory pool %s: %d ms", mxBean.getName(), mxBean.getCollectionTime()));
totalGcTime += mxBean.getCollectionTime();
}
System.out.println(String.format("Total classes loaded: %d", ManagementFactory.getClassLoadingMXBean().getTotalLoadedClassCount()));
System.out.println(String.format("##teamcity[buildStatisticValue key='ideaTests.gcTimeMs' value='%d']", totalGcTime));
System.out.println(String.format("##teamcity[buildStatisticValue key='ideaTests.classesLoaded' value='%d']",
ManagementFactory.getClassLoadingMXBean().getTotalLoadedClassCount()));
}
protected void resetAllFields() {
@@ -387,6 +387,8 @@ public abstract class UsefulTestCase extends TestCase {
totalTeardown += entry.getValue();
}
System.out.println(String.format("Total overhead: setup %d ms, teardown %d ms", totalSetup, totalTeardown));
System.out.println(String.format("##teamcity[buildStatisticValue key='ideaTests.totalSetupMs' value='%d']", totalSetup));
System.out.println(String.format("##teamcity[buildStatisticValue key='ideaTests.totalTeardownMs' value='%d']", totalTeardown));
}
public static void replaceIdeEventQueueSafely() {