Tag | NUnit Posts

This week I had a need for NUnit based unit testing against a class that depended on a provided SqlConnection. Up to this point I had been able to mock external objects and their behavior based on interfaces, but with a SqlConnection I could not mock. There are some options for mocking the SqlConnection such as TypeMock, but I needed a realistic connection to test against. This also proved as a good method for building the expected DB interface. The solution that worked best for my environment (only ...
We’ve all heard the mantra – Unit Testing is good for the soul. We hear about the goodness of things like JUnit, NUnit, and TDD from other people. But you’re not convinced. After all, it takes more time to write unit test code – and you’d rather get on with the next feature. Besides, whether it’s true or not, you certainly feel like your progress is measured by how many features you crank out. In my own journey, I found I went through three distinct stages to testing heaven. Look at my “diary” for ...
My work environment is usually an anything goes, wild west of development sort of place. There are no rules imposed, just a “get things done” attitude. Because of auditing, source control was a necessity that got added to the mix. We use SVN through VisualSVN Server and TortoiseSVN as a client. Well, as a part of self improvement and to produce better more reliable code, I’ve taken up learning TDD for myself. Our current methodology of testing here is based mostly on WTFs per minute and copious prayer. ...
Recently I blogged that the Resharper install corrupted TestDriven.Net. I followed up to say that certainly wasn't the case. In fact, there was nothing wrong with TestDriven.Net. The problem was between the keyboard and chair. I kept getting an error about not being able to load one of my base test classes. At compile time everything was fine. I would get the error only when trying to run the test in TestDriven.Net. R# could run the tests with no problem. This led me to believe it was a problem with ...
In my last post I talked about migrating from NUnit to MSTest and mentioned that there were some Assert methods that NUnit provided which did not have corresponding methods in MSTest. For reference, those unavailable Asserts are: Assert.IsNaN Assert.IsEmpty Assert.IsNotEmpty Assert.Greater Assert.GreaterOrEqual Assert.Less Assert.LessOrEqual Assert.IsAssignableFrom Assert.IsNotAssignableFrom CollectionAssert.IsEmpty CollectionAssert.IsNotEmpty StringAssert.AreEqualIgnori... StringAssert.IsMatch ...
I have been writing a lot of unit tests over the past month using the Microsoft Test (MSTest) unit testing framework that is now part of Visual Studio 2008 Professional Edition (and higher SKUs). Currently I have about 223 unit tests covering 39 classes (about 18K lines of code, 325 methods and 176 properties) with a code coverage percent of 97%. The classes that I’m testing previously had NUnit tests (although not as many as I currently have) and used NCover and NCover Explorer for my code coverage ...
This morning I was working on some unit tests, when NUnit threw this error message at me: TestBed.Trip.Construction : expected: <System.Collections.Gene... but was: <System.Collections.Gene... My girlfriend tells me that it not what I say, but HOW I say it. Maybe NUnit could sense my sarcasm. Technorati tags: NUnit ...
I'm trying to run nunit tests of a 32-bit assembly on a 64-bit machine. When I load the assembly (compiled with VS target platform set to x86) into nunit, I get a FileNotFound exception. The problem is that nunit is running as 64-bit. I found this post by Matevz Gacnik pointing me in the right direction to get around this problem. Here is the fix: You can use corflags to find out what settings the nunit assembly already has: C:\> corflags "C:\Program Files (x86)\NUnit-Net-2.0 2.2.9\bin\nunit-console.exe" ...
A very cool thing just happened. One of my classes has a 100% next to it in NCoverExplorer. Granted it's pretty much just a data store for now, but it's still 100%! Heck yes, I'm agile. If you haven't downloaded TestDriven.net, go get it now. You can right click in Visual Studio and run NUnit, debug your tests and get code coverage statistics. Technorati tags: Code Coverage, TestDriven.net, NCover, NUnit, TDD ...