Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Can I Add a Unit Test Project to an Existing MVC3 Application (from empty template)

Tags:

I created an MVC3 application from the Empty template so I couldn´t add a Visual Studio Unit test project to the solution.

I made some changes, added some controllers and now I want to try TDD so I need to add a framework for testing.

But I can´t see how I can do that.

I want some way where I can create my test project right in the Solution Explorer, for example "website.Test" with some basic folders and files.

I saw here some questions about how to add Unit tests, but those were with xUnit.net or NUnit and I want the original VS test framework.

I am using Visual Studio 2010 Professional.

I am also interested to know what others think about the 3rd-party unit test frameworks, are they better?

What about for beginners?

like image 553
Libor Zapletal Avatar asked Jan 21 '11 14:01

Libor Zapletal


People also ask

How do I add a test project to an existing project?

Select the test project in Solution Explorer. On the Project menu, select Add Reference. In Reference Manager, select the Solution node under Projects. Select the code project you want to test, and then select OK.

How do I add unit tests to an existing Xcode project?

To add a unit test target to an existing Xcode project, choose File > New > Target. Select your app platform (iOS, macOS, watchOS, tvOS) from the top of the New Target Assistant. Select the Unit Testing Bundle target from the list of targets.


2 Answers

To add an empty Test project just go to File>Add>New Project choose Test subcategory > Test Project.

like image 125
frennky Avatar answered Sep 17 '22 13:09

frennky


The naming of the test-project is significant! If your MVC-project is named "MyProject" your test-project has to be named "MyProject.Tests" in order to connect both of them. Tools like MvcScaffolding will not work otherwise!

like image 35
Alexander Schmidt Avatar answered Sep 21 '22 13:09

Alexander Schmidt