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

the after() function should execute after a failed test as well as after a passing test #197

Closed
dianelaw opened this issue May 28, 2015 · 5 comments

Comments

@dianelaw
Copy link

If failfast is true, it probably doesn't matter if the after function executes, but when failfast is false, it's often more important to execute cleanup steps in the after function when a test fails than when it passes.

@dianelaw
Copy link
Author

I did it by passing the after function to the function that checks failfast, prints the stack for failing tests, etc. Added the call just after the stack print

From run () (in runner .fs):
with
| ex when failureMessage <> null && failureMessage = ex.Message -> pass()
| ex -> fail ex test.Id suite.After
from fail (also in runner.fs):
let fail (ex : Exception) id after =
try
if failFast = ref true
then failed <- true
failedCount <- failedCount + 1
contextFailed <- true
let f = DateTime.Now.ToString("MMM-d_HH-mm-ss-fff")
let ss = screenshot configuration.failScreenshotPath f
reporter.fail ex id ss
after()

This would call it regardless of the value of failfast, You could call it conditionally as well.

@lefthandedgoat
Copy link
Owner

thanks I will work on getting something like this in tonight.

@dianelaw
Copy link
Author

Jeremy just added his version as a pull request too. :-) Thanks, Chris!

@lefthandedgoat
Copy link
Owner

@lefthandedgoat
Copy link
Owner

This has the fix in, 9.25 did not because I forgot to merge the change before building the package.

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

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