When I start all tests, response was There is no currently active test. The problem took place when ITestOutputHelper write log to output window.
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
var sb = new StringBuilder();
sb.Append(GetLogLevelString(logLevel))
.Append(" [").Append(_categoryName).Append("] ")
.Append(formatter(state, exception));
if (exception != null)
{
sb.Append('\n').Append(exception);
}
_scopeProvider.ForEachScope((scope, state) =>
{
state.Append("\n => ");
state.Append(scope);
}, sb);
**_testOutputHelper.WriteLine(sb.ToString());**
}
How to solve this problem?
I only can guess why it is so, maybe you use instance _testOutputHelper
from test not related to current test. So this instance was injected for another test which was already completed.
The reason can be different, for example:
The common symptom will be that running single test is successful but running all tests or group of tests is failed.