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

nested tests run in incorrect order #8

Open
norman opened this issue Dec 8, 2011 · 0 comments
Open

nested tests run in incorrect order #8

norman opened this issue Dec 8, 2011 · 0 comments

Comments

@norman
Copy link
Owner

norman commented Dec 8, 2011

Hi,

Thanks for the work you've done on Telescope. I'm pretty new to testing frameworks, but I've enjoyed using it.

I just wanted to get in contact regarding the order in which the before and after functions are executed when nested contexts are involved.

I wrote a little script which just prints out the order things get called in and I got some weird results. When I run:

context("Outer", function()
    context("Inner", function()
        before(function() print("   before inner") end)
        after(function() print ("   after inner") end)
        test("Inner test", function() print("   test inner") end)

    end)
    before(function() print("before outer") end)
    after(function() print ("after outer")end)
    test("Outer test", function() print("test outer") end)
end)

I get the following output, which shows an odd ordering. I don't know whether my script was too contrived, but I thought I'd pass it on.

before outer
   before inner
   test inner
after outer
   after inner
before outer
test outer
after outer
------------------------------------------------------------------------
Outer:                                                               
Inner:                                                               
  Inner test                                                         [U]
Outer test                                                           [U]
------------------------------------------------------------------------

I had expected each of the set up and teardown functions to be called only once, and was surprised to see the outer after being called immediately after the inner test. Is that the expected order of execution, or is something going wrong?

I'm using the latest master branch from git hub.

Thanks,

Tom

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

No branches or pull requests

1 participant