From 0c38f6ad2a548539d5fd9765986b40f9eae6a88c Mon Sep 17 00:00:00 2001 From: Gregory Haskins Date: Sat, 30 Jan 2016 11:04:53 -0500 Subject: [PATCH 1/6] Add first test for `fit` Failing for now --- .../com/greghaskins/spectrum/Spectrum.java | 15 ++++++ src/test/java/specs/FocusedSpecs.java | 49 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/test/java/specs/FocusedSpecs.java diff --git a/src/main/java/com/greghaskins/spectrum/Spectrum.java b/src/main/java/com/greghaskins/spectrum/Spectrum.java index 6fafd39..696f224 100644 --- a/src/main/java/com/greghaskins/spectrum/Spectrum.java +++ b/src/main/java/com/greghaskins/spectrum/Spectrum.java @@ -49,6 +49,21 @@ public static void describe(final String context, final Block block) { public static void it(final String behavior, final Block block) { getCurrentContext().addTest(behavior, block); } + + /** + * Focus on this specific test, while ignoring others. + * + * @param behavior + * Description of the expected behavior + * @param block + * {@link Block} that verifies the system behaves as expected and throws a {@link java.lang.Throwable Throwable} + * if that expectation is not met. + * + * @see {@link #it(String, Block) it} + */ + public static void fit(final String behavior, final Block block) { + getCurrentContext().addTest(behavior, block); + } /** * Declare a {@link Block} to be run before each test in the current context. diff --git a/src/test/java/specs/FocusedSpecs.java b/src/test/java/specs/FocusedSpecs.java new file mode 100644 index 0000000..6a41045 --- /dev/null +++ b/src/test/java/specs/FocusedSpecs.java @@ -0,0 +1,49 @@ +package specs; + +import static com.greghaskins.spectrum.Spectrum.describe; +import static com.greghaskins.spectrum.Spectrum.fit; +import static com.greghaskins.spectrum.Spectrum.it; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import org.junit.runner.Result; +import org.junit.runner.RunWith; + +import com.greghaskins.spectrum.Spectrum; + +import helpers.SpectrumRunner; + +@RunWith(Spectrum.class) +public class FocusedSpecs {{ + + describe("Focused specs", () -> { + + it("are declared with `fit`", () -> { + Result result = SpectrumRunner.run(getSpecWithFocusedTests()); + assertThat(result.getFailureCount(), is(0)); + }); + }); + +} +private static Class getSpecWithFocusedTests() { + class Spec {{ + + describe("A spec that", () -> { + + fit("is focused and will run", () -> { + assertThat(true, is(false)); + }); + + it("is not focused and will not run", () -> { + assertThat(true, is(false)); + }); + + }); + + }} + + return Spec.class; +} +} + + From ebfbb38c1a6933bb34b4969d49b65af72aea0df9 Mon Sep 17 00:00:00 2001 From: Gregory Haskins Date: Mon, 1 Feb 2016 00:52:57 -0500 Subject: [PATCH 2/6] Support `fit` for focused specs --- .../com/greghaskins/spectrum/Spectrum.java | 8 ++--- .../java/com/greghaskins/spectrum/Suite.java | 17 ++++++++++ src/test/java/specs/FocusedSpecs.java | 31 +++++++++++-------- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/greghaskins/spectrum/Spectrum.java b/src/main/java/com/greghaskins/spectrum/Spectrum.java index 1443025..e9d5c5f 100644 --- a/src/main/java/com/greghaskins/spectrum/Spectrum.java +++ b/src/main/java/com/greghaskins/spectrum/Spectrum.java @@ -49,20 +49,20 @@ public static void describe(final String context, final Block block) { public static void it(final String behavior, final Block block) { getCurrentSuite().addSpec(behavior, block); } - + /** - * Focus on this specific test, while ignoring others. + * Focus on this specific spec, while not running others. * * @param behavior * Description of the expected behavior * @param block * {@link Block} that verifies the system behaves as expected and throws a {@link java.lang.Throwable Throwable} * if that expectation is not met. - * + * * @see {@link #it(String, Block) it} */ public static void fit(final String behavior, final Block block) { - getCurrentContext().addTest(behavior, block); + getCurrentSuite().addFocusedSpec(behavior, block); } /** diff --git a/src/main/java/com/greghaskins/spectrum/Suite.java b/src/main/java/com/greghaskins/spectrum/Suite.java index 6c3271f..dfdb818 100644 --- a/src/main/java/com/greghaskins/spectrum/Suite.java +++ b/src/main/java/com/greghaskins/spectrum/Suite.java @@ -2,7 +2,9 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.junit.runner.Description; import org.junit.runner.Runner; @@ -20,6 +22,7 @@ class Suite extends Runner { private final CompositeBlock afterEach = new CompositeBlock(); private final List children = new ArrayList(); + private final Set focusedChildren = new HashSet(); private final Description description; @@ -48,6 +51,12 @@ public Spec addSpec(final String name, final Block block) { return spec; } + public Spec addFocusedSpec(final String name, final Block block) { + final Spec spec = addSpec(name, block); + this.focusedChildren.add(spec); + return spec; + } + private void addChild(final Runner runner) { this.description.addChild(runner.getDescription()); this.children.add(runner); @@ -82,7 +91,15 @@ public void run(final RunNotifier notifier) { private void runChildren(final RunNotifier notifier) { for (final Runner child : this.children) { + runChild(child, notifier); + } + } + + private void runChild(final Runner child, final RunNotifier notifier) { + if (this.focusedChildren.isEmpty() || this.focusedChildren.contains(child)) { child.run(notifier); + } else { + notifier.fireTestIgnored(child.getDescription()); } } diff --git a/src/test/java/specs/FocusedSpecs.java b/src/test/java/specs/FocusedSpecs.java index 6a41045..22638a2 100644 --- a/src/test/java/specs/FocusedSpecs.java +++ b/src/test/java/specs/FocusedSpecs.java @@ -17,32 +17,37 @@ public class FocusedSpecs {{ describe("Focused specs", () -> { - + it("are declared with `fit`", () -> { - Result result = SpectrumRunner.run(getSpecWithFocusedTests()); + final Result result = SpectrumRunner.run(getSuiteWithFocusedTests()); assertThat(result.getFailureCount(), is(0)); }); + + it("mark siblings as ignored so they don't get forgotten", () -> { + final Result result = SpectrumRunner.run(getSuiteWithFocusedTests()); + assertThat(result.getIgnoreCount(), is(1)); + }); }); - + } -private static Class getSpecWithFocusedTests() { - class Spec {{ - +private static Class getSuiteWithFocusedTests() { + class Suite {{ + describe("A spec that", () -> { - + fit("is focused and will run", () -> { - assertThat(true, is(false)); + assertThat(true, is(true)); }); - + it("is not focused and will not run", () -> { assertThat(true, is(false)); }); - + }); - + }} - - return Spec.class; + + return Suite.class; } } From 77eb0004b9e15b7ba4ad867cc94dd657614b4ec7 Mon Sep 17 00:00:00 2001 From: Gregory Haskins Date: Mon, 1 Feb 2016 01:07:32 -0500 Subject: [PATCH 3/6] Add rudimentary `fdescribe` support --- .../com/greghaskins/spectrum/Spectrum.java | 18 +++++++- .../java/com/greghaskins/spectrum/Suite.java | 6 +++ src/test/java/specs/FocusedSpecs.java | 44 ++++++++++++++++++- 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/greghaskins/spectrum/Spectrum.java b/src/main/java/com/greghaskins/spectrum/Spectrum.java index e9d5c5f..72e413d 100644 --- a/src/main/java/com/greghaskins/spectrum/Spectrum.java +++ b/src/main/java/com/greghaskins/spectrum/Spectrum.java @@ -37,6 +37,22 @@ public static void describe(final String context, final Block block) { beginDefintion(suite, block); } + /** + * Focus on this specific suite, while ignoring others. + * + * @param context + * Description of the context for this suite + * @param block + * {@link Block} with one or more calls to {@link #it(String, Block) it} that define each expected behavior + * + * @see {@link #describe(String, Block) describe} + * + */ + public static void fdescribe(final String context, final Block block) { + final Suite suite = getCurrentSuite().addFocusedSuite(context); + beginDefintion(suite, block); + } + /** * Declare a spec, or test, for an expected behavior of the system in this suite context. * @@ -51,7 +67,7 @@ public static void it(final String behavior, final Block block) { } /** - * Focus on this specific spec, while not running others. + * Focus on this specific spec, while ignoring others. * * @param behavior * Description of the expected behavior diff --git a/src/main/java/com/greghaskins/spectrum/Suite.java b/src/main/java/com/greghaskins/spectrum/Suite.java index dfdb818..ef1279a 100644 --- a/src/main/java/com/greghaskins/spectrum/Suite.java +++ b/src/main/java/com/greghaskins/spectrum/Suite.java @@ -43,6 +43,12 @@ public Suite addSuite(final Description description) { return suite; } + public Suite addFocusedSuite(final String name) { + final Suite suite = addSuite(name); + this.focusedChildren.add(suite); + return suite; + } + public Spec addSpec(final String name, final Block block) { final CompositeBlock specBlockInContext = new CompositeBlock(Arrays.asList(this.beforeAll, this.beforeEach, block, this.afterEach)); final Description specDescription = Description.createTestDescription(this.description.getClassName(), name); diff --git a/src/test/java/specs/FocusedSpecs.java b/src/test/java/specs/FocusedSpecs.java index 22638a2..6eb9fb6 100644 --- a/src/test/java/specs/FocusedSpecs.java +++ b/src/test/java/specs/FocusedSpecs.java @@ -1,6 +1,7 @@ package specs; import static com.greghaskins.spectrum.Spectrum.describe; +import static com.greghaskins.spectrum.Spectrum.fdescribe; import static com.greghaskins.spectrum.Spectrum.fit; import static com.greghaskins.spectrum.Spectrum.it; import static org.hamcrest.MatcherAssert.assertThat; @@ -29,6 +30,20 @@ public class FocusedSpecs {{ }); }); + describe("Focused suites", () -> { + + it("are declared with `fdescribe`", () -> { + final Result result = SpectrumRunner.run(getSuiteWithFocusedSubSuites()); + assertThat(result.getFailureCount(), is(0)); + }); + + it("ignores tests that aren't focused", ()-> { + final Result result = SpectrumRunner.run(getSuiteWithFocusedSubSuites()); + assertThat(result.getIgnoreCount(), is(2)); + }); + + }); + } private static Class getSuiteWithFocusedTests() { class Suite {{ @@ -49,6 +64,33 @@ class Suite {{ return Suite.class; } -} +private static Class getSuiteWithFocusedSubSuites() { + class Suite {{ + describe("an unfocused suite", () -> { + it("is ignored", () -> { + assertThat(true, is(false)); + }); + }); + fdescribe("focused describe", () -> { + it("will run", () -> { + assertThat(true, is(true)); + }); + it("will also run", () -> { + assertThat(true, is(true)); + }); + }); + + fdescribe("another focused describe", () -> { + fit("is focused and will run", () -> { + assertThat(true, is(true)); + }); + it("is not focused and will not run", () -> { + assertThat(false, is(true)); + }); + }); + }} + return Suite.class; +} +} From 4ddb9abcc2f15eb029c8b52578120f50bd269632 Mon Sep 17 00:00:00 2001 From: Gregory Haskins Date: Mon, 1 Feb 2016 01:49:47 -0500 Subject: [PATCH 4/6] Factor away for Runner, now Child To have more interface flexibility. --- .../java/com/greghaskins/spectrum/Child.java | 14 ++++++++++++++ .../java/com/greghaskins/spectrum/Spec.java | 3 +-- .../java/com/greghaskins/spectrum/Suite.java | 19 +++++++++---------- 3 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/greghaskins/spectrum/Child.java diff --git a/src/main/java/com/greghaskins/spectrum/Child.java b/src/main/java/com/greghaskins/spectrum/Child.java new file mode 100644 index 0000000..c1a4e21 --- /dev/null +++ b/src/main/java/com/greghaskins/spectrum/Child.java @@ -0,0 +1,14 @@ +package com.greghaskins.spectrum; + +import org.junit.runner.Description; +import org.junit.runner.notification.RunNotifier; + +interface Child { + + public Description getDescription(); + + public void run(RunNotifier notifier); + + public int testCount(); + +} diff --git a/src/main/java/com/greghaskins/spectrum/Spec.java b/src/main/java/com/greghaskins/spectrum/Spec.java index b3a965a..d46b42e 100644 --- a/src/main/java/com/greghaskins/spectrum/Spec.java +++ b/src/main/java/com/greghaskins/spectrum/Spec.java @@ -1,13 +1,12 @@ package com.greghaskins.spectrum; import org.junit.runner.Description; -import org.junit.runner.Runner; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; import com.greghaskins.spectrum.Spectrum.Block; -class Spec extends Runner { +class Spec implements Child { private final Block block; private final Description description; diff --git a/src/main/java/com/greghaskins/spectrum/Suite.java b/src/main/java/com/greghaskins/spectrum/Suite.java index ef1279a..3de4db8 100644 --- a/src/main/java/com/greghaskins/spectrum/Suite.java +++ b/src/main/java/com/greghaskins/spectrum/Suite.java @@ -7,13 +7,12 @@ import java.util.Set; import org.junit.runner.Description; -import org.junit.runner.Runner; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; import com.greghaskins.spectrum.Spectrum.Block; -class Suite extends Runner { +class Suite implements Child { private final CompositeBlock beforeAll = new CompositeBlock(); private final CompositeBlock afterAll = new CompositeBlock(); @@ -21,8 +20,8 @@ class Suite extends Runner { private final CompositeBlock beforeEach = new CompositeBlock(); private final CompositeBlock afterEach = new CompositeBlock(); - private final List children = new ArrayList(); - private final Set focusedChildren = new HashSet(); + private final List children = new ArrayList(); + private final Set focusedChildren = new HashSet(); private final Description description; @@ -63,9 +62,9 @@ public Spec addFocusedSpec(final String name, final Block block) { return spec; } - private void addChild(final Runner runner) { - this.description.addChild(runner.getDescription()); - this.children.add(runner); + private void addChild(final Child child) { + this.description.addChild(child.getDescription()); + this.children.add(child); } public void beforeAll(final Block block) { @@ -96,12 +95,12 @@ public void run(final RunNotifier notifier) { } private void runChildren(final RunNotifier notifier) { - for (final Runner child : this.children) { + for (final Child child : this.children) { runChild(child, notifier); } } - private void runChild(final Runner child, final RunNotifier notifier) { + private void runChild(final Child child, final RunNotifier notifier) { if (this.focusedChildren.isEmpty() || this.focusedChildren.contains(child)) { child.run(notifier); } else { @@ -127,7 +126,7 @@ public Description getDescription() { @Override public int testCount() { int count = 0; - for (final Runner child : this.children) { + for (final Child child : this.children) { count += child.testCount(); } return count; From 765260ea1f0e96bbb3608ba9edfabf9d8230d733 Mon Sep 17 00:00:00 2001 From: Gregory Haskins Date: Mon, 1 Feb 2016 02:28:34 -0500 Subject: [PATCH 5/6] Correctly focus nested `fit` and `fdescribe` Instead of just ignoring siblings, focused specs and suites will ignore *all* other non-focused ones. --- .../java/com/greghaskins/spectrum/Child.java | 10 +-- .../java/com/greghaskins/spectrum/Parent.java | 14 ++++ .../java/com/greghaskins/spectrum/Spec.java | 9 ++- .../com/greghaskins/spectrum/Spectrum.java | 11 +-- .../java/com/greghaskins/spectrum/Suite.java | 49 +++++++------ src/test/java/specs/FocusedSpecs.java | 70 +++++++++++++++++-- 6 files changed, 127 insertions(+), 36 deletions(-) create mode 100644 src/main/java/com/greghaskins/spectrum/Parent.java diff --git a/src/main/java/com/greghaskins/spectrum/Child.java b/src/main/java/com/greghaskins/spectrum/Child.java index c1a4e21..ccd47e4 100644 --- a/src/main/java/com/greghaskins/spectrum/Child.java +++ b/src/main/java/com/greghaskins/spectrum/Child.java @@ -3,12 +3,14 @@ import org.junit.runner.Description; import org.junit.runner.notification.RunNotifier; -interface Child { +interface Child { - public Description getDescription(); + Description getDescription(); - public void run(RunNotifier notifier); + void run(RunNotifier notifier); - public int testCount(); + int testCount(); + + void focus(); } diff --git a/src/main/java/com/greghaskins/spectrum/Parent.java b/src/main/java/com/greghaskins/spectrum/Parent.java new file mode 100644 index 0000000..7b3aaae --- /dev/null +++ b/src/main/java/com/greghaskins/spectrum/Parent.java @@ -0,0 +1,14 @@ +package com.greghaskins.spectrum; + +interface Parent { + + void focus(Child child); + + static final Parent NONE = new Parent() { + + @Override + public void focus(final Child child) { + } + }; + +} diff --git a/src/main/java/com/greghaskins/spectrum/Spec.java b/src/main/java/com/greghaskins/spectrum/Spec.java index d46b42e..6b659c0 100644 --- a/src/main/java/com/greghaskins/spectrum/Spec.java +++ b/src/main/java/com/greghaskins/spectrum/Spec.java @@ -10,11 +10,13 @@ class Spec implements Child { private final Block block; private final Description description; + private final Parent parent; - public Spec(final Description description, final Block block) { + public Spec(final Description description, final Block block, final Parent parent) { this.description = description; this.block = block; + this.parent = parent; } @Override @@ -39,4 +41,9 @@ public int testCount() { return 1; } + @Override + public void focus() { + this.parent.focus(this); + } + } diff --git a/src/main/java/com/greghaskins/spectrum/Spectrum.java b/src/main/java/com/greghaskins/spectrum/Spectrum.java index 72e413d..77a3aa0 100644 --- a/src/main/java/com/greghaskins/spectrum/Spectrum.java +++ b/src/main/java/com/greghaskins/spectrum/Spectrum.java @@ -45,11 +45,12 @@ public static void describe(final String context, final Block block) { * @param block * {@link Block} with one or more calls to {@link #it(String, Block) it} that define each expected behavior * - * @see {@link #describe(String, Block) describe} + * @see #describe(String, Block) * */ public static void fdescribe(final String context, final Block block) { - final Suite suite = getCurrentSuite().addFocusedSuite(context); + final Suite suite = getCurrentSuite().addSuite(context); + suite.focus(); beginDefintion(suite, block); } @@ -75,10 +76,10 @@ public static void it(final String behavior, final Block block) { * {@link Block} that verifies the system behaves as expected and throws a {@link java.lang.Throwable Throwable} * if that expectation is not met. * - * @see {@link #it(String, Block) it} + * @see #it(String, Block) */ public static void fit(final String behavior, final Block block) { - getCurrentSuite().addFocusedSpec(behavior, block); + getCurrentSuite().addSpec(behavior, block).focus(); } /** @@ -163,7 +164,7 @@ private Value(final T value) { public Spectrum(final Class testClass) { final Description description = Description.createSuiteDescription(testClass); - this.rootSuite = new Suite(description); + this.rootSuite = Suite.rootSuite(description); beginDefintion(this.rootSuite, new ConstructorBlock(testClass)); } diff --git a/src/main/java/com/greghaskins/spectrum/Suite.java b/src/main/java/com/greghaskins/spectrum/Suite.java index 3de4db8..733c161 100644 --- a/src/main/java/com/greghaskins/spectrum/Suite.java +++ b/src/main/java/com/greghaskins/spectrum/Suite.java @@ -12,7 +12,7 @@ import com.greghaskins.spectrum.Spectrum.Block; -class Suite implements Child { +class Suite implements Parent, Child { private final CompositeBlock beforeAll = new CompositeBlock(); private final CompositeBlock afterAll = new CompositeBlock(); @@ -24,17 +24,19 @@ class Suite implements Child { private final Set focusedChildren = new HashSet(); private final Description description; + private final Parent parent; - public Suite(final Description description) { - this.description = description; + public static Suite rootSuite(final Description description) { + return new Suite(description, Parent.NONE); } - public Suite addSuite(final String name) { - return addSuite(Description.createSuiteDescription(name)); + private Suite(final Description description, final Parent parent) { + this.description = description; + this.parent = parent; } - public Suite addSuite(final Description description) { - final Suite suite = new Suite(description); + public Suite addSuite(final String name) { + final Suite suite = new Suite(Description.createSuiteDescription(name), this); suite.beforeAll(this.beforeAll); suite.beforeEach(this.beforeEach); suite.afterEach(this.afterEach); @@ -42,23 +44,14 @@ public Suite addSuite(final Description description) { return suite; } - public Suite addFocusedSuite(final String name) { - final Suite suite = addSuite(name); - this.focusedChildren.add(suite); - return suite; - } - public Spec addSpec(final String name, final Block block) { - final CompositeBlock specBlockInContext = new CompositeBlock(Arrays.asList(this.beforeAll, this.beforeEach, block, this.afterEach)); final Description specDescription = Description.createTestDescription(this.description.getClassName(), name); - final Spec spec = new Spec(specDescription, specBlockInContext); - addChild(spec); - return spec; - } - public Spec addFocusedSpec(final String name, final Block block) { - final Spec spec = addSpec(name, block); - this.focusedChildren.add(spec); + final CompositeBlock specBlockInContext = new CompositeBlock( + Arrays.asList(this.beforeAll, this.beforeEach, block, this.afterEach)); + + final Spec spec = new Spec(specDescription, specBlockInContext, this); + addChild(spec); return spec; } @@ -83,6 +76,12 @@ public void afterEach(final Block block) { this.afterEach.addBlock(block); } + @Override + public void focus(final Child child) { + this.focusedChildren.add(child); + focus(); + } + @Override public void run(final RunNotifier notifier) { if (this.testCount() == 0) { @@ -112,7 +111,8 @@ private void runAfterAll(final RunNotifier notifier) { try { this.afterAll.run(); } catch (final Throwable e) { - final Description failureDescription = Description.createTestDescription(this.description.getClassName(), "error in afterAll"); + final Description failureDescription = Description.createTestDescription(this.description.getClassName(), + "error in afterAll"); this.description.addChild(failureDescription); notifier.fireTestFailure(new Failure(failureDescription, e)); } @@ -132,4 +132,9 @@ public int testCount() { return count; } + @Override + public void focus() { + this.parent.focus(this); + } + } diff --git a/src/test/java/specs/FocusedSpecs.java b/src/test/java/specs/FocusedSpecs.java index 6eb9fb6..6af5578 100644 --- a/src/test/java/specs/FocusedSpecs.java +++ b/src/test/java/specs/FocusedSpecs.java @@ -20,14 +20,24 @@ public class FocusedSpecs {{ describe("Focused specs", () -> { it("are declared with `fit`", () -> { - final Result result = SpectrumRunner.run(getSuiteWithFocusedTests()); + final Result result = SpectrumRunner.run(getSuiteWithFocusedSpecs()); assertThat(result.getFailureCount(), is(0)); }); it("mark siblings as ignored so they don't get forgotten", () -> { - final Result result = SpectrumRunner.run(getSuiteWithFocusedTests()); + final Result result = SpectrumRunner.run(getSuiteWithFocusedSpecs()); assertThat(result.getIgnoreCount(), is(1)); }); + + describe("when nested in a separate suite", () -> { + + it("cause specs in other suites to be ignored", () -> { + final Result result = SpectrumRunner.run(getSuiteWithNestedFocusedSpecs()); + assertThat(result.getFailureCount(), is(0)); + assertThat(result.getIgnoreCount(), is(1)); + }); + }); + }); describe("Focused suites", () -> { @@ -42,10 +52,18 @@ public class FocusedSpecs {{ assertThat(result.getIgnoreCount(), is(2)); }); + describe("when nested", () -> { + it("cause specs in other suites to be ignored", () -> { + final Result result = SpectrumRunner.run(getSuiteWithNestedFocusedSuites()); + assertThat(result.getFailureCount(), is(0)); + assertThat(result.getIgnoreCount(), is(1)); + }); + }); + }); } -private static Class getSuiteWithFocusedTests() { +private static Class getSuiteWithFocusedSpecs() { class Suite {{ describe("A spec that", () -> { @@ -59,11 +77,27 @@ class Suite {{ }); }); - }} return Suite.class; } + +private static Class getSuiteWithNestedFocusedSpecs() { + class Suite {{ + + it("should not run because it isn't focused", () -> { + assertThat(true, is(false)); + }); + + describe("a nested context", () -> { + fit("is focused and will run", () -> { + assertThat(true, is(true)); + }); + }); + }} + return Suite.class; +} + private static Class getSuiteWithFocusedSubSuites() { class Suite {{ describe("an unfocused suite", () -> { @@ -93,4 +127,32 @@ class Suite {{ }} return Suite.class; } + +private static Class getSuiteWithNestedFocusedSuites() { + class Suite {{ + + describe("an unfocused suite", () -> { + it("should not run because it isn't focused", () -> { + assertThat(true, is(false)); + }); + }); + + describe("a nested context", () -> { + + fdescribe("with a focused sub-suite", () -> { + it("is focused and will run", () -> { + assertThat(true, is(true)); + }); + }); + }); + + describe("another nested context", () -> { + fit("with a focused spec", () -> { + assertThat(true, is(true)); + }); + }); + }} + return Suite.class; +} + } From 632c47acf128e93372e23fa0658db628375dc0ca Mon Sep 17 00:00:00 2001 From: Gregory Haskins Date: Mon, 1 Feb 2016 02:46:29 -0500 Subject: [PATCH 6/6] Add supported feature list to README --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 4513ddf..5b74a6a 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,21 @@ public class ExampleSpec {{ }} ``` +## Supported Features + +Spectrum moving toward a `1.0` release with close alignment to Jasmine's API. The library already supports a nice subset of those features: + +- [x] `describe` +- [x] `it` +- [x] `beforeEach` / `afterEach` +- [x] `beforeAll` / `afterAll` +- [x] `fit` / `fdescribe` +- [ ] `xit` / `xdescribe` + +### Non-Features + +Unlike some BDD-style frameworks, Spectrum is _only_ a test runner. Assertions, expectations, mocks, and matchers are the purview of other libraries. + ## Getting Started Spectrum is available as a [package on jCenter](https://bintray.com/greghaskins/maven/Spectrum/view), so make sure you have jCenter declared as a repository in your build config. Future inclusion in Maven Central (see [#12](https://github.com/greghaskins/spectrum/issues/12)) will make this even easier.