C#C
C#4w ago
TeBeCo

[xUnit v3] How to generating test data dynamically that support IAsyncLifetime

Hello, I'm trying to write an integration test "class" with multiple "test" inside (that be Theory or Fact is fine as long at it work)

What i'm trying to do is something similar to ClassData where the idea is to have a generator that returns a dynamic IEnumerable of what we could call CurrentRunData (think like a record that contains multiple properties)

Except that I want for each CurrentRunData to be usable is an IAsyncLifetime.InitializeAsync (because I need to create some infra such as container or azure specific - no there's no emulator for the part i'm trying to do)
and I also need it to be running the DisposeAsync for cleaning data

I have a list of "logical fact/test" that I want to run for each of these data emitted and the InitializeAsync depends on that CurrentRunData, currently with xUnit the ClassData and MemberData are injected at test level, which will not run InitializeAsync with it

anyone already managed to do that ?
Was this page helpful?