Skip to content

TestContext.Progress and test log/output #4287

Answered by stevenaw
dfev77 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @dfev77
To my knowledge they are different output streams to serve different use cases, but if you want to write to both easily you would likely need to code that yourself. A minimal way to do this could be define your own extension method on the TestContext class. For example, the following untested code:

public static class TestContextExtensions {
  public static void LogToProgressAndOutput(this TestContext context, string message) {
    context.Out.WriteLine(message);
    context.Progress.WriteLine(message);
  }
}

could then be invoked as

TestContext.Current.LogToProgressAndOutput("hello world");

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dfev77
Comment options

Answer selected by dfev77
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