-
Notifications
You must be signed in to change notification settings - Fork 46
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
Logs are getting mixed in Visual studio test explorer #298
Comments
For issue 1: What is the intended behaviour? A browser session per scenario? |
hi,
|
Standard output is a global resource. When running tests in parallel the standard output can't be directly associated with a test. This is a limitation of the global and can't be changed by Reqnroll. 😞 See also the related MsTest issue. You can use |
Could you share with us the code that is writing this output? |
Hi @Code-Grump we are not writing it Reqnroll is writing these output.
To if (_isThreadSafeTraceListener || _testRunnerManager.IsMultiThreaded)
this is working for MSTest and run is getting passed with proper logs as well |
@sampath-ganesan that change makes the logging synchronous so I fear that would cause other issues with massive parallelization. I have tried to reproduce the issue, but I could not. I think we are stuck with this issue. Could you please make some minimalistic repro project that shows the problem? Probably based on that we could figure out what's wrong. |
I will try to create that project |
created it and I can able to replicate it |
Thanks for creating the repro. 👍 I ran the tests locally and got similar results.
This happens because Reqnroll itself writes to the console and the console is a global resource (as described before). MSTestTraceListener:
This writes to Reqnroll/Reqnroll/Tracing/DefaultListener.cs Lines 7 to 15 in 4642769
Note that MsTest displays both standard output and If you don't like the extra writing to standard output, you can mitigate this by registering your own TraceListener: [assembly: RuntimePlugin(typeof(Plugin))]
namespace LogMixCheck.Test.Steps;
public sealed class Plugin : IRuntimePlugin
{
public void Initialize(RuntimePluginEvents runtimePluginEvents, RuntimePluginParameters runtimePluginParameters, UnitTestProviderConfiguration unitTestProviderConfiguration)
{
runtimePluginEvents.CustomizeTestThreadDependencies += RuntimePluginEvents_CustomizeTestThreadDependencies;
}
private void RuntimePluginEvents_CustomizeTestThreadDependencies(object? sender, CustomizeTestThreadDependenciesEventArgs e)
{
e.ObjectContainer.RegisterTypeAs<CustomTraceListener, ITraceListener>();
}
}
public sealed class CustomTraceListener : ITraceListener
{
private readonly IObjectContainer container;
private readonly TestContext testContext;
public CustomTraceListener(IObjectContainer container, TestContext testContext)
{
this.container = container;
this.testContext = testContext;
}
TestContext GetTestContext()
{
var contextManager = container.Resolve<IContextManager>();
var scenarioContext = contextManager.ScenarioContext;
if (scenarioContext is null)
return this.testContext;
return scenarioContext.ScenarioContainer.Resolve<TestContext>();
}
public void WriteTestOutput(string message)
{
var testContext = GetTestContext();
testContext.WriteLine(message);
}
public void WriteToolOutput(string message)
{
var testContext = GetTestContext();
testContext.WriteLine("-> " + message);
}
} I'm not sure why Reqnroll writes to standard output and Reqnroll/Plugins/Reqnroll.NUnit.ReqnrollPlugin/NUnitTraceListener.cs Lines 19 to 35 in 4642769
Perhaps we can should consider changing this? 🤔 I hope this helps. 🙂 |
Thanks for the suggestion, I will try to implement this |
Hi @obligaron, `namespace LogMixCheck.Properties
}` FYI, @gasparnagy, @ajeckmans, @Code-Grump |
Reqnroll Version
2.1.1
Which test runner are you using?
MSTest
Test Runner Version Number
3.6.0
.NET Implementation
.NET 8.0
Test Execution Method
Visual Studio Test Explorer
Content of reqnroll.json configuration file
No response
Issue Description
Steps to Reproduce
Link to Repro Project
No response
The text was updated successfully, but these errors were encountered: