TypeMock for VB.NET

I came across a recent article by Roy Osherove advising that Typemcok Isolator now has a new VB.NET unit testing API

I think that there is only one firm rule in software development – If it’s not tested then it is broken All the other rules are, in my view, suggestions. Some are very strong suggestions and you ignore them at your peril. But this rule cannot be broken. If you haven’t tested then you don’t know if your software works.

How then, should you test? There are many types of tests – unit tests, integration tests, regression tests, user acceptance tests, and so on. But it is unit tests that are the most useful for programmers. In the .Net world you normally use a tool like NUnit, MbUNit, XUnit or something similar. I have used NUnit and MbUnit and they are both great testing frameworks. I mostly use NUnit, more out of habit than anything else – I am used to it.

But the problem with unit tests is that many objects have dependencies on other objects. For example, if we have a class Order that takes a Customer as a parameter in its constructor then in order to unit test the Order class we need to construct a Customer class. The two classes cannot be tested in isolation.

This is where mock objects come to the rescue. You can create a mock customer, or a stub in this case. The order class can now be tested by calling the mock customer instead of a real customer.

There are a number of mocking frameworks around, and Typemock is considered one of the more powerful of these tools. Some people have suggested that it is too powerful, but with power comes responsibility – you just have to invest a little time learning how to use it.

Of course, a mocking framework won’t solve all of your dependency problems. You might want to look into Dependency Injection and Inversion of Control containers, but mocks are a great tool to have in your testing arsenal.

If you are interested in unit testing, and you should be, Roy Osherove has details about a new book he has written The Art of Unit Testing. I have a copy and it is a good read with a fair bit to say about using mocks and the different testing frameworks. You should also check out Typemock. Their web site has the following information:-

Programming Visual Basic applications?

Typemock have released a new version of their unit testing tool, Typemock Isolator 5.2.
This version includes a new friendly VB.NET API which makes Isolator the best Isolation tool for unit testing A Visual Basic (VB) .NET application.

Isolator now allows unit testing in VB or C# for many ‘hard to test’ technologies such as SharePoint, ASP.NET MVC, partial support for Silverlight, WPF, LINQ, WF, Entity Framework, WCF unit testing and more.

Note that the first 25 bloggers who blog this text in their blog and tell us about it, will get a Free Full Isolator license (worth $139). If you post this in a VB.NET dedicated blog, you’ll get a license automatically (even if more than 25 submit) during the first week of this announcement.

Go ahead, click the following link for more information on how to get your free license.

I don’t expect to get a free licence, I am sure that there will be 25 posts ahead of mine, and this is not a VB.NET dedicated blog. But Typemock is a good product. I have used it and I recommend that you give it a go.