Skip to content
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

Console output is completely garbled with dotnet test and xUnit #246

Open
shaynevanasperen opened this issue Mar 10, 2017 · 4 comments
Open

Comments

@shaynevanasperen
Copy link

When running dotnet test on a .NET Core Unit test project using xUnit v2.2.0, the console output of each test is interleaved with each other, resulting in a completely useless unintelligible mess, as you can see in the attached screenshot.
dotnet-test-bddfy

This probably has something to do with xUnit running tests in parallel, and the need for using ITestOutputHelper as described here, but I've looked at the code and I can't really tell where to make the fix. I think it might be the ConsoleReporter, which is configured in Processors, but there isn't a way to override this to specify that it should use xUnit's ITestOutputHelper. I'd be happy to contribute a fix for this, but I'm not sure where to start.

This only occurs when using the latest RTM tooling for .NET Core (VS2017). On my other computer which is still running VS2017 RC, I get no console output at all, except for the fully qualified method names of the methods that have the [Fact] attribute.

@robdmoore
Copy link
Member

Check out #228. See if the gist I posted and try it out to see if it works :)

@shaynevanasperen
Copy link
Author

@robdmoore Thanks. I'm busy doing that right now. But I've run into a snag. The way that xUnit works means that each of my test classes needs to declare a constructor that accepts an instance of ITestOutputHelper, and I really don't want to have to add all that noise to my tests. I'm trying to find a way of using the service locator pattern in a base class of mine, or some way of configuring it once at the assembly level so that I don't have to do this in all of my derived test classes:

public DerivedTestClass(ITestOutputHelper output) : base(output) { }

@robdmoore
Copy link
Member

robdmoore commented Mar 11, 2017 via email

@shaynevanasperen
Copy link
Author

Thanks @robdmoore

I've solved this with a library I wrote: https://github.com/shaynevanasperen/TestStack.BDDfy.Xunit

I've been a bit cheeky by naming the NuGet package with the TestStack.BDDfy prefix. If the maintainers of TestStack.BDDfy object to this, I'm happy to pass ownership to them. Hopefully this library will only be a temporary requirement, until TestStack.BDDfy natively supports Xunit parallel test execution (which might also require changes to Xunit). At least it can possibly serve as a starting point in that direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants