0

I have problem with solution from this answer: https://stackoverflow.com/a/47529356/8611327

The problem is that when I use parallel testcases execution Console.WriteLine is common for all running test instances and logging is not assigned to specific testcase, so I see logs written under last testcase that have instantiated WriteLineConverter and set it as Console output:

WriteLineConverter writeLineConverter = new WriteLineConverter(_output);
Console.SetOut(writeLineConverter);

I need to use Console.WriteLine because I have a lot of nested classes like services, then access to database, sending http requests etc where I am logging timestamps and requests, I need to be able to connect theses logs with specific testcases because in parallel scenario logs from testcases are mixed.

Eventually is it possible to somehow run tests so each testcase has its separate stack of variables rather than shared stack used by all testcases?

sjanisz
  • 57
  • 8

1 Answers1

0

I have just used ITestOutputHelper and propagated reference to it thorough all constructors in my code, replacing Console outputting with ITestOutputHelper (actually I have created interface which allow me to change implementation later if required). This is not answer to my question but maybe what I wanted to achieve is not possible without major code changes/complications (otherwise such feature would be available in xunit library right away).

sjanisz
  • 57
  • 8