Often a situation faced by coders, especially when following test-driven development, is the writing of very similar test cases, changing only in, for example, the expected and actual values, along with some set up parameters. We often end up writing dozens, nay hundreds of near identical test cases, and end up with a test class that looks that it has suffered from a terminal case of copy-paste. This blog post shows a little-known technique for making this sort of test class a little more readable using the nUnit TestCase attribute.
In common with other big systems, thetrainline’s systems use a variety of technologies under the hood. Most of our code is written for the .NET framework, although there are bits of other technology stacks in there as well.
Recently, working with a project targeting version 3.5 of the .NET framework using Visual Studio, I came across a rather subtle gotcha.
Visual Studio 2010 was released in April 2010 and by default will target version 4 of the .NET framework. Version 4 of .NET came with, amongst other things, the following features.
- The Parallel extensions library.
- Dynamic dispatch.
- Named parameters.
- Optional parameters.
It was this last feature – optional parameters – that was the original source of this gotcha, leading to ‘error CS0241: Default parameter specifiers are not permitted’.
The Trainline Engineering team attended Silicon Milkroundabout 5.0, the tech hiring event held at the Old Truman Brewery on Brick Lane on Sunday, May 12th, 2013. It was a great event, well organised and with excellent turnaround of quality job seekers.
A few years ago, I was working on a project where we decided to use Selenium as our automation tool. Writing automated tests was easy and very soon we ended up copying & pasting code and at times hardcoding values in tests and using xpath to get the job done. Although such tests were quick to write and were giving us results that we wanted at the time, as our test suite grew, we could see ourselves getting into a test code maintenance nightmare. We fixed this problem by using the Page Object Design Pattern.