Skip to content

Commit

Permalink
Readjust due to Issue KentBeck/junit#426 coding style.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmichaelis committed Oct 24, 2012
1 parent 6bc83a0 commit be61237
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
50 changes: 25 additions & 25 deletions src/main/java/org/junit/rules/TestWatcher.java
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
package org.junit.rules;

import java.util.ArrayList;
import java.util.List;

import org.junit.internal.AssumptionViolatedException;
import org.junit.runner.Description;
import org.junit.runners.model.MultipleFailureException;
import org.junit.runners.model.Statement;

import java.util.ArrayList;
import java.util.List;

/**
* TestWatcher is a base class for Rules that take note of the testing
* action, without modifying it. For example, this class will keep a log of each
* passing and failing test:
* <p/>
*
* <pre>
* public static class WatchmanTest {
* private static String watchedLog;
* private static String watchedLog;
*
* &#064;Rule
* public TestWatcher watchman= new TestWatcher() {
* &#064;Override
* protected void failed(Throwable e, Description description) {
* watchedLog+= description + &quot;\n&quot;;
* }
* &#064;Rule
* public TestWatcher watchman= new TestWatcher() {
* &#064;Override
* protected void failed(Throwable e, Description description) {
* watchedLog+= description + &quot;\n&quot;;
* }
*
* &#064;Override
* protected void succeeded(Description description) {
* watchedLog+= description + &quot; &quot; + &quot;success!\n&quot;;
* &#064;Override
* protected void succeeded(Description description) {
* watchedLog+= description + &quot; &quot; + &quot;success!\n&quot;;
* }
* };
*
* &#064;Test
* public void fails() {
* fail();
* }
* &#064;Test
* public void fails() {
* fail();
* }
*
* &#064;Test
* public void succeeds() {
* &#064;Test
* public void succeeds() {
* }
* }
* </pre>
Expand Down Expand Up @@ -70,7 +70,7 @@ public void evaluate() throws Throwable {
}

private void succeededQuietly(Description description,
List<Throwable> errors) {
List<Throwable> errors) {
try {
succeeded(description);
} catch (Throwable t) {
Expand All @@ -79,7 +79,7 @@ private void succeededQuietly(Description description,
}

private void failedQuietly(Throwable t, Description description,
List<Throwable> errors) {
List<Throwable> errors) {
try {
failed(t, description);
} catch (Throwable t1) {
Expand All @@ -88,7 +88,7 @@ private void failedQuietly(Throwable t, Description description,
}

private void skippedQuietly(AssumptionViolatedException e, Description description,
List<Throwable> errors) {
List<Throwable> errors) {
try {
skipped(e, description);
} catch (Throwable t) {
Expand All @@ -97,7 +97,7 @@ private void skippedQuietly(AssumptionViolatedException e, Description descripti
}

private void startingQuietly(Description description,
List<Throwable> errors) {
List<Throwable> errors) {
try {
starting(description);
} catch (Throwable t) {
Expand All @@ -106,7 +106,7 @@ private void startingQuietly(Description description,
}

private void finishedQuietly(Description description,
List<Throwable> errors) {
List<Throwable> errors) {
try {
finished(description);
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
package org.junit.tests.experimental.rules;

import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.results.PrintableResult;
import org.junit.internal.AssumptionViolatedException;
import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;

import static junit.framework.Assert.fail;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
Expand All @@ -17,6 +9,14 @@
import static org.junit.experimental.results.ResultMatchers.hasFailureContaining;
import static org.junit.runner.JUnitCore.runClasses;

import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.results.PrintableResult;
import org.junit.internal.AssumptionViolatedException;
import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;

public class TestWatcherTest {
public static class ViolatedAssumptionTest {
private static StringBuilder watchedLog = new StringBuilder();
Expand Down Expand Up @@ -155,4 +155,4 @@ public void testWatcherFailedAndFinishedThrowsException() {
assertThat(result, hasFailureContaining("watcher failed failure"));
assertThat(result, hasFailureContaining("watcher finished failure"));
}
}
}

0 comments on commit be61237

Please sign in to comment.