thomhurst / TUnit

A modern, fast and flexible .NET testing framework
MIT License
2.4k stars 38 forks source link

Only run After hooks if the Before hooks ran. #1231

Closed thomhurst closed 5 days ago

thomhurst commented 5 days ago

@campersau Running only if we know the setups were run.

campersau commented 5 days ago

Looks like this addresses point 3 but what about point 2 from https://github.com/thomhurst/TUnit/commit/3286de308d91246e6d999dc016b883d213547116#commitcomment-149172613 ? If you have two tests one with SkipAttribute and another one manually throws a SkipTestException then the TearDown also isn't called because the SkipAttribute one does not get decreased in the instance tracker.

Because ExecuteStaticAfterHooks is only called in ExecuteTest https://github.com/thomhurst/TUnit/blob/4fb354f2b1da47537982e6c93ce82202ade94087/TUnit.Engine/Services/SingleTestExecutor.cs#L225 Which means TearDown isn't called.

thomhurst commented 5 days ago

@campersau Hopefully all better in 0.3.20