-
-
Notifications
You must be signed in to change notification settings - Fork 96
Closed
Description
Sorry, I don't know did you see my comment here so I duplicate it as new issue
In 0.24 you've added property injection into ClassDataSource classes. Thank you very much!
But there are wrong dispose call in perAssembly shared class. Here is code structure:
[ClassDataSource<MyFactory>(Shared = SharedType.PerClass)]
[NotInParallel]
public class MyTests1(MyFactory factory)
{
...
}
[ClassDataSource<MyFactory>(Shared = SharedType.PerClass)]
[NotInParallel]
public class MyTests2(MyFactory factory)
{
...
}
public class MyFactory : IAsyncInitializer, IAsyncDisposable
{
[ClassDataSource<MyServer>(Shared = SharedType.PerAssembly)]
public required MyServer Server { get; init; }
...
}
public class MyServer : IAsyncInitializer, IAsyncDisposable
{
...
}
I run MyTests1 and MyTests2 in one session:
- MyServer initializes 1 time (expected)
- MyFactory initializes 2 times (expected)
When ONE test class finished:
- MyFactory disposes 1 time (expected)
- MyServer disposes 1 time (unexpected!)
Expected: MyServer.Dispose calls only after disposing all MyFactory classes
PS: when inject MyServer into test classes dispose works correctly
bazarniy
Metadata
Metadata
Assignees
Labels
No labels