XUnit. Net Usage memorandum (1): installation and use test, xunit.net Memorandum
- Environment Installation
- Use test
- Other Instructions
Tools are indispensable. The tool is ready:
II. Environment Installation
Create a class library project for testing:
Use NuGet Package Manager to reference xUnit. Net-related Assembly
You can also use the command line in the NuGet console for quick installation.
PM> Install-Package xunit
PM> Install-Package xunit. runner. visualstudio
If you want to use ReSharper to call test cases like me, you only need to install the first xunit. If you want to use the test resource manager that comes with VS for calling, you also need to install xunit. runner. visual studio. To use ReSharper for debugging, you also need to install an extension as shown in. If your ReSharper version is 10 or later, you do not need to install this extension. It comes with support.
After the installation preparation is complete, let's test and use it as needed.
Create a new test case class and add relevant features and assertions to the method to be tested. If ReSharper is installed, click the icon on the left to make a quick call.
IV. Other Instructions
When used, the output information in the console cannot be captured and displayed in ReSharper. After studying the documents on the official website, we found that the method was replaced by ITestOutputHelper after v1.x was released to v2.x, the WriteLine of this interface can be used to output information.
Official documentation problem link: http://xunit.github.io/docs/capturing-output.html