A message from a fortune cookie the night I left for my new project…
Testing According to the Capability Maturity Model
- Initial – You don’t test or manually test in an ad hoc manner
- Repeatable – You start building test suite(s) that can be run repeatably
- Defined – You automate your test suites and run them in a continuous integration environment
- Managed – You start observing metrics from the tests such as how good the coverage is, how long it takes to run and how difficult they may be to write
- Optimising – You start to make changes to your code to make it easier to test, and you use the tests to highlight areas that need refactoring or a redesign. You start running Test Driven Development or Behaviour Driven Development to enhance the testability of your code.
After applying the CMM to way I execute testing, I find it interesting that the practices that emerged from the agile community are heavily biased towards the higher end of the CMM. There’s definitely a message here.
Disclaimer: This list was created by myself and does not reflect any official source associated with the Software Engineering Institute (SEI). It was written by me in terms of thinking of how I have seen testing executed and then trying to describe it in terms of the CMM.
Ask EMMA If You Are Covered
Code coverage is a useful tool for helping you work out how well you are testing your code. On most projects I have been on, I have found Clover to be the most well known and most popular but there are other alternatives, and this one in particular I am going to demonstrate how to use it.
On our current project, I used EMMA, an open source code coverage tool, to monitor how well we were testing various aspects of the code base. Results highlighted areas that were not test driven or areas that the team had neglected to deal with at the time (such as certain exception handling). This library is not specifically design to work only with JUnit, so I thought it might be useful to show you how we use it in our normal build that does use JUnit.
Steps to generate code coverage using EMMA
- Compile your classes
- Instrument your classes
- Execute your tests
- Generate the report
Compile Your Classes
With EMMA there is no change to the way that you can compile your classes as it allows you to instrument them post-compilation.
Instrument Your Classes
The distribution comes with a class that you can run against a set of classes that automatically generates the instrumented classes as shown below:
java –cp emma.jar emma instr –m overwrite –cp build/classes
where:
[emma
] Is the executable java class for easily running all the features from this library.
[instr
] Is the command for executing the instrumentation that weaves in all the monitoring features for generate code coverage information.
[-m overwrite
] Is the output mode and states to overwrite the original classes. You can also output a copy if you want but you will have to specify the output directory using the –d/-dir/-outputdir option
[-cp build/classes
] tells EMMA where it should be looking for the files to instrument.
Execute Your Tests
After instrumenting your classes with the features that monitor code coverage, you only need to run your tests as normal, only ensuring that you include the EMMA’s library jar in the classpath.
After running your tests you will see two output files including coverage.em
and coverage.ec
that are both used as inputs into the report.
Generate The Report
We will reuse the same executable class for generating the report as below:
java –cp emma.jar emma report –r html –in ../coverage.em,../coverage.ec -sp ../src
where:
[emma
] Is the executable java class for easily running all the features from this library.
[report
] tells emma that you want to generate a report from the coverage readings
[-r html
] tells what format the report should be in
[–in ../coverage.em,../coverage.ec
] tells emma where to find the code coverage data
[-sp ../src
] links the java source files to the results so that you can get some nice graphical reports.
Your should end up with a HTML report that outputs something like the following:
Ant Build Integration
You can use this build file (substituting appropriate values) if you want to get up and running quickly. It assumes:
- You have the appropriate emma jar in the specified location (see buildfile)
- You have the jar in the classpath of the tests
- You have compile and test targets
Second Anniversary Working at Thoughtworks
This time last year I blogged about my first year of employment with Thoughtworks. Not surprisingly, one year later now marks my second year and like all good things is a nice time to reflect on what things have happened since then. The best place to start is probably to see what I wanted to change last year and what has happened since then.
(From Last Year) Single-Project Consultant
Anyone who has worked in Brisbane understands that the commercial scene is not as broad as Sydney or Melbourne, and a consequence of being Brisbane-based (or is that bound?) means that I only got to work on a single project whilst I was there. I understand the commercial reasons behind it, but I think the same reasons pair rotation is important also apply to project rotation – consultants gain invaluable skills and spread knowledge, techniques and practices continually adding to the value of the organisation and to the clients they work with. Two years on I have now been on three different clients and four different projects, and I am now about to roll onto a fourth client.
(From Last Year) Lack of Travel Opportunities
Consulting brings with it the threat of constant travel, but being based in Brisbane didn’t bring anything with this. One of the programs Thoughtworks offers to its employees is an Exchange Program that enables people to transfer to the different offices (UK, Canada, India, China, USA and Australia) for a year to try living in a different country. I opted for working in London and it has been a fantastic experience since arriving in August last year. I have even visited an English seaside town for one of my projects but I do prefer experiencing all that London has to offer for the rest of the time that I will spend here.
(From Last Year) Further Feedback
One of the greatest things about working from the London office is the sheer number of people that you have access to on a regular basis. I imagine the other Australian offices would be different to Brisbane, but it’s great that you can bounce ideas around and discuss different topics with more than just a handful of people.
In terms of more formal feedback, the UK is setting great initiatives with project roll-off reviews and annual reviews. It really isn’t too hard getting other colleagues to give you feedback informally.
What Other Great Things Happened?
I am continually stunned by myself to see how my skill set continues to expand in so many different areas because I get to talk with and work with really bright people. It is especially more apparent when I pair program with people just how many more patterns, refactoring, testing and development techniques and principles I have learned.
All of these things I am now trying to share with more people. Last year I presented at an internal conference (one of our fabulous so-called “Team Hugs”), and was accepted to Agile India to present a Ping Pong Programming Challenge (but unfortunately couldn’t make it due to certain circumstances). This year I’ve submitted proposals to both XP 2006 in Finland and the Javazone conference in Norway both for later this year. I think it’s a great opportunity to share what knowledge I’ve gathered and get more feedback from industry fellows.
I am now dabbling in several new languages, some old and some new and am also now focusing on expanding on skills outside of just development to become a more well rounded consultant. My current focus is developing skills on being an agile coach because I have found clients tend not to understand a lot of the principles and I have found a team will be more effective if the team performs a number of the basics. As you may have read in previous posts, I am now currently building up a catalogue of retrospective exercises that I have found useful and what others might find useful. My personal beliefs have also significantly changed or perhaps even strengthened. I strive consistently for building self-empowered teams, not only because I think it is more successful but I think it is more fun and frankly I would rather have fun whilst working.
I did a little bit of sales work early on that was really just showing clients the way we work and the way that we do things, something I found quite interesting. It was nice that we could polish off some of the work that we did, turn it into a demo, and give it to people who were interested in doing things a different way and having them say, “Wow.” It’s such a rare opportunity that we get to do this on our projects and be appreciated by our clients.
So the good: Meeting and working with loads of other TWers, doing a variety of development and non-development roles, great amount of personal and professional growth, and all the things to improve from last year did improve.
More to improve on: Sharing this experience with more people and developing skills in even more areas.
A Retrospective Timeline
The retrospective timeline is a useful exercise for gaining a better understanding and a richer context for a particular retrospective. This means that this exercise becomes less useful when you do retrospectives more frequently and especially useful when doing a retrospective spanning longer periods or you run retrospectives less frequently.
Goals
The timeline aims to give a very visual overview of the events that occurred during the period for which you are doing the retrospective. The facilitator should use distinct and bold colours to identify distinct events so that it is easier to interpret the results. The timeline is a great way of determining trends over time for periods in the project and a useful mechanism for getting a feel for how the team felt throughout the course of the project.
When To Use It
As mentioned earlier, the timeline retrospective is useful for refreshing the memories of participants and you might find it useful in the following circumstances:
- For projects that are run without any intermediate retrospectives
- For projects that require more formalised processes (i.e. not necessarily uber-agile)
- If you need to communicate a more complete perspective for outside parties that may require reporting to
- If all participants did not necessarily work on the project during the entirety of the project (people rolling on or rolling off)
- The end of a project retrospective
The Fundamentals (Part One)
There are two major parts to this exercise. The first is noting all the events. Make sure that everyone has access to different coloured pieces of paper where:
- Green represents good events
- Yellow represents significant or memorable events
- Orange represents problematic events
The types of events that you might want to consider suggesting include things like when people rolled on or off projects, when things kicked off, when someone in the business made a decision that affected the team in a great way, when the team did achieved something really amazing, etc.
Get everyone to scribble each event down on separate pieces of paper and then get them to tack it along a standard timeline along a whiteboard or several sheets of paper stuck to the wall. This is where sticky notes or lots of blu-tack helps. It should look something like the following:
It is a good idea for you to get everyone to explain events, especially if the participants may not have full knowledge of what was going on. The significant events help to put things into context and might answer a few of the puzzling questions some people might have about the project, and the good points help to identify strengths while the problematic points should lead you to discussing action items. I find this exercise is most useful for first putting context for a retrospective spanning a large time and then using other exercises to draw out further conclusions. It is a good mechanism just to get the discussions flowing within the team and allows the facilitator to try to put different perspectives on things.
The Fundamentals (Part Two)
The reason you want to reserve some space underneath the timeline is for the second part of this exercise. In this part, you split the remaining area into two sections where you get the team to fill in how they felt about each event or how they felt in general for that period. You can try to limit them by getting them to put three dots per significant period (week/month) or perhaps one per event posted, with the idea that you want to get a general feeling for the overall morale of the team. You should end up with a scattergram that looks like the following:
Once the team has finished plotting all their points, you can then try to draw a trend through them that helps to establish a real idea of how the project went such as below:
Trawling The Timeline
The visual nature of the timeline allows you to easily draw out a number of trends from the project. Large concentrations of a particular colour may attract your attention to a certain period and it would be worthwhile trying to pinpoint its underlying cause so you can attempt to replicate (or avoid) the same circumstances in the future. The general trend at the bottom may or may not coincide with the events above the line so there might be another discussion point for explaining why morale might be low even though there might be lots of green or why it is high even though there were problematic events (maybe it was a good team building experience or people were growing and learning).
Agile Mythbusting
Yesterday I ran a session for another group at my current client introducing them to agile. The first part of this session helped me get a better understanding of what they thought of, or had heard about, or applied about agile and during this I noticed a few comments they touched on (and I hear numerous times from other people) that I thought might be worth sharing. I have found that when people observe and even when people practice some of the agile practices, it can be easy for them to incorrectly draw the wrong conclusions. Here’s a few of them and my thoughts on each:
Being agile means we don’t have to write documentation
I have never heard any agile coach nor practitioner ever say this, nor encourage this form of thinking. The agile manifesto states a value is “Working Software over Comprehensive Documentation”, with the thinking that people would rather some delivered instead of being given a document telling them what they could have had instead. You will find people trying to avoid writing comments in code because most of the stuff people write is redundant (it tells someone what the code does, when they can read the code right there and then – if it can’t be read, then maybe you have a bigger problem at hand). There are situations where comments are invaluable (libraries APIs given to external parties, or even commenting why something may not be obvious to a reader because of some bug/library/performance reason). I have found that sometimes having general diagrams with some descriptive phrases and a brief narrative is much more useful than any 300 page document might give. Consider that an hour spent in a conversation about what someone wants can be more productive than an hour spent writing and then another hour spent reading a document hastily put together.
Being agile means we don’t do design
Avoiding Big Design Up Front (BDUF) is a popular term but so easily abused. Not practicing BDUF is not about not doing *any* design and is even worse for a justification of a *poor* design and is a very big judgement thing. We have found that some good discussion about an approach helps (whiteboarding might be involved) can be useful, but in reality the implementation will be greatly different from the original design. It is sometimes better to just do things, and refactor to patterns or a better design (otherwise referred to emergent design) because you cannot anticipate everything. UML and class diagrams may help for *communicating* ideas, but not a great idea for trying to generate the code from it as the code tends to move faster than what the diagrams can keep up with.
Agile doesn’t work with old projects
There is no reason why inheriting someone else’s code automatically implies you cannot apply agile principles. You might find that some of the practices might be more difficult to implement such as talking to the people that originally wrote the code, or find the system difficult to test, but it shouldn’t stop you from trying. It does not mean that when you get new requirements, you cannot involve the customer more, it does not mean you cannot write your tests first and it certainly does not restrict you to release changes early and get more feedback. If you find there are problems, the old project is unlikely the cause and is more likely other processes such as the release procedures or the way your operations team works. Blaming agile or the project is not the answer.
Agile is no different from other processes, we do testing in RUP (etc)
I’ve never heard any agile practitioner say that testing is not executed in other processes. Testing in agile is different because there are different levels of testing and there is an expectation for the testing to start as early as possible. By focusing on testable, releasable and value-added units, more things can be achieved by the team such as getting better feedback, and getting more value earlier rather than in one big bang at the end (that may or may not happen).
Scary Conversations On Agile
A conversation I had with someone today:
Me: So how is your project going?
Manager: We’re doing 12 iterations, we’re up to the eighth and we’re just getting a QA environment to run tests in.
Me: Do you have any form of continuous integration?
Manager: Well, we are only interested in the files that change, so we don’t need to run it against the entire system
Me: (Warning bells starting to ring…) Do you have any tests?
Manager: Our developers have too much trouble writing unit tests because the system is made of all web pages
Me: (Okay, keep calm, just run with it for now) Have they tried looking at HttpUnit or JWebUnit?
Manager: No, not yet.
Me: (Ask it anyway – maybe they’ll surprise you) So what sort of tests do your developers have?
Manager: Oh well, since they don’t have a remote environment, they just run tests on their machines.
Me: Do you mean they run them manually?
Manager: Yes
Me: (Sigh and so forth…)
The Retrospective Starfish
Diagrams are always useful focal points for starting discussions, and that’s one reason I like using the starfish diagram for a retrospective. This particular retrospective technique helps people by getting them to reflect on varying degrees of things that they want to bring up, without having it fit into the black or white category of ‘What Went Well’ or ‘Not So Well’ so I think it scales a little bit better.
A little bit about each category:
- Keep Doing – Is a good starting point for team members to focus on typically all the good things that they liked about a project. You might want to encourage people to think about things in terms of, what would they miss if they didn’t have a particular practice, technique, technology, person, role, etc. A good example from a real session I’ve been in before is ‘Running performance benchmarking and tuning during an iteration helps to identify regressions or slowdowns so we can address them earlier’.
- Less Of – Helps to focus on practices that might need a bit more refining or that were simply not helpful in the current circumstance. Perhaps they add value but not as much as other practices could. An example here is that perhaps stand ups have become status meetings and so there should less of talking to one person (and more of talking to each other) during them.
- More Of – Is another type of focus that helps further refine or highlight practices, technologies, etc that team members might want to try more and are not necessarily taking full advantage of. A good example is that maybe people are pair programming but knowledge transfer and a better understanding of the code changing might be gained by doing more of swapping programming partners.
- Stop Doing – Obviously for things that are not very helpful to development practices or not adding much value. Perhaps it’s about writing that status reporting email at the end of the day (because you can substitute a simple one minute conversation for it instead)
- Start Doing – Is a great opportunity for team members to suggest new things to try because of things that may not have gone so well or just for simply keeping things dynamic and fun. Perhaps you might want to try a burn up chart on the whiteboard or try some new open source tool for helping improve developer productivity.
Interpreting the Starfish
Getting people to either write things up under the starfish in this manner gives you a scattergram of sorts and is a great visual technique of estimating the overall health of your project. Most of the points on the starfish also try to coerce people into actually creating action items instead of simply saying that something was not good.