Reputation: 15685
Q: Is it possible to run xunit tests side-by-side with MSTest in VS 2013? If so, what am I doing wrong?
Background:
I've migrated a .NET Solution from VS 2012 format to VS 2013.
I was unable to get the xUnit tests to work. After much troubleshooting (experimenting with project types, MS Tools versions, creating new projects with just xUnit, and experimenting with xUnit versions and dependencies), I was able to narrow the problem down to having MSTests in the same project as xUnit tests. This worked before in VS 2012.
As soon as I include just one test method marked with the [TestMethod]
attribute, none of the xUnit tests will be run. They may appear in either the VS Test Explorer, or the ReSharper Unit Test Sessions panels, but they appear with either a [!] under Not Run Tests (for Test Explorer) or [?] (for Unit Test Sessions). Having a class with the [TestClass]
attribute, but not a method marked with [TestMethod]
still allows xUnit tests to run.
It may turn out that this is a bug in an xUnit component, but I'd like to see whether anyone else has had any experience to the contrary.
Note: nearly all unit tests are based on xUnit, the MSTest is just there as a proof-of-concept to ensure that it's supported in case MSTests are to be used later.
Code Excerpts:
MSTest:
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace YYY.XXX.Test.Unit
{
[TestClass]
public class MSTests
{
[TestMethod]
public void Test_Blah()
{
Assert.AreEqual(2, 2);
}
}
}
xUnit:
using Xunit;
namespace YYY.XXX.Test.Unit
{
public class FactTests
{
[Fact]
public void Test_Blah()
{
Assert.Equal(2, 2);
}
}
}
SW Versions:
Upvotes: 6
Views: 1271
Reputation: 979
Resharper problem xunit/vstestrunner fix: (Took a long time to figure this one out too) You can get resharper 8.2 or higher.
and
Test -> Test Settings-> Uncheck Keep test execution engine running.
This should allow you to have both engines run. I think what is happening is that once one is started it stays and it's difficult to get the other to work
keyword: executor://xunit/VsTestRunner2
Upvotes: 0