From 2f1dead7cd3a0d43afa655bde17a223f1e650846 Mon Sep 17 00:00:00 2001 From: Wouter Oet Date: Sun, 8 Mar 2015 17:18:42 +0100 Subject: [PATCH 1/2] Suite description now add its children --- .../java/com/mscharhag/oleaster/runner/OleasterRunner.java | 6 ------ .../com/mscharhag/oleaster/runner/OleasterRunnerTest.java | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/oleaster-runner/src/main/java/com/mscharhag/oleaster/runner/OleasterRunner.java b/oleaster-runner/src/main/java/com/mscharhag/oleaster/runner/OleasterRunner.java index c9db822..4f61408 100644 --- a/oleaster-runner/src/main/java/com/mscharhag/oleaster/runner/OleasterRunner.java +++ b/oleaster-runner/src/main/java/com/mscharhag/oleaster/runner/OleasterRunner.java @@ -78,12 +78,6 @@ protected Description describeChild(Spec child) { } - @Override - public Description getDescription() { - return Description.createSuiteDescription(this.getTestClass().getJavaClass().getName()); - } - - protected SuiteBuilder createSuiteBuilder() { return new StaticSupportingSuiteBuilder(); } diff --git a/oleaster-runner/src/test/java/com/mscharhag/oleaster/runner/OleasterRunnerTest.java b/oleaster-runner/src/test/java/com/mscharhag/oleaster/runner/OleasterRunnerTest.java index 1c2e889..274eecc 100644 --- a/oleaster-runner/src/test/java/com/mscharhag/oleaster/runner/OleasterRunnerTest.java +++ b/oleaster-runner/src/test/java/com/mscharhag/oleaster/runner/OleasterRunnerTest.java @@ -52,6 +52,11 @@ public void buildTestSuite(SuiteBuilder sb) { runner = new OleasterRunner(TestClass.class); }); + it("adds the filtered children to the suite", () -> { + int numberOfChildren = runner.getDescription().getChildren().size(); + assertEquals(2, numberOfChildren); + }); + describe("when specs are obtained from the test class using getChildren()", () -> { beforeEach(() -> { From 3f865e15577febc40ca0eff55aba63a3841b90a8 Mon Sep 17 00:00:00 2001 From: Wouter Oet Date: Mon, 9 Mar 2015 11:58:00 +0100 Subject: [PATCH 2/2] Fix for bug #19 --- .../mscharhag/oleaster/matcher/matchers/ExceptionMatcher.java | 4 ++-- .../oleaster/matcher/matchers/ExceptionMatcherTest.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/oleaster-matcher/src/main/java/com/mscharhag/oleaster/matcher/matchers/ExceptionMatcher.java b/oleaster-matcher/src/main/java/com/mscharhag/oleaster/matcher/matchers/ExceptionMatcher.java index 3f95360..6e8a7b9 100644 --- a/oleaster-matcher/src/main/java/com/mscharhag/oleaster/matcher/matchers/ExceptionMatcher.java +++ b/oleaster-matcher/src/main/java/com/mscharhag/oleaster/matcher/matchers/ExceptionMatcher.java @@ -68,8 +68,8 @@ public void toThrow(Class expectedExceptionClass, Strin Arguments.ensureNotNull(expectedMessage, "expectedMessage cannot be null"); this.toThrow(expectedExceptionClass); String exceptionMessage = this.exception.getMessage(); - Expectations.expectTrue(expectedMessage.equals(exceptionMessage), - "Expected exception message '%s' but was '%s'", exceptionMessage, exceptionMessage); + Expectations.expectTrue(expectedMessage.equals(exceptionMessage), + "Expected exception message '%s' but was '%s'", expectedMessage, exceptionMessage); } private void runCodeBlock(CodeBlock block) { diff --git a/oleaster-matcher/src/test/java/com/mscharhag/oleaster/matcher/matchers/ExceptionMatcherTest.java b/oleaster-matcher/src/test/java/com/mscharhag/oleaster/matcher/matchers/ExceptionMatcherTest.java index 9b00f5f..894b249 100644 --- a/oleaster-matcher/src/test/java/com/mscharhag/oleaster/matcher/matchers/ExceptionMatcherTest.java +++ b/oleaster-matcher/src/test/java/com/mscharhag/oleaster/matcher/matchers/ExceptionMatcherTest.java @@ -32,7 +32,8 @@ public class ExceptionMatcherTest { }); it("fails if the exception message is not equal to the expected message", () -> { - TestUtil.expectAssertionError(() -> matcher.toThrow(IllegalArgumentException.class, "foo")); + String expectedMessage = "Expected exception message 'foo' but was 'test exception'"; + TestUtil.expectAssertionError(() -> matcher.toThrow(IllegalArgumentException.class, "foo"), expectedMessage); }); it("is ok if it is checked for a super class of the thrown exception", () -> {