Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aroundAll runs even when all specs are ignored #73

Closed
greghaskins opened this issue Dec 2, 2016 · 5 comments
Closed

aroundAll runs even when all specs are ignored #73

greghaskins opened this issue Dec 2, 2016 · 5 comments
Labels

Comments

@greghaskins
Copy link
Owner

This is a low-priority one, but should probably get addressed at some point. At the moment, there isn't a simple implementation fix, because Suite objects don't know which of their children are ignored or not. I think the underlying implementation will evolve to be based more around tags anyway; fixing this issue will be simpler after that.

For reference, this is the failing test:

describe("a suite with only ignored specs", () -> {

  it("should not run aroundAll", () -> {
    ArrayList<String> steps = new ArrayList<>();
    SpectrumHelper.run(() -> {

      aroundAll(block -> {
        steps.add("aroundAll");
        block.run();
      });

      xit("foo", () -> {
      });

    });

    assertThat(steps, is(empty()));
  });

});
@greghaskins greghaskins added the bug label Dec 2, 2016
@ashleyfrieze
Copy link
Contributor

ashleyfrieze commented Dec 2, 2016

The suite should be able to tell if its children are ignored. The question is, I guess, whether it needs to be testing for ignored of direct descendants, or the whole tree.

Just add isIgnored to Child and then

// suite
boolean areChildrenIgnored() {
    return children.stream().filter(child -> !child.isIgnored()).findFirst().isPresent();
}

@ashleyfrieze
Copy link
Contributor

This will be fixed by #56 which would otherwise be doing big class-rule things with totally ignored suites.

@greghaskins
Copy link
Owner Author

@ashleyfrieze we should check if this bug still applies, or whether it was fixed by #56 .

@ashleyfrieze
Copy link
Contributor

I think this may have been fixed by #56

      describe("a suite with only ignored specs", () -> {

        it("should not run aroundAll", () -> {
          ArrayList<String> steps = new ArrayList<>();
          SpectrumHelper.run(() -> {

            aroundAll(block -> {
              steps.add("aroundAll");
              block.run();
            });

            xit("foo", () -> {
            });

          });

          assertThat(steps, is(empty()));
        });

      });

That passes - it's a test within a test. The SpectrumHelper.run wraps the real block with both ignored and aroundAll. The effect of running this is that the array list remains empty, so the hook didn't run.

I wonder if I stole this test from somewhere and made it pass while making the hooks work for JUnit mixins. I can't remember.

@greghaskins
Copy link
Owner Author

Resolved by #56.

@greghaskins greghaskins moved this from To do to Done in Spectrum Core Feb 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

2 participants