I downloaded TestDriven.Net a free tool that integrates with Visual Studio to make Unit Testing easier. You have to register and there is a survey to take before you can download.
After installing the add-in I added my test class to the project. Previously I had been keeping it separate. I also added a reference to nunit.framework.dll in the project. After this I right clicked on the TestCalculator.cs file in the Solution Explorer and chose Run Test(s). It ran immediately and 0.11 seconds later the results were ready...
------ Test started: Assembly: calc.exe ------
18 succeeded, 0 failed, 0 skipped, took 0.11 seconds.
---------------------- Done ----------------------
But alas, no green bar! The output is just not as pretty. Well I suppose that would be difficult to do.
Then I made one of the tests fail by asserting that it would get the wrong value. Again the output was not as pretty as in NUnit.
------ Test started: Assembly: calc.exe ------
TestCase 'NUnitTest.TestClass.DisplayInitialisesToZero' failed:
String lengths differ. Expected length=2, but was length=1.
Strings differ at index 1.
expected:<"01">
but was:<"0">
------------^
d:\source\c#\calc\calc\testcalculator.cs(25,0):
at NUnitTest.TestClass.DisplayInitialisesToZero()
17 succeeded, 1 failed, 0 skipped, took 0.12 seconds.
---------------------- Done ----------------------
This gives you exactly the same information you'd get in the NUnit GUI, except there is no red/green bar. It would be nice if the output was more graphical, but even so, it is much better to have the tests running inside Visual Studio.
No comments:
Post a Comment