I would love to know if there is a way I can get Visual Studio to run unit tests corresponding to a given assembly whenever I build it.
Given a solution containing projects structured like this:
Assembly1 Assembly1.Tests Assembly2 Assembly2.Tests
Is there a way I can get the unit tests in Assembly2.Tests
to run whenever Assembly2
is built?
That would be amazing.
I'm using Visual Studio 2008 Standard Edition.
Unit testing can be done manually but is usually automated. Unit testing is a part of the test-driven development (TDD) methodology that requires developers to first write failing unit tests. Then they write code in order to change the application until the test passes.
To generate unit tests, your types must be public. Open your solution in Visual Studio and then open the class file that has methods you want to test. Right-click on a method and choose Run IntelliTest to generate unit tests for the code in your method. IntelliTest runs your code many times with different inputs.
Unit Testing is done during the development (coding phase) of an application by the developers. Unit Tests isolate a section of code and verify its correctness.
Always build the project(s) before running/debugging unit tests. Positive: always correct results, not confusing for users.
You can use the nUnit console utility to run the tests as a post-build event for the individual project.
You call the nunit-console.exe and supply your assembly containing your tests as an argument.
"C:\Program Files\NUnit 2.5.7\bin\net-2.0\nunit-console.exe" "PathToTestAssembly.dll"
or
You can run the tests in the GUI:
"C:\Program Files\NUnit 2.5.7\bin\net-2.0\nunit.exe" "PathToTestAssembly.dll" /run
Edit:
Removed the part about the post-build event for the test assembly project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With