Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passed/failed/skipped {TestDisplayName} interprets escape characters #5133

Open
thomhurst opened this issue Feb 25, 2025 · 0 comments
Open

Comments

@thomhurst
Copy link
Contributor

Publishing a test node with a display name containing an escape character causes it to be escaped in the console output also.

internal class DummyAdapter : ITestFramework, IDataProducer
{
    public string Uid => nameof(DummyAdapter);

    public string Version => string.Empty;

    public string DisplayName => string.Empty;

    public string Description => string.Empty;

    public Type[] DataTypesProduced => [typeof(TestNodeUpdateMessage)];

    public Task<CloseTestSessionResult> CloseTestSessionAsync(CloseTestSessionContext context) => Task.FromResult(new CloseTestSessionResult { IsSuccess = true });

    public Task<CreateTestSessionResult> CreateTestSessionAsync(CreateTestSessionContext context) => Task.FromResult(new CreateTestSessionResult { IsSuccess = true });

    public async Task ExecuteRequestAsync(ExecuteRequestContext context)
    {
        for (int i = 0; i < 15; i++)
        {
            await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(new SessionUid("1"), new TestNode
            {
                Uid = $"{i}",
                DisplayName = $"Hello(\nWorld {i})",
                Properties = new PropertyBag(GetRandomState())
            }));
        }
     
        context.Complete();
    }

    private static IProperty GetRandomState()
    {
        IProperty[] states = [ PassedTestNodeStateProperty.CachedInstance, SkippedTestNodeStateProperty.CachedInstance, new FailedTestNodeStateProperty("Oops") ];
        
        Random.Shared.Shuffle(states);

        return states.First();
    }

    public Task<bool> IsEnabledAsync() => Task.FromResult(true);
}

dotnet run --output Detailed

Results in:

Image

These should probably be shown literally to avoid weird console display

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant