Avoid Agile Fatigue

This month’s Agile Yorkshire meeting had a talk by Nick McKenna, the CEO of McKenna Consultants, on an unusual topic: There Is No Agile (text of the talk from his blog). A well spoken and engaging speaker, Nick kept it engrossing all the way. In brief, he argued that there is no such thing as an Agile way/process of doing things. Every team must reach their own ‘Agile way’ by trial and error – discard/change the practices that are not working or make sense so as to get the best value. Continue reading

Advertisements

Randomise your unit tests – lists

Following on from the previous post about benefits of randomising unit test inputs, the following deals with the unit testing of lists.
Create a list with random number of entries using the following extension method. The following uses the ForEach extension method for IEnumerable.
       public static IList ListFor(this Random random, 
            int min = MinForList, int max = MaxForList)
            where T : new()
        {
            var list = new List();
            Enumerable.Range(1, random.Next(min, max))
                      .ForEach(x => list.Add(new T()));
            return list;
        }

Continue reading

Randomise your unit tests – numeric calculations

When unit testing it’s helpful to ensure that the expected value for a unit test should not be hard coded. For numeric calculations, this usually entails creating a random set of inputs, calculating the expected value in a way that is different to how it’ll be implemented, then calling the method under test to get the actual value for comparison. This process has the added advantage of changing the inputs every time it runs, so the chances of false positive/negative are minimal.

Continue reading

A bit of reflection may help…

when unit tests call legacy code.

It can be tricky adding unit tests to your code if it calls legacy code that can’t be changed for one reason or other. In some cases, it might be possible to use reflection to your advantage.

Under consideration today are cases where the call to the legacy code can be intercepted by instantiating a private/internal variable, instance or static, which is usually checked before calling a service/database etc.

Continue reading