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

doc: uses pending in describe block / pattern to skip all tests in a describe block #610

Open
blueyed opened this issue Aug 6, 2019 · 3 comments

Comments

@blueyed
Copy link

blueyed commented Aug 6, 2019

http://olivinelabs.com/busted/ has this section:

Pending
Pending functions are placeholders for tests you plan to write (or fix) later.

describe("busted pending tests", function()
  pending("I should finish this test later")
end)

However, according to #551 (comment) this does not work.

Usually you would use pending instead of it then.
So the docs need to be fixed in this regard (I could not find them in some git repo).

Is this a good pattern to make all tests in a describe block pending then?

describe("foo", function()
  if some_condition then
    it = pending
  end
  it("works", function()
    error("foo")
  end)
end)

(in neovim/neovim@f6c9412 return was used, but that does not really make the tests pending, but only skips them)

@DorianGray
Copy link
Contributor

@Tieske wrote some tests in #583 that show that not working. It's on my list to go in and fix that =)

As long as you have test insulation enabled that will work fine. iirc you can replace describe with pending as well, but I may be mis-remembering.

@blueyed
Copy link
Author

blueyed commented Oct 17, 2019

While the it = pending trick works (but should rather be local it = pending(" (reason)"), it is different from calling pending in it still, which would add the location for the pending call.

This works quite good:

    local function pending_it(reason, it)
      return function(desc)
        it(desc, function()
          pending(desc.." ("..reason..")")
        end)
      end
    end
    local it = pending_it("reason!", it)

I think it would be good if using pending("reason") in a describe block would internally turn all it blocks into pending ones like the above, but that would break the existing behavior, where local it = pending("…") would be used.

The above pending_it function would benefit from pending therein (which is busted.pending) would be abled to handle level, similar to how busted.error does it, so that the location would be reported properly.

I think for me local it = pending(…) is better then the wrapper (pending_it), mainly because of the missing level, and that it would add additional lines for the location after all (even with adjusted level not really that useful).

@Tieske
Copy link
Member

Tieske commented Sep 24, 2020

after #636 was merged, this should now work.
Can you confirm @blueyed ? and if so, close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants