How to test ConsoleApplications with NUnit?
-
In order to write tests you need to access the classes you want to test. Of course. So, if you have a VS.NET solution that contains (a) the project you are developing and (b) the testing classes as a class library the latter has to reference the former. But how? VS insists that everything I reference must be a .dll but at the same time my assembly must be a .exe for it to be executable. I know that I could move most of the code from the executable into a .dll and just keep a stub in the .exe but this means that I would have to keep the dll around as well when I want to run my app. Can anybody think of a better solution?
-
In order to write tests you need to access the classes you want to test. Of course. So, if you have a VS.NET solution that contains (a) the project you are developing and (b) the testing classes as a class library the latter has to reference the former. But how? VS insists that everything I reference must be a .dll but at the same time my assembly must be a .exe for it to be executable. I know that I could move most of the code from the executable into a .dll and just keep a stub in the .exe but this means that I would have to keep the dll around as well when I want to run my app. Can anybody think of a better solution?
Hi Erik, If you are using NUnit 2.0, you can create a project in your solution that creates a DLL to contain your unit tests. This will be separate from your main EXE module. Then, you can use either the console or GUI runner that NUnit provides to see the results of your unit tests. Hope this helps! Kevin "Semicolons in a programming language are like mother's milk."