Permalink
Browse files

Readjust due to Issue KentBeck/junit#426 coding style.

  • Loading branch information...
mmichaelis committed Oct 24, 2012
1 parent 6bc83a0 commit be6123772ffa7bc580ea44c2db488852255c401f
@@ -1,42 +1,42 @@
package org.junit.rules; package org.junit.rules;
import java.util.ArrayList;
import java.util.List;
import org.junit.internal.AssumptionViolatedException; import org.junit.internal.AssumptionViolatedException;
import org.junit.runner.Description; import org.junit.runner.Description;
import org.junit.runners.model.MultipleFailureException; import org.junit.runners.model.MultipleFailureException;
import org.junit.runners.model.Statement; 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 * 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 * action, without modifying it. For example, this class will keep a log of each
* passing and failing test: * passing and failing test:
* <p/> *
* <pre> * <pre>
* public static class WatchmanTest { * public static class WatchmanTest {
* private static String watchedLog; * private static String watchedLog;
* *
* &#064;Rule * &#064;Rule
* public TestWatcher watchman= new TestWatcher() { * public TestWatcher watchman= new TestWatcher() {
* &#064;Override * &#064;Override
* protected void failed(Throwable e, Description description) { * protected void failed(Throwable e, Description description) {
* watchedLog+= description + &quot;\n&quot;; * watchedLog+= description + &quot;\n&quot;;
* } * }
* *
* &#064;Override * &#064;Override
* protected void succeeded(Description description) { * protected void succeeded(Description description) {
* watchedLog+= description + &quot; &quot; + &quot;success!\n&quot;; * watchedLog+= description + &quot; &quot; + &quot;success!\n&quot;;
* } * }
* }; * };
* *
* &#064;Test * &#064;Test
* public void fails() { * public void fails() {
* fail(); * fail();
* } * }
* *
* &#064;Test * &#064;Test
* public void succeeds() { * public void succeeds() {
* } * }
* } * }
* </pre> * </pre>
@@ -70,7 +70,7 @@ public void evaluate() throws Throwable {
} }
private void succeededQuietly(Description description, private void succeededQuietly(Description description,
List<Throwable> errors) { List<Throwable> errors) {
try { try {
succeeded(description); succeeded(description);
} catch (Throwable t) { } catch (Throwable t) {
@@ -79,7 +79,7 @@ private void succeededQuietly(Description description,
} }
private void failedQuietly(Throwable t, Description description, private void failedQuietly(Throwable t, Description description,
List<Throwable> errors) { List<Throwable> errors) {
try { try {
failed(t, description); failed(t, description);
} catch (Throwable t1) { } catch (Throwable t1) {
@@ -88,7 +88,7 @@ private void failedQuietly(Throwable t, Description description,
} }
private void skippedQuietly(AssumptionViolatedException e, Description description, private void skippedQuietly(AssumptionViolatedException e, Description description,
List<Throwable> errors) { List<Throwable> errors) {
try { try {
skipped(e, description); skipped(e, description);
} catch (Throwable t) { } catch (Throwable t) {
@@ -97,7 +97,7 @@ private void skippedQuietly(AssumptionViolatedException e, Description descripti
} }
private void startingQuietly(Description description, private void startingQuietly(Description description,
List<Throwable> errors) { List<Throwable> errors) {
try { try {
starting(description); starting(description);
} catch (Throwable t) { } catch (Throwable t) {
@@ -106,7 +106,7 @@ private void startingQuietly(Description description,
} }
private void finishedQuietly(Description description, private void finishedQuietly(Description description,
List<Throwable> errors) { List<Throwable> errors) {
try { try {
finished(description); finished(description);
} catch (Throwable t) { } catch (Throwable t) {
@@ -1,13 +1,5 @@
package org.junit.tests.experimental.rules; 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 junit.framework.Assert.fail;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
@@ -17,6 +9,14 @@
import static org.junit.experimental.results.ResultMatchers.hasFailureContaining; import static org.junit.experimental.results.ResultMatchers.hasFailureContaining;
import static org.junit.runner.JUnitCore.runClasses; 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 class TestWatcherTest {
public static class ViolatedAssumptionTest { public static class ViolatedAssumptionTest {
private static StringBuilder watchedLog = new StringBuilder(); private static StringBuilder watchedLog = new StringBuilder();
@@ -155,4 +155,4 @@ public void testWatcherFailedAndFinishedThrowsException() {
assertThat(result, hasFailureContaining("watcher failed failure")); assertThat(result, hasFailureContaining("watcher failed failure"));
assertThat(result, hasFailureContaining("watcher finished failure")); assertThat(result, hasFailureContaining("watcher finished failure"));
} }
} }

0 comments on commit be61237

Please sign in to comment.