Sunday, 24 May 2009

Agile Testing: A Practical Guide for Testers and Agile Teams


by Lisa Crispin and Janet Gregory (978-0-321-53446-0)

This book is pretty much what it says on the tin and that's a good thing. Behind all the usual Shiny Happy People Having Fun stuff you usually get in books from the Agile community is some sound, well expressed advice. This isn't just a book for Agile testers. There's a lot of good practical information that all testers should learn. It's a difficult balance to achieve, but I think the use of the word Agile may put of a lot of people who should really be reading this book.

As well as the general practical testing advice the book also covers a lot of fundamental Agile stuff. It sets out some Agile testing principals and discusses the problems a lot of teams have when transitioning to Agile. It's all been written before, but never from a testers perspective, but to be honest it's not that different from the developer perspective.

The book is very hung up on the idea that developers in Agile teams, and indeed testers in or joining Agile teams have difficulty seeing how testers fit in as developers are doing unit testing and therefore the code is supposedly already tested. Personally I feel that anyone who doesn't understand that not everything can be unit tested and see that “independent” testers are vital is probably in the wrong job. The book made me view our owner tester, who does not come from a programming background, in a totally different way. Instead of seeing him as someone who just carries out the manual user interface tests, I now see him as an integrated member of the team who needs to take part when requirements are gathered and should also be writing integration and end-to-end tests as well as maintaining continuous integration. The necessary training has now commenced.

Most of the Agile discussion is at the beginning of the book. The practical stuff comes later and is quite detailed, including most of the sorts of testing, including automated GUI testing, that should be carried out.

I think this book will make most people think differently about testing in a good way.

Friday, 22 May 2009

Tomcat Servlet with Spring Timer

recently had a requirement to write a service, in Java, that monitors a directory and when new files with the correctly formatted name appear, send them to another system. All fairly simple stuff. There are many different ways of writing Java services, but we use Tomcat quite heavily, so rather than investigate another way, I decided to write a Tomcat servlet to act as the service.

I started off by extending GenericServlet and overriding the init and destroy methods to write log messages to standard out. Then I wrote the appropriate web.xml to tell Tomcat about the servlet and wrapped it all up in a war file (basically a zip file with a Tomcat specific directory layout) and deployed it to my local Tomcat installation. I then checked the logs and found the log messages I'd put in the code. Not bad going for twenty minutes work and my first Tomcat servlet written from scratch.

We've been gradually learning about Spring recently and I remembered reading that Spring had timers that would be perfect for polling the directory for files. So I integrated Spring into my servlet, repackaged and redeployed it and then checked the logs to make sure the Spring application context had fired up correctly. It had.

Next I created a Ticker class by implementing the Java TimerTask interface and implementing the run method to write "Tick" to standard out. I then registered the class as a Spring bean and created a Spring ScheduledTimerTask, set the tick interval to one second and created an anonymous TimerFactoryBean. Making the TimerFactoryBean anonymous causes it to be instantiated when the Spring context is started, rather than waiting for an explicit instantiation from code somewhere. So, what should happen is that the ticker should start as soon as the application starts. Sure enough as soon as I repackaged and deployed, "Tick" was written to standard out every second.

It occurred to me that the class extending GenericServlet was redundant. So, not expecting it to work, I removed the class from the servlet and web.xml entirely and repackaged and redeployed. That's when I had my real "Whoah! That's really neat!" moment. To my amazement and joy the ticker started again and kept ticking every second. I already knew Spring and Tomcat worked well together, but having Tomcat start the Spring context without needing a servlet class is pure genius.

It may seem like such a small and simple thing, but creating my first Java service and Spring timer and having them work together in a very simple way was a real revelation for me.

Monday, 18 May 2009

ACCU Conference 2009

Wednesday Keynote: The Birth of Software Craftsmanship by Robert Martin

Brilliant! Simply brilliant! Uncle Bob is an enthusiastic and wonderfully engaging speaker. Through this keynote he chronicled the, now well understood, pitfalls of big upfront design, the emergence of XP and the birth and journey to maturity of Agile. Bob explained how Agile was adopted by business as it is more people focused than XP and how that caused the technical practices that made XP so good to be left behind. He highlighted how we need to reengage with the technical practices moving forward. We should all be using Test Driven Development, Continuous Integration and Pair Programming and Uncle Bob demonstrated why. In 2009 the benefits of using these are measurably several magnitudes greater than not using them. Uncle Bob has also brought out a new back to basics book to help us all remember how to write good code.


Security in Distributed Systems and SOA by Nicolai Josuttis

At previous conferences it has always been very difficult for me to find sessions that are directly related to my everyday work, so Nico's session intrigued me greatly as securing web services is something my team was due to attempt shortly after the conference. Together with joining the ACCU Nico is responsible for kick starting my career. I learnt more about C++ and the standard library from his book than almost any other source. What I learnt, in a very short period of time, allowed me to absolutely trounce a job interview and increase my salary by 30%. So I always try and go to Nico's sessions.

The session was everything I hoped it would be and answered some key questions that had been going around in my mind for some time. Nico took us through the different issues and methods of securing web services and methods of avoiding common denial of service attacks, such as XML bombs.


Measuring the Effect of TDD by Keith Braithwaite

This was another interesting session, but unfortunately some of the maths and detail went over my head. However, the gist was that code that is designed for test and has good test coverage is almost always less complex and "better" than code that does not. Instead of this being just a general feeling, Keith showed how this could actually be measured.


The Model Student Episode II: A Fresh Hell by Richard Harris

Richard Harris is one of the brightest people I know and his command of maths far outstrips my own. I completely failed to follow most of his talk, but it was fun when I got picked on to choose the numbers in the Countdown simulation. The session was full of entertainment and special effects and left me wondering what Richard would do to better it next year.


Keynote: Welcome Crappy Code - The Death of Code Quality by Nicolai Josuttis

I wasn't the only too come away from this presentation wondering if Nico had lost the plot. I must admit I found myself hoping that Nico's German humour had got lost in translation somewhere. The basic message was that we as developers are not given time to write good code, so we should stop worrying about it so much and accept crappy code. The whole way through I was waiting for the punchline that never came.


Thursday Keynote: The Benefits of Abstraction in Patterns by Linda Rising

Linda Rising is obviously very passionate about patterns. She sees them, quite rightly, everywhere. Not just in software engineering. I'm sure there was some very interesting material in her presentation, but unfortunately it was all lost in the delivery which was slow and at times a little boring.


Memory Allocation and Garbage Collection in Java by Angelika Langer

This was another session where I was hoping to learn something that I could apply in my everyday work and I wasn't disappointed at all! Before the session started I was wondering how Angelika was going to fill 90mins with a relatively straight forward and well understood subject like garbage collection in Java. However, she went in a great deal of detail about the Java memory model and how it has evolved, especially with respect to threading. Angelika also covered some of the tools that can be used to see what is happening with memory inside the virtual machine.


Kirk Pepperdine also attended the session and, as always, took over in a few places. However, I think everybody enjoyed and learnt from his interruptions.


Designing for Testability by Sami Vaaraniemi

I've been designing for testability for years and I wanted to go and see if someone else had a different take on it. Unfortunately Sami, ironically a Microsoft employee, was explaining a lot of stuff such as the use of interfaces and the bridge pattern that I've been using a long time. To my dismay, amongst other things, he also advocated having constructors just for testing purposes where a solution that at least called the production constructors as well could have been employed. There was a lot of useful information for the novice here, but a little bit of caution is required.


Friday Keynote: Geeks, Nerds and Other Prejudices by Susan Greenfield

Susan Greenfield's key note was highly enjoyable and entertaining. She looked at the differences between men and women at the brain level and proved, with plenty of humour, that women are no less capable than men at computer science and pointed to the way in which society portrays computer science and computer scientists as the reason few young women choose a career in IT. Of course if this presentation was flipped on its head and became about why men are as good as women at computer science it would have been condemned as sexist!


Boilerplating Database Resource Cleanup by Paul Grenyer

Paul Grenyer was brilliant! Superb! The star of the conference....Well of course I wasn't really and if I had been I certainly wouldn't be bragging about it. I do feel, however, that this was my most successful presentation to date. Not in terms of number of attendees, but due to the new confidence I feel when presenting. It all comes down to preparation and practice. Next year I'm going to do another 90 minute presentation (if they'll have me).


Processors Processors Everywhere, But How Do I Actually Use Them? by Russel Winder

As I have said in the past, I find Russel very entertaining and this was another enjoyable session where Russel demonstrated the performance of a number of different languages (C, C++, Java, Python, etc) in a threaded environment. Unsurprisingly Java didn't do very well compared to C++. Again, I learnt plenty and was able to contribute. This was three hours well spent.


Saturday Keynote: Considerations for Successful Management

Allan has passed over to the dark side and frustratingly is very good at it. During his session he gave a lot of common sense practical advice about managing agile teams and of course plugged his book.


All in all this is probably the most useful ACCU conference I have been too. I learnt a lot of stuff that I have since been able to apply and there's more to come. During the week I was persuaded, not only to edit three issues of CVu but also to join the conference committee, so I am looking forward to helping shape another great conference next year. Roll on 2010 (isn't that the year we made contact?).