If you write a Web API (I’m using this to mean any API that you call via HTTP, such as a REST API using the Microsoft Web API framework), the world it’s part of is: It’s likely that while you’re developing, Client machine = Web server machine = Database machine, but this might not be … Continue reading Testing a Web API
Category: C#
Initialising objects in C#
In C#, what is the difference between these two statements var x = new Thing{ A = 10, B = 20 }; var x = new Thing(A:10, B:20); (Notice the difference in styles of bracket, and the symbol between e.g. A and 10.) The answer is: The first is using a constructor that takes no … Continue reading Initialising objects in C#
Streaming and buffering in C# and Talend
This could also be entitled: How to make your code over 3x faster*. I love LINQ in C#, and I think that I'm not the only C# programmer who does. However, there are hidden problems to watch out for, and I'll describe one now. It is based on the difference between streaming and buffering, which … Continue reading Streaming and buffering in C# and Talend
Taming Combinatorial Explosions in SpecFlow
The Problem Imagine you are using SpecFlow to test a REST API. In the common REST way, the URL is built up of 1+ units, where each unit is one of these: Give me a list of X; Give me the instance of X that has id Y. You could easily have up to 3 … Continue reading Taming Combinatorial Explosions in SpecFlow
How to make your code 500x faster*
(*Sorry, the techniques I describe don't apply in all circumstances.) This graph shows the time taken by 8 different ways of doing exactly the same thing: retrieving the details of 20,000 orders from a database. The taller the bar, the more time it took. Unfortunately I had to use a log scale because the range … Continue reading How to make your code 500x faster*
Gluing together the bits of your SpecFlow test
In my previous post on SpecFlow, I showed how a single test case (Scenario in SpecFlow-speak) maps to many different bits of C# that will actually implement it. One scenario will often map to 3 different bits - for the Given, When and Then respectively - but if you use And to extend any of … Continue reading Gluing together the bits of your SpecFlow test
An introduction to Behaviour-Driven Testing with Cucumber / SpecFlow
BDD (Behaviour-Driven Development) evolved out of TDD (Test-Driven Development), and is an approach to testing and development in general. I have found it has benefits even if you just use it as a way of doing testing, rather than having tests drive what you develop. There are a few different frameworks that allow you to … Continue reading An introduction to Behaviour-Driven Testing with Cucumber / SpecFlow