Skip to content

Commit

Permalink
Polish TimedSpringRunnerTests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Jan 10, 2015
1 parent b81c522 commit cf7a793
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -57,7 +57,11 @@ public void timedTests() throws Exception {
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());
Expand Down Expand Up @@ -125,7 +129,6 @@ public void springAndJUnitTimeouts() {
@Timed(millis = 1000)
@Retention(RetentionPolicy.RUNTIME)
private static @interface MetaTimedWithOverride {

long millis() default 1000;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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();
Expand All @@ -50,6 +54,14 @@ public int getTestFinishedCount() {
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();
Expand All @@ -65,4 +77,14 @@ public void testFinished(Description description) throws Exception {
this.testFinishedCount.incrementAndGet();
}

@Override
public void testAssumptionFailure(Failure failure) {
this.testAssumptionFailureCount.incrementAndGet();
}

@Override
public void testIgnored(Description description) throws Exception {
this.testIgnoredCount.incrementAndGet();
}

}

0 comments on commit cf7a793

Please sign in to comment.