Monday, April 20, 2009

Unit tests and how to trick ExpertsExchange

I'm glad I got accustomed to writing tests. It's not fully TDD, but I try to write a test as soon as possible (at least I'm not doing test-last). To never forgot writing a test I divided my IDE into two codeviews:



In the upper view is the productive code, in the lower view the corresponding unit tests. If a tests fails, I open the test result in the lower section and can navigate through the error-proven code easily.

One word on testing events (as I stumbled over it last week): with C# and anonymous methods it's quite easy to write tests for throwing events. With VB.NET not supporting anonymous methods, you have to find another way: I'm using TestContext.Properties(TestContext.TestName) = True at the moment. This code is in my event-handler and changes a TestContext-Property. I think it looks better as using a global variable.

You know ExpertsExchange? Every time I search something related to coding via Google, I get a hit for ExpertsExchange. But unfortunately, you have to pay for an answer: you only see empty boxes instead of the answer if not being a member. But thank god there is Google cache which has access for a free answer: just scroll down all the way and voilá, the boxes are filled:



By the way: I know now how to embed pictures. Google chrome doesn't show the 'upload picture'-frame immediately :/

No comments:

Post a Comment