DataSourceGeneratorAttribute
display name formatting for classes
#949
VMelnalksnis
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
Can you try in In your custom For example: [Test]
[MyGenerator]
public async Task PasswordTest(string password)
{
await Assert.That(TestContext.Current!.TestDetails.DisplayName).IsEqualTo("PasswordTest(REDACTED)");
}
public class MyGenerator : DataSourceGeneratorAttribute<string>, ITestDiscoveryEvent
{
public override IEnumerable<string> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata)
{
yield return "Super Secret Password";
}
public void OnTestDiscovery(DiscoveredTestContext discoveredTestContext)
{
discoveredTestContext.SetDisplayName($"{discoveredTestContext.TestDetails.TestName}(REDACTED)");
}
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As far as I can tell,
TUnit
just uses the argument type name in class names when aDataSourceGeneratorAttribute
is used on a class. That means that I have to create a subclass for each fixture in order for it to have a different name in the test explorer, and it limits how the name can be formatted since it has to be a valid class name. InNUnit
it is possible to change the display name withTestFixtureData.SetArgDisplayNames
, maybe something similar is possible inTUnit
?Beta Was this translation helpful? Give feedback.
All reactions