User1520731567 posted
Hi phmaspnet,
To create an MVC application by using unit test, follow the below steps:
-
Select "New Project" under the File menu in Visual Studio.
-
Go to "Installed Templates" and click on "Visual Basic" or "C#" as per the requirement and click on "Web."
-
Select the template of the Asp.net MVC Application.
-
Write the same as MvcContacts.
-
Click on OK.
-
As soon as the dialog box for Unit Test Project appears, ensure that "Yes" is selected and then select OK. The Visual Studio will create two solutions containing two projects, the first one as MvcContacts and the other named as MvcContacts.Tests.
-
Go the Test menu and select "Run" and then click on "All Tests of Solution." Results will be displayed in the Window of Test results. All tests are passed.
-
Now go to the project of MvcContacts.Tests and analyze the account controller classes for the test and the model. These classes describe the ways of creating the mock interfaces.
More details,you could refer to these links:
https://dzone.com/articles/using-tdd-approach-in-mvc
https://www.c-sharpcorner.com/article/test-driven-development-tdd-using-mvc-web-application3/
Best Regards.
Yuki Tao