Polish TimedSpringRunnerTests

This commit is contained in:
Sam Brannen 2015-01-10 17:52:41 +01:00
parent b81c522ee1
commit cf7a7932f3
2 changed files with 29 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -57,7 +57,11 @@ public class TimedSpringRunnerTests {
new SpringJUnit4ClassRunner(testClass).run(notifier);
assertEquals("Verifying number of tests started for test class [" + testClass + "].", 7,
listener.getTestStartedCount());
assertEquals("Verifying number of failures for test class [" + testClass + "].", 5,
assertEquals("Verifying number of tests ignored for test class [" + testClass + "].", 0,
listener.getTestIgnoredCount());
assertEquals("Verifying number of assumption failures for test class [" + testClass + "].", 0,
listener.getTestAssumptionFailureCount());
assertEquals("Verifying number of test failures for test class [" + testClass + "].", 5,
listener.getTestFailureCount());
assertEquals("Verifying number of tests finished for test class [" + testClass + "].", 7,
listener.getTestFinishedCount());
@ -125,7 +129,6 @@ public class TimedSpringRunnerTests {
@Timed(millis = 1000)
@Retention(RetentionPolicy.RUNTIME)
private static @interface MetaTimedWithOverride {
long millis() default 1000;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -37,6 +37,10 @@ public class TrackingRunListener extends RunListener {
private final AtomicInteger testFinishedCount = new AtomicInteger();
private final AtomicInteger testAssumptionFailureCount = new AtomicInteger();
private final AtomicInteger testIgnoredCount = new AtomicInteger();
public int getTestFailureCount() {
return this.testFailureCount.get();
@ -50,6 +54,14 @@ public class TrackingRunListener extends RunListener {
return this.testFinishedCount.get();
}
public int getTestAssumptionFailureCount() {
return this.testAssumptionFailureCount.get();
}
public int getTestIgnoredCount() {
return this.testIgnoredCount.get();
}
@Override
public void testFailure(Failure failure) throws Exception {
this.testFailureCount.incrementAndGet();
@ -65,4 +77,14 @@ public class TrackingRunListener extends RunListener {
this.testFinishedCount.incrementAndGet();
}
@Override
public void testAssumptionFailure(Failure failure) {
this.testAssumptionFailureCount.incrementAndGet();
}
@Override
public void testIgnored(Description description) throws Exception {
this.testIgnoredCount.incrementAndGet();
}
}