

In Solution Explorer, right-click the Dependencies node of the StringLibraryTest project and select Add Project Reference from the context menu. It applies the TestMethodAttribute attribute to define TestMethod1 in C# or TestSub in Visual Basic.Įach method tagged with in a test class tagged with is executed automatically when the unit test is run.įor the test project to work with the StringLibrary class, add a reference in the StringLibraryTest project to the StringLibrary project.It applies the TestClassAttribute attribute to the UnitTest1 class.It imports the namespace, which contains the types used for unit testing.The source code created by the unit test template does the following: If the language you want to use is not shown, change the language selector at the top of the page.

Visual Studio creates the project and opens the class file in the code window with the following code.

NET 6 (Long-term support) in the Framework box. On the Additional information page, select. On the Configure your new project page, enter StringLibraryTest in the Project name box. Choose C# or Visual Basic from the Language list, and then choose All platforms from the Platform list.Ĭhoose the MSTest Test Project template, and then choose Next. On the Add a new project page, enter mstest in the search box. Right-click on the solution in Solution Explorer and select Add > New project.

NET class library using Visual Studio.Īdd a new unit test project named "StringLibraryTest" to the solution. Open the ClassLibraryProjects solution you created in Create a. MSTest is one of three test frameworks you can choose from. Unit tests provide automated software testing during your development and publishing. This tutorial works with the solution that you create in Create a.This tutorial shows how to automate unit testing by adding a test project to a solution.
