How to wrap all methods of a test correctly? #2666
-
|
Hey the documentation is lacking and upon inspecting the source code I haven't managed to write a proper hook to wrap all parts of a test. I am attempting to have a custom attribute that when placed on a test, suite or assembly it will dispatch all those calls on a particular thread with a custom dispatcher. Considering this class: [Dispatch]
public class DispatchedTest
{
[Before(Class)]
public static void BeforeAll()
{
}
[Before(HookType.Test)]
public void BeforeEach()
{
}
[Test]
public void Test()
{
}
[After(HookType.Test)]
public void AfterEach()
{
}
[After(Class)]
public static void AfterAll()
{
}
}I'd like all methods to be dispatched, including Before/After hooks. So far I've tried to derive from public ValueTask OnTestRegistered(TestRegisteredContext context)
{
var exec = new DispatchExecutor();
context.SetHookExecutor(exec);
context.SetTestExecutor(exec);
return default;
}and the test executor works fine, the method is invoked through my executor, however the other hooks are not triggered. It seems like Any help would be much appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Small bump to check if there is anything new about this as of the latest updates? I had tried locally with a recent version and I get the same findings, seems like I am still unable to properly wrap / dispatch actions from tests. |
Beta Was this translation helpful? Give feedback.
Sorry I missed this! Working on a fix here: #3357