Tuesday 29 May 2007

Nunit in action

On my new project I am implementing a proxy, in the .NET framework. Its currently in Beta (implemented 2 years ago), and is implemented in VB6. So to be more clear I have some old VB code which should be ported, updated and tested. I vote for implementing (porting) it in C#, since I like brackets and ";" and just think its a better language than VB.NET. Anyway this blog is about how I am going to use NUnit it my new C# project (which Im starting while they are making the decision).

For info on NUnit go here (Link)

I have made a new C# project in Visual Studio 2005. which should be the actual project. In this I will add a new project to be my NUnit test project called test, which should be console application. If my new project is called "Proxy" my folder structure is as follows:
My main project: \projects\Proxy
My test project: \projects\Proxy\Test

My test project be in the same namespace as the Proxy namespace otherwise the tests wont run on private methods. You may need to add the Proxy project to the NUnit test project. so it can see the methods it should test.

Now every time I make a new method, I will make one or more test methods, to test it. And a new test class for each new class.

When I have implemented a couple of lines, I compile the testcode, and run the tests in NUnit GUI.

I just found this excellent tutorial about how to use NUnitTest in vb.net (link)

No comments: