-
|
In order to write output in tests with Xunit, test classes should take a dependence on public class OutputScenarios
{
private readonly ITestOutputHelper _testOutputHelper;
public OutputScenarios(ITestOutputHelper testOutputHelper)
{
_testOutputHelper = testOutputHelper;
}
[Scenario]
public void WriteToOutputScenario()
{
_testOutputHelper.WriteLine("Test");
}
}I get the following exception when executing the scenario: What am I missing? |
Beta Was this translation helpful? Give feedback.
Answered by
asbjornu
Mar 13, 2024
Replies: 1 comment
-
|
Seems like I just forgot to wrap the logging in an actual test. Rewriting it as such worked once I managed to get Rider to run the test from a fresh build and not a stale one: public class OutputScenarios
{
private readonly ITestOutputHelper _testOutputHelper;
public OutputScenarios(ITestOutputHelper testOutputHelper)
{
_testOutputHelper = testOutputHelper;
}
[Scenario]
public void WriteToOutputScenario()
{
"Write to the ITestOutputHelper".x(() =>
{
_testOutputHelper.WriteLine("Test");
});
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
asbjornu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems like I just forgot to wrap the logging in an actual test. Rewriting it as such worked once I managed to get Rider to run the test from a fresh build and not a stale one: