Saturday 31 December 2011

Kanbanery – Simple work management to keep you moving


Kanbanery is a great tool for managing tasks, your work load, and, of course, your Kanban process. Based on Kanban principles, it gives you a solid way to manage tasks for both solo and group work. With just three states you get a very clear view of what needs doing, what is being done, and what is done.

The tools simplicity focuses you on what is really important in your current work load. The price plan includes a free version that allows two people to collaborate on a project, whilst other very reasonably priced plans easily open this up to small and large teams.

Well worth a look. Check it out here – www.Kanbanery.com


Wednesday 28 December 2011

Automate a soap web service using c#

In web service rich systems you can leverage the interfaces that these services provide and test as much of the system as possible. Web Services give you a great opportunity to do quick regression and integration testing of business logic without going through a front end system or creating complicated test harnesses across your system. Automation at this level is extremely valuable to any deployment pipeline.

This quick example shows you how to:
  • Automate a web service with a soap binding using Visual Studio and c# 
  • Set up a simple test framework using NUnit
Automating the web service

For this example we are going to use this banking utility api from http://www.ibanbic.be  that provides several IBAN and BIC conversion facilities. The service uses the soap protocol.

To begin with we need to create a new class library project in visual studio with a references to NUnit. Download NUnit here if you don't have it. You will need to add the following reference  ..\ NUnit-2.5.10.11092\bin\net-2.0\framework\nunit.framework.dll. You may also need to add System.ServiceModel as well.

Once all the references are added we then need to create a c# proxy client class based on the contract (wsdl) of the target web service. We do this using ms svcutil, which you can read more about here.

Once the proxy client class is created add it to the VS project. During the process of creating this proxy client class, an app.config file should have been created as well. Add this to the project.

ProjectName\Services\proxyClient.cs

Invoking the web service

If you don't know how the service works, use a tool like soapUI to interrogate the different requests and responses. This will allow you to become familiar with the data required to be sent with a request, and the expected response.

For this example we are going to invoke the service and use the calculateIBAN1 operation which takes two parameters ISOCountry and account to return an IBAN number.

The code is very simple. I've placed a method inside a class called converters.cs which sits inside a solution folder called modules.



namespace WebServiceAutomationSOAP.Modules
{
    class Converters
    {

        public string CalculateIBAN(string isoCode, string account)
        {

            try
            {
                BANBICSoapClient client = new BANBICSoapClient("IBANBICSoap");
                string iban = client.calculateIBAN1(isoCode, account);
                return iban;
            }
            catch (Exception e)
            {

                return e.ToString();
            }

        }


    }
}


We can now call this method and return either an iban number or an exception.

Setting up the test framework

As with many other examples on this blog, the test framework uses NUnit and separates out business logic from test logic using module classes for business, and test classes for tests. As we saw above we created a module class called converters.cs. Each module class has a corresponding test class.

Create a class called ConverterTests.cs and place it in a solution folder called Tests. Inside this class we will create two tests, one that tests for the correct IBAN creation, and another to check that the correct exception is thrown.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
namespace WebServiceAutomationSOAP
{
    [TestFixture]
    public class Class1
    {

        [SetUp]
        public void SetUp()
        {
     
        // Do some set up configuration here
        }
     
        [Test]
        public testCorrectIBANIsCreatedUsingCalculateIBAN1()
        {

            string expectedIBAN = "IBAN ES44 0000 0333 0000 0000 3434";
            Modules.Converters converters = new Modules.Converters();
            Assert.AreEqual(expectedIBAN, converters.GetIBAN("ES", "000003333434"));

        }


        [Test]
        public testCorrectExceptionIsCreatedWhenIncorrectBankCodeIsUsedWithCalculateIBAN1()
        {

            string expectedException = "This is the expected exception";
            Modules.Converters converters = new Modules.Converters();
            Assert.AreEqual( expectedException , converters.GetIBAN("ES", "cwsaSDFASD"));

        }


        [TearDown]
        public void TearDown()
        {
     
            // Clean up here
     
        }
     
    }
}

Expanding the idea

Once you have this simple test framework in place you can begin to build a suite of tests around a web service very easily. To expand this further you can think about placing the creation of the web service client in the constructor of a base class that can then be inherited by all module classes.

You could also add data driving by using either a constants class, an application configuration file, or a library such as FileHelpers to manage excel or text files.

Of course, soap is not the only webservice type out there. RESTful services have become much more widespread with google, yahoo, twitter adopting these over soap services.  I will give some examples soon of how to automate these!

Monday 12 December 2011

Engineering Support Teams (DevOps)


In agile environments, product owners that aren't in touch with development or who are not familiar with engineering practices always seem to push out of the backlog those technical stories that are required for a successful project.

Sometimes we need technical stories that allocate time to set up a CI project, or create a mocking framework, or create an environment, or some automated deployment scripts in order to continue developing and releasing a project. When we don’t have these mechanisms in place, we need to hope that we have a team that can pick up the functionality as we fire it out and position it into the deployment pipeline so that it will drop out happily into production.

Without these technical stories and engineering practices in place, the cycle time (time between conception and release of a story) climbs and we either never release, or if we do release, it’s a pressurised situation of manic updates done manually on live servers by technicians that may have no idea about the code they are deploying.

If you have multiple teams or programmes, and if you have the budget, an engineering support team is essential. This is a team that engages primarily in DevOps, but will also be domain experts capable of taking a holistic view of the project and identify any unforeseen issues.

You will often see this team type in large organisations, but in those organisations which may need them the most, i.e. those start ups that need to be capable of continuous delivery to keep ahead of the competition, it is usually never seen due to the difficulty in justifying a couple of heads working on technical stories instead of functionality. It takes a really technically savvy manager to understand and sell their worth to the business.

If you don’t have this team, and you are not afforded the necessary time to do technical user stories in your sprints or iterations, then you need to think outside of the box and form a group that can focus on these software engineering practices.

A software engineering group is one of these and is usually a selection of the most ambitious or creative engineers from your teams that are willing to get together on a regular basis to throw around current engineering problems and work on providing solutions between them. By utilising slack days, or lunch times, the team can fire through some of these completely necessary technical elements of the delivery pipeline and keep the cycle time down to a minimum.

Agile Test Strategy (Updated)

A couple of years ago I posted a  very simple test strategy for agile based projects, here is an updated version.


Test and quality objectives


Objectives are a fundamental part of any strategy as they show us where we need to be going, and they allow us to invest in the right activities. My test strategies typically include the following objectives
  • Provide the customer with a system that they really need with quality baked in
  • Automate as much of the testing, configuration, and deployment as possible
  • Engage the business and customers in testing
  • Provide the business with the ability to confidently deliver features or complete systems without considering lengthy or multiple test iterations

Phase – Project conception & early estimation meetings


This is the most important part of the project. The wrong idea here could result in many man hours down the drain and a lot of money for your business. Who is really bothered about reducing the defect detection rate in a product or system that no one will ever use? Idea bugs are the most costly bugs and the ones that we should really focus on. This is sometimes out of the hands of most QA and test engineers, and is usually down to either having a very strong willed architect or a product manager that really understands what the customer needs and how to prove those ideas. I believe that this warrants a completely separate post, but you can find a very good explanation of idea bugs here. Whatever happens, there are tasks that we can take on.
  • Encourage pretotyping to prove the product concept over writing stories for unproven ideas
  • Understand any technology
  • Begin to sketch out a test strategy for the project

Phase – Early stage sprinting


During the early sprints our focus should be on proving the architecture and system concepts, building the team, and putting in place development and test frameworks.
Planning
  • Write technical stories or ensure the following tasks exist (These are all MUSTS)
    • Set up a CI project on your CI server
    • Set up unit test framework
    • Set up framework for front end script automation (JSUnit)
    • Set up build scripts
    • Set up all the necessary environments for now and think about what you may need for the future (Identify any needs you have further down the line)
  • Help scope out the stories and product
  • Get acceptance criteria clear in each story
  • Engage architects and technical experts in all planning discussions, never make assumptions on how things should work
  • Liaise with test leads or test managers to ensure you have covered off any global test strategies or ideals
  • Raise any performance considerations
Sprint
  • If the architecture is not yet baked then get to understand proposed solutions, arguments for and against. If it is decided, get to know why it was chosen, capabilities, etc
  • Ensure that plans are in place to make the code testable at more than just the unit level
  • Work with the product owners to get more insight on what the product is supposed to be doing
  • Update and test build and deploy mechanisms into the QA environments
  • Look for opportunities for early automation
  • Pair program / test / analyse

Phase – Normal sprinting


During normal sprinting we shape the product and deploy to UAT or beta environments on a regular basis to get feedback from customers, we may even be deploying direct to production. Regression testing is a key part of this process so must be efficient as possible. Throughout the strategy we are automating every process we can. Unit, integration, front end, and build scripts all combine to provide a high level of confidence in what we are delivering. 


Planning
  • Clarify acceptance criteria
  • Write testing tasks for all user stories
    • Unit
    • Integration
    • Scripting
  • Plan exploratory strategy
  • Ensure environments are ready
  • Plan crowd source testing
  • Ensure that the correct people are involved in the different planning activities. The tester should become a conduit during the planning, ensuring that information is passing to the right people.
  • Ensure UAT or beta environments are ready
  • Set up performance environments
Sprint
  • Write acceptance tests based on acceptance criteria
  • Carry out automation tasks
  • Maintain build scripts and environments
  • Carry out exploratory testing
  • Pair up with developers
  • Performance test
  • Test release mechanisms
  • Write post release test plans
There are probably a lot more activities that we can include, and I would encourage folk to experiment. If you understand your objectives, you will definitely understand what activities you will need to implement.