Skip to content
Discussion options

You must be logged in to vote

A TestContext doesn't exist before generators are run, because the data generated will create new tests. So you'd have to go for a two phased approach.

The ObjectBag in the test builder context gets passed to the test context when eventually built.

Something like this in your data generator before you yield:

dataGeneratorMetadata.TestBuilderContext.Current.ObjectBag["MyDisplayNamePrefix", "Category");

And then a custom attribute on the test like (pseudo-code):

public class CustomDisplayNamePrefixAttribute : Attribute, ITestRegisteredEventReceiver
{
    OnRegistered(TestContext context)
    {
        context.SetDisplayName(context.ObjectBag["MyDisplayNamePrefix"] + ": " + context.GetDispla…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@TheRumle
Comment options

@thomhurst
Comment options

Answer selected by TheRumle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants