This information intended to be helpful for developers working with the mojoPortal Source Code in Visual Studio 2008.

Disclaimer: I am not a practitioner of Test Driven Development. Its not my purpose here to assert that you should or should not use that approach. Suffice to say that I can see the benefits of having Unit Tests that you can run against your code whether written first or after writing the code to be tested. Its additional work to write Unit Tests any way you slice it so its more expensive and most often I can't justify the expense in the projects I'm working on. I mean ok, if you're building banking software its definitely worth the extra expense, but for blogs and forums, meh

However, in implementing ecommerce for mojoPortal, I think its prudent and worth the extra effort to write some tests for the code that processes the credit cards. I mean hey if its talking to a bank its banking software and I already said that case is justified. So today (2008-02-22) I stubbed out a new class library project, mojoPortal.UnitTests, and added the binaries for the NUnit framework under _libs/NUnit246

To make it easy to use, you need to add it as an external tool in Visual Studio. You may prefer to install it on your machine and reference the copy installed but you can just point it to the _libs/NUnit246/NUnit.exe included with mojoPortal sourcecode (only available in svn at the time of this writing). If you're working with other projects the installed approach is probably better. The instructions are the same, just the path to the .exe is different. In VS go to Tools > External Tools... and the rest of the steps are pretty much told by this screen shot:

NUnit in Visaul Studio

 

Now if you open any file in the mojoPortal.UnitTests project (just to make it the active project) then you can choose Tools > NUnit GUI to launch NUnit and run the tests.

Running NUnit

So as of this writing I haven't yet written my tests for the PaymentGateway code but now I'm setup to do so and thought it would be good to make these notes about getting setup now while its fresh on my mind.

Rate this Content 7 Votes