Reputation: 4028
I'm brand new to Unit Testing, fresh out of college, and suddenly responsible for developing and maintaining a fairly large application by myself. The previous developer (who just left the company) included NUnit with the project references, wrote a few empty test fixtures at the bottom of a couple classes, and never did anything else with it.
I'm afraid if I don't start writing unit tests now, while I'm refactoring and learning the system, I'll never get them done, but I'm having trouble understanding how to properly set up my test project.
I was told that I should keep my test project as a separate Class Library
within the same solution, so I've made an OurApplication.Test Library project. I don't know how I reference the project that I'll be testing within it, though.
Guides online say to point it to my main project's .DLL... but there isn't one. Our project is a standalone application that doesn't generate a dll, and I'm not sure what I'm supposed to do in this case.
Any advice on what's wrong here, or pointers to more comprehensive guides would be greatly appreciated. I'd like to get this done the right way, and as soon as I can.
Upvotes: 5
Views: 2321
Reputation: 7814
If you're using Visual Studio you can add references to Projects within the solution as here referencing a console application from a test project
Upvotes: 5
Reputation: 1905
Ideally it is best to separate your applications into separate dlls which based of functionalities , I.e. separating the solution into modules represented by projects of type class libraries. This will make it simpler to test these dlls separately. I usually have separate test project for each module (projects).
Having said that you can add a .exe project as a reference to your nun it project and get access to all namespaces and classes to test, though not best practice for maintainable code.
Upvotes: 4