Tricked by the IDE, broke the build

Posted on Tue 18 September 2012 in Coding • Tagged with fail, vb.net, csharp, vs2010

Over the last year, I’ve written a fair amount of Visual Basic .NET code for a customer project. As a result, I know a lot more VB.NET than I would like to, and I’ve run into a number of peculiar behaviors, such as this one. In this …


Continue reading

One assertion per test, please

Posted on Wed 25 July 2012 in Coding • Tagged with assertion, qunit, testrules, javascript

When it comes to unit or integration tests, there are of course good ones and bad ones. There are few things more treacherous than a test suite filled with low-quality tests that don’t test what they’re supposed to, if anything at all. When the test suite goes green …


Continue reading

Regular expression multiline mode - what's a newline?

Posted on Wed 30 May 2012 in Coding • Tagged with newline, regular expressions, csharp, java

I stumbled upon an interesting little detail as I was using a regular expression in a unit test case in a C# application. I had a multiline string and was searching for a particular substring in multiline mode. The newlines in the string were Windows newlines, meaning CR followed by …


Continue reading

Testing asynchronous background workers in .NET

Posted on Tue 08 May 2012 in Coding • Tagged with async, background worker, test, .net

When you build a GUI, all lengthy operations that can be triggered by the user should take place on a background thread so that the GUI doesn’t become unresponsive. Why would it? Well, it’s because all GUI operations take place on a single thread - the GUI thread (the …


Continue reading

Abusing XML literals in VB.NET

Posted on Wed 25 April 2012 in Coding • Tagged with vb.net, format strings, xml literals

One of the things I do like about VB.NET is XML literals. Given that XML is so common, it’s really a great idea! Here’s a tiny example:

Dim x = <p>Some test.</p>

I thought I’d write about how XML literals can be abused to create …


Continue reading

Swedish to not-so-Swedish through diacritics removal

Posted on Fri 06 April 2012 in Coding • Tagged with diacritics, Swedish, unicode

According to Merriam-Webster, a diacritic is:

a mark near or through an orthographic or phonetic character or combination of characters indicating a phonetic value different from that given the unmarked or otherwise marked element

Right! :-) In the Swedish language, there are three common letters with diacritics, namely å, ä and …


Continue reading

Mocking __iter__ with a magic mock in Python

Posted on Thu 29 March 2012 in Coding • Tagged with iteration, list comprehension, magic mock, Python

I just ran into a tiny little problem and thought I’d share the solution.

I was writing some tests in which I was mocking a dependency using Mock. My test code was roughly equivalent to the following (based on an example in the Mock documentation on magic methods):

>>> sub1 …

Continue reading

Nothing surprises me in VB.NET

Posted on Tue 27 March 2012 in Coding • Tagged with nothing, null, vb.net

I currently work in a VB.NET project with a customer, and what amazes me is that I over and over again get the feeling that the language is designed to be easy to work with, but at the same time there are so many aspects of it that behave …


Continue reading

NSubstitute vs Moq - a quick comparison

Posted on Mon 27 February 2012 in Coding • Tagged with mock, moq, nsubstitute, test

When you write unit tests, you occasionally need to mock away dependencies of the subject under test (SUT). By far the easiest way to do this is to use a mocking library, which has the added benefit that it allows you to verify the behavior of the SUT by inspecting …


Continue reading

Node.js experimentation - a GitHub clone script

Posted on Thu 19 January 2012 in Coding • Tagged with async, git, node.js

Recently I wrote my first Node.js program! Yeah, yeah, I know! Late to the game and all that! But I thought it was time to catch up with the rest of the world. Better late than never, right? (Also, the program needed to parse JSON data, so JavaScript felt …


Continue reading