For more information about nuint and unit test, see [unit test] nuint usage and Visual Studio configuration.
Xunit is an evolutionary version of nuint. It is used in a similar way as nuint. First download and install "xunit.net runner for Visual Studio 2012 and 2013", and run the following command to add the reference package: Install-package xunit.
Test sample code:
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using Xunit; 6 7 namespace DemoTests 8 { 9 public class Test10 {11 [Fact]12 public void TestMethod()13 {14 Assert.Equal("1", "1");15 }16 }17 }
Xunit is easy to use. Unlike nuint, you only need to add the testfixture mark before the test class, but you only need to add the fact mark before the test method. Other usage methods (such as assertions) it is similar to nuint.
To use xunit in vs2012/vs2013, you only need to install the "nunit Test Adapter". The usage is similar to that of nuint. "nunit Test Adapter" currently supports the following test frameworks:
- Nunit
- Xunit.net
- Mbunit
- Qunit
- Jasmine
The installation and use of the "nunit Test Adapter" can be referred to: http://www.cnblogs.com/xishuai/p/3728576.html#xishuai_h4_3
After a solution is generated, the test cases contained in the solution are automatically detected:
Record it here.