ClassDataSource - Is it possible to have two fixtures at different scopes on the same class? #991
Answered
by
thomhurst
richardoSGSI
asked this question in
Q&A
-
For example,
|
Beta Was this translation helpful? Give feedback.
Answered by
thomhurst
Oct 23, 2024
Replies: 1 comment 2 replies
-
As part of the same instance (so injected at the same time)? Or two separate invocations, which would end up as different test cases? For the former, no. For the latter, yes, and that's what the above would do. If you did want the former, you could use property injection instead. namespace MyTests
{
public class MyTestClass
{
[ClassDataSource<MyFixture>(Shared = SharedType.Globally)]
public required MyFixture Fixture1 { get; init; }
[ClassDataSource<AnotherFixture>(Shared = SharedType.ForClass)]
public required AnotherFixture Fixture2 { get; init; }
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
richardoSGSI
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As part of the same instance (so injected at the same time)? Or two separate invocations, which would end up as different test cases?
For the former, no. For the latter, yes, and that's what the above would do.
If you did want the former, you could use property injection instead.