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

after() function is not called when test fails. #200

Closed
galatrash opened this issue Jun 1, 2015 · 13 comments
Closed

after() function is not called when test fails. #200

galatrash opened this issue Jun 1, 2015 · 13 comments

Comments

@galatrash
Copy link

The test cleanup function after() is not called when a test fails. I think, it should be called regardless.

@lefthandedgoat
Copy link
Owner

I released a new version of canopy this morning which should address this

#197

@galatrash
Copy link
Author

I've checked the repository but it seems the change #197 is not merged into the master branch.

@lefthandedgoat
Copy link
Owner

You are right, I forgot to merge the pull request, I just did that and when I get home tonight I will do another build and let you know.

@galatrash
Copy link
Author

Thank you

@lefthandedgoat
Copy link
Owner

https://www.nuget.org/packages/canopy/0.9.26

That has the change in it.

@galatrash
Copy link
Author

It would be nicer to have these before/after/once/lastly to work across all the tests and not just the very first context (same as TextFixtureSetup / TextFixtureTeardown / Setup / Teardown in unit test frameworks.

@lefthandedgoat
Copy link
Owner

You want them to not be context specific?

@galatrash
Copy link
Author

That's what I suggest - across all tests (once for the very first test, lastly for the very end test, before/after for all tests).

Here is an example why they would be useful:

let stopWatch = System.Diagnostics.Stopwatch()

before (fun _ -> stopWatch.Restart())

after (fun _ ->
    stopWatch.Stop()
    let total = stopWatch.Elapsed
    printfn "Total test time: %A" total)

@lefthandedgoat
Copy link
Owner

Its like that, but its all tests within a context.

If you want to have some nice common code so that you don't have to redefine the same boring once/before/after/lastly for each context I can show you how to do that. Just take a few minutes.

@galatrash
Copy link
Author

Also context specific ones could be useful, but these should be defined inside the context itself; not the global level.

@lefthandedgoat
Copy link
Owner

This gist shows:

https://gist.github.com/lefthandedgoat/006f9282e53b9ab29f6e

F# runs the most recently defined version of a function, so by providing a new version of context in canopyExtensions and opening it after canopy and runner, we get that free default code everywhere.

Does this help accomplish what you want?

@galatrash
Copy link
Author

Yes, that's wonderful. Thank you.

@lefthandedgoat
Copy link
Owner

You are welcome, enjoy!

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

2 participants