spectrum: Allow grouping of describe blocks using @Test annotations so IDEs can provide selective test running at suite level

How about supporting this hybrid approach? This way there won’t be too much need of fit, fdescribes etc and people will be able to use Spectrum without losing anything - Not sure if this is related to #79

    @Test
    public void something_suite() {
        describe("something",() -> {
            it("somethning", () -> {
                Assert.assertEquals(1, 1);
            });
        });
    }

If this can be done somehow I will migrate all my tests to use Spectrum!

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

h2

Sorry - used wrong markup h2 == ##

The example shown is a classic configure by config object Spring example. Don’t focus on that. The SpringClassRule of your version of Spring Test should be able to cope with the way you want to configure your test object.

@ashleyfrieze 's suggestion should get part of the way there @zifnab87, and it works out of the box. I’ve used it myself to only run a subset of tests at a time from my IDE. It may not even require the @RunWith(Enclosed.class) on the outer class depending on your setup (mine quick test didn’t need it).

JUnit5 (#68) is probably a better long-term solution for this, since that platform provides better support for alternative test runners, whereas JUnit4 very much wants a class name and a method name (which are used both for display and filter/re-run purposes). At least IntelliJ has started on proper IDE support for JUnit5.

Well well well 😃

You’ve picked on the thing which these sorts of custom test runners can’t do. You’d have the same trouble using Cucumber and all the other RSpec/Jasmie clones out there.

So your request is something like - Could there be a specialist runner for Spectrum which is compatible with selective test running in IntelliJ at suite level

It kind of looks like this:

@RunWith(SpectrumMagicRunner.class)
public class MyTests {
    @Test
    public void suite1() {
        describe("one", () -> { ... });
    }

    @Test
    public void suite2() {
        describe("two", () -> {
           it("has a spec", () -> { ... });
        });
    }

}

And you’d expect that the JUnit tree, when looking at this in IntelliJ or Eclipse, might have the tree in it:

MyTests
  suite1
     ...
  suite2
    has a spec

And your IDE UI would let you run MyTests but also re-run suite1 or suite2.

@greghaskins would this be a desirable twist on Spectrum for you? I can think of where to start to try to make it.