I am currently developing in a solution with multiple test projects. I only wanted to run the ones that are designated as “Unit” test projects on demand. Normally I have used testing frameworks like XUnit and NUnit from a command line. The team has done an excellent job with the naming conventions of dlls, so I wrote a msbuild script that gets these dlls from the solution directory structure and runs them all via the command line.
Items of note:
- I needed to exclude the obj directory and the TestResults directory. Notice how I used an ItemGroup for excluded files.
- I place a ContinueOnError=”false” statement at the target level so I can see all tests that pass and fail.
- I added this script to run from the external tools menu in Visual Studio and deliver the results to the output window.
Ways to improve this script:
- Add a target to capture the test results so that they can be imported into a Visual Studio Test Project.
- Check the build condition and run in either Debug or Release mode. I will probably fix this sooner than later, because I am going to have to do a release build at some point. Also, the question will come up if I should even be building test projects in release mode I am sure.
- Set a property switch to fail when the first error is found
What are ways that you would change or update this script?
Get it here. RunUnitTests.msbuild
One comment
Do you want to comment?
Comments RSS and TrackBack URI
Trackbacks