My current project requires xunit for unit testing. I’m used to mstest as it is build into visual studio, but xunit integration is transparent with the extension installed.
Setup
To get xUnit working with the Test explorer install the xUnit.net runner extension. Also install the xUnit package from nuget for your project. Now you’re good to go.
Visual Studio has support for snippets. I added the factm snippet to expand to a method with the Fact attribute on it. Download my snippet from here.
Thoughts
I’m missing the Assert.Inconclusive method for reminding me about incomplete tests. Also I must stop clicking New Unittest and start creating New Class.
Where mstest uses an ExpectedException attribute, xunit uses Asserts.Throws. This makes the code more readable.
Xunit has Assert.Contains to check strings for containing a string. I was doing a check for true on string.Contains, the xunit method is shorter. Short is good 😉