use of org.springframework.test.context.testng.TrackingTestNGTestListener in project spring-framework by spring-projects.
the class ClassLevelDirtiesContextTestNGTests method runTestClassAndAssertStats.
private void runTestClassAndAssertStats(Class<?> testClass, int expectedTestCount) {
final int expectedTestFailureCount = 0;
final int expectedTestStartedCount = expectedTestCount;
final int expectedTestFinishedCount = expectedTestCount;
final TrackingTestNGTestListener listener = new TrackingTestNGTestListener();
final TestNG testNG = new TestNG();
testNG.addListener((ITestNGListener) listener);
testNG.setTestClasses(new Class<?>[] { testClass });
testNG.setVerbose(0);
testNG.run();
assertEquals("Failures for test class [" + testClass + "].", expectedTestFailureCount, listener.testFailureCount);
assertEquals("Tests started for test class [" + testClass + "].", expectedTestStartedCount, listener.testStartCount);
assertEquals("Successful tests for test class [" + testClass + "].", expectedTestFinishedCount, listener.testSuccessCount);
}
use of org.springframework.test.context.testng.TrackingTestNGTestListener in project spring-framework by spring-projects.
the class FailingBeforeAndAfterMethodsTestNGTests method runTestAndAssertCounters.
@Test
@Ignore("Fails against TestNG 6.11")
public void runTestAndAssertCounters() throws Exception {
TrackingTestNGTestListener listener = new TrackingTestNGTestListener();
TestNG testNG = new TestNG();
testNG.addListener((ITestNGListener) listener);
testNG.setTestClasses(new Class<?>[] { this.clazz });
testNG.setVerbose(0);
testNG.run();
String name = this.clazz.getSimpleName();
assertEquals("tests started for [" + name + "] ==> ", this.expectedTestStartCount, listener.testStartCount);
assertEquals("successful tests for [" + name + "] ==> ", this.expectedTestSuccessCount, listener.testSuccessCount);
assertEquals("failed tests for [" + name + "] ==> ", this.expectedFailureCount, listener.testFailureCount);
assertEquals("failed configurations for [" + name + "] ==> ", this.expectedFailedConfigurationsCount, listener.failedConfigurationsCount);
}
Aggregations