private static final void runTestClassAndAssertStats(Class<?> testClass, int expectedTestCount) {
final int expectedTestFailureCount = 0;
final int expectedTestStartedCount = expectedTestCount;
final int expectedTestFinishedCount = expectedTestCount;
TrackingRunListener listener = new TrackingRunListener();
JUnitCore jUnitCore = new JUnitCore();
jUnitCore.addListener(listener);
jUnitCore.run(testClass);
assertEquals("Verifying number of failures for test class [" + testClass + "].", expectedTestFailureCount,
listener.getTestFailureCount());
assertEquals("Verifying number of tests started for test class [" + testClass + "].", expectedTestStartedCount,
listener.getTestStartedCount());
assertEquals("Verifying number of tests finished for test class [" + testClass + "].",
expectedTestFinishedCount, listener.getTestFinishedCount());
}