-
-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Description
Using v0.56.44
.
When skipping a test with a custom skip attribute the BeforeEvery
/ AfterEvery
hooks are executed instead of being skipped. But when using SkipAttribute
directly those hooks will not be executed (as expected).
namespace tunit_constructor_runs_before_skipattribute;
public class CustomSkipAttribute(string reason) : SkipAttribute(reason)
{
public override Task<bool> ShouldSkip(TestRegisteredContext context)
{
return Task.FromResult(true);
}
}
public class Tests
{
[Test]
[Skip("Skipped with SkipAttribute")]
public void SkippedWithSkipAttributeTest()
{
Console.WriteLine("This is a skipped test using SkipAttribute");
}
[Test]
[CustomSkip("Skipped with CustomSkipAttribute")]
public void SkippedWithCustomSkipAttributeTest()
{
Console.WriteLine("This is a skipped test using CustomSkipAttribute");
}
}
public static class Hooks
{
[BeforeEvery(Test)]
public static void BeforeEveryTest(TestContext testContext)
{
Console.WriteLine("Before every test");
}
[AfterEvery(Test)]
public static void AfterEveryTest(TestContext testContext)
{
Console.WriteLine("After every test");
}
}
dotnet run -- --verbosity minimal --no-ansi
:
████████╗██╗ ██╗███╗ ██╗██╗████████╗
╚══██╔══╝██║ ██║████╗ ██║██║╚══██╔══╝
██║ ██║ ██║██╔██╗ ██║██║ ██║
██║ ██║ ██║██║╚██╗██║██║ ██║
██║ ╚██████╔╝██║ ╚████║██║ ██║
╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝
TUnit v0.56.44.0 | 64-bit | Darwin 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041 | osx-arm64 | .NET 9.0.7 | Microsoft Testing Platform v1.8.2
Engine Mode: SourceGenerated
skipped SkippedWithSkipAttributeTest (0ms)
Skipped with SkipAttribute
skipped SkippedWithCustomSkipAttributeTest (0ms)
Skipped with CustomSkipAttribute
Standard output
Before every test
After every test
Error output
Test run summary: Zero tests ran - /Users/lizalc/Programming/source/tunit-constructor-runs-before-skipattribute/bin/Debug/net9.0/tunit-constructor-runs-before-skipattribute.dll (net9.0|arm64)
total: 2
failed: 0
succeeded: 0
skipped: 2
duration: 58ms
When using v0.25.21
the hooks are not executed when using a custom skip attribute:
████████╗██╗ ██╗███╗ ██╗██╗████████╗
╚══██╔══╝██║ ██║████╗ ██║██║╚══██╔══╝
██║ ██║ ██║██╔██╗ ██║██║ ██║
██║ ██║ ██║██║╚██╗██║██║ ██║
██║ ╚██████╔╝██║ ╚████║██║ ██║
╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝
TUnit v0.25.21.0 | 64-bit | Darwin 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041 | osx-arm64 | .NET 9.0.7 | Microsoft Testing Platform v1.7.1
Engine Mode: SourceGenerated
skipped SkippedWithSkipAttributeTest (0ms)
Skipped with SkipAttribute
skipped SkippedWithCustomSkipAttributeTest (0ms)
Skipped with CustomSkipAttribute
Test run summary: Zero tests ran - /Users/lizalc/Programming/source/tunit-constructor-runs-before-skipattribute/bin/Debug/net9.0/tunit-constructor-runs-before-skipattribute.dll (net9.0|arm64)
total: 2
failed: 0
succeeded: 0
skipped: 2
duration: 38ms
Copilot
Metadata
Metadata
Assignees
Labels
No labels