locked
test driven developement using mvc RRS feed

  • Question

  • User569149469 posted

    Hi,

    Any one pls guide on how to do TDD realtime using mvc and continous integration

    Wednesday, January 2, 2019 5:56 AM

Answers

  • User1520731567 posted

    Hi phmaspnet,

    To create an MVC application by using unit test, follow the below steps:

    1. Select "New Project" under the File menu in Visual Studio.

    2. Go to "Installed Templates" and click on "Visual Basic" or "C#" as per the requirement and click on "Web."

    3. Select the template of the Asp.net MVC Application.

    4. Write the same as MvcContacts.

    5. Click on OK.

    6. 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.

    7. 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.

    8. 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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 2, 2019 9:34 AM

All replies

  • User1120430333 posted

    Do you know what Test Driven Design is about that really has nothing to do with continuous integration? Do you know what Model View Controller a UI design pattern is really about?

    Wednesday, January 2, 2019 8:40 AM
  • User1520731567 posted

    Hi phmaspnet,

    To create an MVC application by using unit test, follow the below steps:

    1. Select "New Project" under the File menu in Visual Studio.

    2. Go to "Installed Templates" and click on "Visual Basic" or "C#" as per the requirement and click on "Web."

    3. Select the template of the Asp.net MVC Application.

    4. Write the same as MvcContacts.

    5. Click on OK.

    6. 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.

    7. 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.

    8. 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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 2, 2019 9:34 AM