I have a few DataAttribute
s to inject different graphics libraries into my integration tests, like so:
<code>public class InstanceDataAttribute : DataAttribute
{
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
{
var instanceDescription = new InstanceDescription
{
ApplicationName = testMethod.Name,
ApplicationVersion = new Version(),
Headless = true,
Debug = true
};
var logger = // ??? What to do here ???
yield return new object[] { new VulkanInstance(instanceDescription, logger) };
yield return new object[] { new DirectX12Instance(instanceDescription, logger) };
yield return new object[] { new MetalInstance(instanceDescription, logger) };
}
}
</code>
<code>public class InstanceDataAttribute : DataAttribute
{
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
{
var instanceDescription = new InstanceDescription
{
ApplicationName = testMethod.Name,
ApplicationVersion = new Version(),
Headless = true,
Debug = true
};
var logger = // ??? What to do here ???
yield return new object[] { new VulkanInstance(instanceDescription, logger) };
yield return new object[] { new DirectX12Instance(instanceDescription, logger) };
yield return new object[] { new MetalInstance(instanceDescription, logger) };
}
}
</code>
public class InstanceDataAttribute : DataAttribute
{
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
{
var instanceDescription = new InstanceDescription
{
ApplicationName = testMethod.Name,
ApplicationVersion = new Version(),
Headless = true,
Debug = true
};
var logger = // ??? What to do here ???
yield return new object[] { new VulkanInstance(instanceDescription, logger) };
yield return new object[] { new DirectX12Instance(instanceDescription, logger) };
yield return new object[] { new MetalInstance(instanceDescription, logger) };
}
}
These graphics libraries can provide a lot of diagnostics information through their logging APIs, and I would like to log that information to the test output. Normally I would use ITestOutputHelper
, but I don’t believe I have access to that interface from within a DataAttribute
.
What would be a good way for me to ensure that my logs end up in the test output?