Reputation: 1841
I've created a bunch of unit tests for methods in my web project, but i can't make visual studio find these unit tests.
The unit tests are located in App_Code/Tests/testfile (there's multiple test files under the folder tests)
How do i make visual studio find these tests ?
I tried having a seperate unit test project at first, but i couldn't reference the web project, and therefore not call any of the methods in the .cs files under App_Code.
Upvotes: 0
Views: 1244
Reputation: 773
I agree with Mathias. It's a better design to modularize your code in layers. So you create Assemblies for example for your Business logic and your Dataaccess Logic. These are not webbased and are pretty easy to Test. You can add References to this Assemblies and test them. If you follow this approach you will have at least 3 Projects:
The WebUi Projekt references the BusinessLogic project and the BusinessLogic project references the Dataaccess projekt.
In the WebUi Project only do UI related stuff and let the BusinessLogic Layer do the work.
Hope it helps...
Upvotes: 0
Reputation: 261
Refactor the solution so that the code that you are testing is in one assembly for example Dataaccess.dll that is referenced from the web project and the test in a test project DataaccessTests that also reference the Dataaccess.dll project.
Upvotes: 1