norman/telescope — Issue #8: nested tests run in incorrect order
Author: norman
Created: 2011-12-08 13:23:49+00:00
State: open

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:

```lua
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