diff --git a/config/spectrum.cleanup.xml b/config/spectrum.cleanup.xml new file mode 100644 index 0000000..d7f5122 --- /dev/null +++ b/config/spectrum.cleanup.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/greghaskins/spectrum/Parent.java b/src/main/java/com/greghaskins/spectrum/Parent.java index 643cccc..aa239ce 100644 --- a/src/main/java/com/greghaskins/spectrum/Parent.java +++ b/src/main/java/com/greghaskins/spectrum/Parent.java @@ -8,7 +8,7 @@ interface Parent { Parent NONE = new Parent() { @Override - public void focus(Child child) {} + public void focus(final Child child) {} @Override public boolean isIgnored() { diff --git a/src/main/java/com/greghaskins/spectrum/Spec.java b/src/main/java/com/greghaskins/spectrum/Spec.java index 7caa326..bc3fe62 100644 --- a/src/main/java/com/greghaskins/spectrum/Spec.java +++ b/src/main/java/com/greghaskins/spectrum/Spec.java @@ -57,6 +57,6 @@ public void focus() { @Override public void ignore() { - ignored = true; + this.ignored = true; } } diff --git a/src/test/java/given/a/spec/with/constructor/parameters/WhenDescribingTheSpec.java b/src/test/java/given/a/spec/with/constructor/parameters/WhenDescribingTheSpec.java index 504e140..c5e3a0b 100644 --- a/src/test/java/given/a/spec/with/constructor/parameters/WhenDescribingTheSpec.java +++ b/src/test/java/given/a/spec/with/constructor/parameters/WhenDescribingTheSpec.java @@ -16,7 +16,8 @@ public class WhenDescribingTheSpec { @Before public void before() throws Exception { - description = new Spectrum(Fixture.getSpecThatRequiresAConstructorParameter()).getDescription(); + this.description = + new Spectrum(Fixture.getSpecThatRequiresAConstructorParameter()).getDescription(); } @Test @@ -40,7 +41,7 @@ private Description getDescriptionForError() { } private Description getDescriptionForExplodingContext() { - return description; + return this.description; } } diff --git a/src/test/java/given/a/spec/with/constructor/parameters/WhenRunningTheSpec.java b/src/test/java/given/a/spec/with/constructor/parameters/WhenRunningTheSpec.java index 970cb29..5a67eb9 100644 --- a/src/test/java/given/a/spec/with/constructor/parameters/WhenRunningTheSpec.java +++ b/src/test/java/given/a/spec/with/constructor/parameters/WhenRunningTheSpec.java @@ -17,17 +17,17 @@ public class WhenRunningTheSpec { @Before public void before() throws Exception { - result = SpectrumRunner.run(Fixture.getSpecThatRequiresAConstructorParameter()); + this.result = SpectrumRunner.run(Fixture.getSpecThatRequiresAConstructorParameter()); } @Test public void thereIsOneFailure() throws Exception { - assertThat(result.getFailureCount(), is(1)); + assertThat(this.result.getFailureCount(), is(1)); } @Test public void theFailureExplainsWhatHappened() throws Exception { - assertThat(result.getFailures().get(0), + assertThat(this.result.getFailures().get(0), is(failure("encountered an error", UnableToConstructSpecException.class, Fixture.getSpecThatRequiresAConstructorParameter().getName()))); } diff --git a/src/test/java/given/a/spec/with/exception/in/constructor/WhenDescribingTheSpec.java b/src/test/java/given/a/spec/with/exception/in/constructor/WhenDescribingTheSpec.java index 683f987..b8a281d 100644 --- a/src/test/java/given/a/spec/with/exception/in/constructor/WhenDescribingTheSpec.java +++ b/src/test/java/given/a/spec/with/exception/in/constructor/WhenDescribingTheSpec.java @@ -16,7 +16,7 @@ public class WhenDescribingTheSpec { @Before public void before() throws Exception { - description = + this.description = new Spectrum(Fixture.getSpecThatThrowsAnExceptionInConstructor()).getDescription(); } @@ -41,7 +41,7 @@ private Description getDescriptionForError() { } private Description getDescriptionForExplodingContext() { - return description; + return this.description; } } diff --git a/src/test/java/given/a/spec/with/exception/in/constructor/WhenRunningTheSpec.java b/src/test/java/given/a/spec/with/exception/in/constructor/WhenRunningTheSpec.java index 2ed9fa9..44dac3b 100644 --- a/src/test/java/given/a/spec/with/exception/in/constructor/WhenRunningTheSpec.java +++ b/src/test/java/given/a/spec/with/exception/in/constructor/WhenRunningTheSpec.java @@ -15,17 +15,17 @@ public class WhenRunningTheSpec { @Before public void before() throws Exception { - result = SpectrumRunner.run(Fixture.getSpecThatThrowsAnExceptionInConstructor()); + this.result = SpectrumRunner.run(Fixture.getSpecThatThrowsAnExceptionInConstructor()); } @Test public void thereIsOneFailure() throws Exception { - assertThat(result.getFailureCount(), is(1)); + assertThat(this.result.getFailureCount(), is(1)); } @Test public void theFailureExplainsWhatHappened() throws Exception { - assertThat(result.getFailures().get(0), + assertThat(this.result.getFailures().get(0), is(failure("encountered an error", Fixture.SomeException.class, "kaboom"))); } diff --git a/src/test/java/given/a/spec/with/exception/in/describe/block/WhenDescribingTheSpec.java b/src/test/java/given/a/spec/with/exception/in/describe/block/WhenDescribingTheSpec.java index 704e1de..15bcfa9 100644 --- a/src/test/java/given/a/spec/with/exception/in/describe/block/WhenDescribingTheSpec.java +++ b/src/test/java/given/a/spec/with/exception/in/describe/block/WhenDescribingTheSpec.java @@ -16,7 +16,7 @@ public class WhenDescribingTheSpec { @Before public void before() throws Exception { - description = + this.description = new Spectrum(Fixture.getSpecThatThrowsAnExceptionInDescribeBlock()).getDescription(); } @@ -40,7 +40,7 @@ private Description getDescriptionForError() { } private Description getDescriptionForExplodingContext() { - return description.getChildren().get(0); + return this.description.getChildren().get(0); } } diff --git a/src/test/java/given/a/spec/with/exception/in/describe/block/WhenRunningTheSpec.java b/src/test/java/given/a/spec/with/exception/in/describe/block/WhenRunningTheSpec.java index cf8e1c9..f45c433 100644 --- a/src/test/java/given/a/spec/with/exception/in/describe/block/WhenRunningTheSpec.java +++ b/src/test/java/given/a/spec/with/exception/in/describe/block/WhenRunningTheSpec.java @@ -15,17 +15,17 @@ public class WhenRunningTheSpec { @Before public void before() throws Exception { - result = SpectrumRunner.run(Fixture.getSpecThatThrowsAnExceptionInDescribeBlock()); + this.result = SpectrumRunner.run(Fixture.getSpecThatThrowsAnExceptionInDescribeBlock()); } @Test public void thereIsOneFailure() throws Exception { - assertThat(result.getFailureCount(), is(1)); + assertThat(this.result.getFailureCount(), is(1)); } @Test public void theFailureExplainsWhatHappened() throws Exception { - assertThat(result.getFailures().get(0), + assertThat(this.result.getFailures().get(0), is(failure("encountered an error", Fixture.SomeException.class, "kaboom"))); } diff --git a/src/test/java/given/a/spec/with/nested/describe/blocks/WhenDescribingTheSpec.java b/src/test/java/given/a/spec/with/nested/describe/blocks/WhenDescribingTheSpec.java index 06ee04f..ed609d7 100644 --- a/src/test/java/given/a/spec/with/nested/describe/blocks/WhenDescribingTheSpec.java +++ b/src/test/java/given/a/spec/with/nested/describe/blocks/WhenDescribingTheSpec.java @@ -21,24 +21,24 @@ public class WhenDescribingTheSpec { public void before() throws Exception { final Description rootDescription = new Spectrum(getSpecWithNestedDescribeBlocks()).getDescription(); - mainDescription = rootDescription.getChildren().get(0); + this.mainDescription = rootDescription.getChildren().get(0); } @Test public void theMainDescriptionHasTwoContextsAsChildren() throws Exception { - assertThat(mainDescription.getChildren(), + assertThat(this.mainDescription.getChildren(), contains(Description.createSuiteDescription("with a first child context"), Description.createSuiteDescription("with a second child context"))); } @Test public void theFirstSubContextHasThreeTests() throws Exception { - assertThat(mainDescription.getChildren().get(0).getChildren(), hasSize(3)); + assertThat(this.mainDescription.getChildren().get(0).getChildren(), hasSize(3)); } @Test public void theSecondSubContextHasOneTest() throws Exception { - assertThat(mainDescription.getChildren().get(1).getChildren(), hasSize(1)); + assertThat(this.mainDescription.getChildren().get(1).getChildren(), hasSize(1)); } private static Class getSpecWithNestedDescribeBlocks() { diff --git a/src/test/java/given/a/spec/with/one/passing/test/WhenDescribingTheSpec.java b/src/test/java/given/a/spec/with/one/passing/test/WhenDescribingTheSpec.java index b2aef22..dda8693 100644 --- a/src/test/java/given/a/spec/with/one/passing/test/WhenDescribingTheSpec.java +++ b/src/test/java/given/a/spec/with/one/passing/test/WhenDescribingTheSpec.java @@ -16,17 +16,18 @@ public class WhenDescribingTheSpec { @Before public void before() throws Exception { - description = new Spectrum(Fixture.getSpecWithOnePassingTest()).getDescription(); + this.description = new Spectrum(Fixture.getSpecWithOnePassingTest()).getDescription(); } @Test public void theRootSuiteIsTheTestClass() throws Exception { - assertThat(description.getDisplayName(), is(Fixture.getSpecWithOnePassingTest().getName())); + assertThat(this.description.getDisplayName(), + is(Fixture.getSpecWithOnePassingTest().getName())); } @Test public void thereIsOneChildSuite() throws Exception { - assertThat(description.getChildren(), hasSize(1)); + assertThat(this.description.getChildren(), hasSize(1)); } @Test @@ -45,7 +46,7 @@ public void theTestNameIsCorrect() throws Exception { } private Description getFirstChildSuite() { - return description.getChildren().get(0); + return this.description.getChildren().get(0); } } diff --git a/src/test/java/given/a/spec/with/one/passing/test/WhenRunningTheSpec.java b/src/test/java/given/a/spec/with/one/passing/test/WhenRunningTheSpec.java index f2e05cc..73c70a2 100644 --- a/src/test/java/given/a/spec/with/one/passing/test/WhenRunningTheSpec.java +++ b/src/test/java/given/a/spec/with/one/passing/test/WhenRunningTheSpec.java @@ -14,17 +14,17 @@ public class WhenRunningTheSpec { @Before public void before() throws Exception { - result = SpectrumRunner.run(Fixture.getSpecWithOnePassingTest()); + this.result = SpectrumRunner.run(Fixture.getSpecWithOnePassingTest()); } @Test public void theRunCountIsOne() throws Exception { - assertThat(result.getRunCount(), is(1)); + assertThat(this.result.getRunCount(), is(1)); } @Test public void theRunIsSuccessful() throws Exception { - assertThat(result.wasSuccessful(), is(true)); + assertThat(this.result.wasSuccessful(), is(true)); } } diff --git a/src/test/java/given/a/spec/with/passing/and/failing/tests/WhenDescribingTheSpec.java b/src/test/java/given/a/spec/with/passing/and/failing/tests/WhenDescribingTheSpec.java index d664cdf..e4fcedf 100644 --- a/src/test/java/given/a/spec/with/passing/and/failing/tests/WhenDescribingTheSpec.java +++ b/src/test/java/given/a/spec/with/passing/and/failing/tests/WhenDescribingTheSpec.java @@ -18,7 +18,7 @@ public class WhenDescribingTheSpec { @Before public void before() throws Exception { - description = new Spectrum(Fixture.getSpecWithPassingAndFailingTests()).getDescription(); + this.description = new Spectrum(Fixture.getSpecWithPassingAndFailingTests()).getDescription(); } @Test @@ -45,7 +45,7 @@ public void theTestsAreInDeclarationOrder() throws Exception { } private Description getFirstContext() { - return description.getChildren().get(0); + return this.description.getChildren().get(0); } } diff --git a/src/test/java/given/a/spec/with/passing/and/failing/tests/WhenRunningTheSpec.java b/src/test/java/given/a/spec/with/passing/and/failing/tests/WhenRunningTheSpec.java index 7229c6b..d939f6c 100644 --- a/src/test/java/given/a/spec/with/passing/and/failing/tests/WhenRunningTheSpec.java +++ b/src/test/java/given/a/spec/with/passing/and/failing/tests/WhenRunningTheSpec.java @@ -18,22 +18,22 @@ public class WhenRunningTheSpec { @Before public void before() throws Exception { - result = SpectrumRunner.run(Fixture.getSpecWithPassingAndFailingTests()); + this.result = SpectrumRunner.run(Fixture.getSpecWithPassingAndFailingTests()); } @Test public void fiveTestsAreRun() throws Exception { - assertThat(result.getRunCount(), is(5)); + assertThat(this.result.getRunCount(), is(5)); } @Test public void twoTestsFail() throws Exception { - assertThat(result.getFailureCount(), is(2)); + assertThat(this.result.getFailureCount(), is(2)); } @Test public void theFailuresDescribeWhatWentWrong() throws Exception { - final List failures = result.getFailures(); + final List failures = this.result.getFailures(); assertThat(failures.get(0), is(failure("fails test 1", AssertionError.class, "failure message one"))); assertThat(failures.get(1), diff --git a/src/test/java/given/a/spec/with/passing/and/failing/tests/WhenRunningTheTests.java b/src/test/java/given/a/spec/with/passing/and/failing/tests/WhenRunningTheTests.java index e8a7e0e..08a1f73 100644 --- a/src/test/java/given/a/spec/with/passing/and/failing/tests/WhenRunningTheTests.java +++ b/src/test/java/given/a/spec/with/passing/and/failing/tests/WhenRunningTheTests.java @@ -10,6 +10,7 @@ import org.junit.runner.Runner; import org.junit.runner.notification.RunNotifier; import org.mockito.InOrder; +import org.mockito.Matchers; import org.mockito.Mockito; public class WhenRunningTheTests { @@ -21,9 +22,9 @@ public class WhenRunningTheTests { @Before public void before() throws Exception { final Runner runner = new Spectrum(Fixture.getSpecWithPassingAndFailingTests()); - runNotifier = mock(RunNotifier.class); + this.runNotifier = mock(RunNotifier.class); - runner.run(runNotifier); + runner.run(this.runNotifier); } @Test @@ -31,10 +32,10 @@ public void theStartFailureAndFinishedNotificationsAreFiredForFailingTests() thr final Description descriptionOfFailingTest = Description.createTestDescription(CONTEXT_NAME, "fails test 1"); - final InOrder inOrder = Mockito.inOrder(runNotifier); - inOrder.verify(runNotifier).fireTestStarted(descriptionOfFailingTest); - inOrder.verify(runNotifier).fireTestFailure(Mockito.any()); - inOrder.verify(runNotifier).fireTestFinished(descriptionOfFailingTest); + final InOrder inOrder = Mockito.inOrder(this.runNotifier); + inOrder.verify(this.runNotifier).fireTestStarted(descriptionOfFailingTest); + inOrder.verify(this.runNotifier).fireTestFailure(Matchers.any()); + inOrder.verify(this.runNotifier).fireTestFinished(descriptionOfFailingTest); } @Test @@ -42,9 +43,9 @@ public void theStartAndFinishedNotificationsAreFiredForPassingTests() throws Exc final Description descriptionOfPassingTest = Description.createTestDescription(CONTEXT_NAME, "passes test 3"); - final InOrder inOrder = Mockito.inOrder(runNotifier); - inOrder.verify(runNotifier).fireTestStarted(descriptionOfPassingTest); - inOrder.verify(runNotifier).fireTestFinished(descriptionOfPassingTest); + final InOrder inOrder = Mockito.inOrder(this.runNotifier); + inOrder.verify(this.runNotifier).fireTestStarted(descriptionOfPassingTest); + inOrder.verify(this.runNotifier).fireTestFinished(descriptionOfPassingTest); } } diff --git a/src/test/java/matchers/IsFailure.java b/src/test/java/matchers/IsFailure.java index 5cae3d3..dfcb55e 100644 --- a/src/test/java/matchers/IsFailure.java +++ b/src/test/java/matchers/IsFailure.java @@ -33,8 +33,9 @@ protected boolean matchesSafely(final Failure item, final Description mismatchDe describeTo(mismatchDescription, actualMethodName, actualExceptionType, actualMessage); - return methodName.equals(actualMethodName) && exceptionType.equals(actualExceptionType) - && failureMessage.equals(actualMessage); + return this.methodName.equals(actualMethodName) + && this.exceptionType.equals(actualExceptionType) + && this.failureMessage.equals(actualMessage); } private String getMethodName(final Failure failure) { @@ -50,7 +51,7 @@ private String getMethodName(final Failure failure) { @Override public void describeTo(final Description description) { - describeTo(description, methodName, exceptionType, failureMessage); + describeTo(description, this.methodName, this.exceptionType, this.failureMessage); } private void describeTo(final Description description, final String methodName,