🦔
How to add a test project to a solution in Visual Studio 2022
A note for me of frequently used steps when you create application.
Target
- Unit test framework:
MSTest
- Mock framework:
Moq
Steps
Add Test Project
Add
-> New Project
1. Right click the solution and
MSTest
and Select, then click Next
2. Search 3. Configure the project
4. Choose latest .NET runtime and create
Connect test project
Add
-> Project reference
5. Right click the test project and
OK
6.Check the target project and click - Now you can access the target class or methods in the target project.
Install mock framework
Tools
-> NuGet Package Manager
-> Manage NuGet Packages for Solution
7. - Open NuGet package manager to install mocking tool
Browse
tab, then Search Moq
and check the test project. Click Install
after confirming if the version is latest.
8. Move
Apply
9. Click - Now you can use Moq framework in your test code.
Discussion