Category: Testing

The Agile Testing Days 2014: Conference Day 3

The last conference day started with a very personal & inspiring (and slideless!) keynote from Antony Marcano, entitled “Don’t Put Me in a Box”. He made a good point about how people have many ‘labels’ outside their job such as mother or father, friend, cook, helpful neighbour etc., while in a job there’s often only one label: The job title. In fact, he asked as few listeners in the audience about what they do and everyone answered with a role or a job title.

He explained how this may be an impediment for agile teams. If (or when) we stay in the box of our job title, we might not get a chance to help in an area that’s outside the main focus of our job description.

The following talk “Pull Requests and Testing Can Be Friends” by Alan Parkinson presented some very interesting points. One of them was this: While it may not be necessary for testers to be able to write code, it may be very useful to be able to read code.

His presentation was mainly how his company uses pull requests in Git. I found it interesting that they use pull requests for a lot of things, including reporting and tracking bugs found when testing the change that implemented the pull request. The reason they do so is simple: The context in which that bug was found is that pull request, therefore these two should be kept close together. They implemented this by having a discussion for each of their pull requests. To me this makes a lot of sense for a development team.

After that I attended Chris George’s talk “Easing the Pain of Legacy Tests” (Be sure to watch the slides, they’re great!). He explained how his team started with a long running (as in: 16 hours) test suite that reported about 20% of the tests as failed; and not always the same 20%. After some iterations of working on the problems they had significantly faster as well as much more stable tests. So, for his team it was well worth the effort.

In the afternoon, I attended Selena Delesie‘s workshop “The Best Agile Managers Thrive When Teams Do”. An introductory exercise showed how stressful it can be for both the manager and the team, if the manager tries to control the progress, instead of allowing the team to solve the problem at hand.

Often it’s better to make the goal visible to (and understood by) everyone, and then let the team work out the solution. One thing I found particularly interesting was this: In a more controlled environment people sometimes have to wait (or at least feel they have to wait) for the next task given to them by the manager. This waiting is not always necessary, but happens anyway. In a more team oriented environment the waiting is more often caused by the work itself, for example when one can only continue testing after some serious bug is fixed. To me this ‘work constrain’ related waiting is a lot easier, because one understands the reason for waiting. The ‘management constrain’ related waiting often seems to be unnecessary and therefore can be more annoying.

At the end of the workshop we, the participants, were asked to answer the question: “What does senior management value?”. For the answers, see the photo below.

The Answers to "What does senior managemet value?"

 

I believe that our (the workshop participants) overall model of senior management is far too simple (or simplistic).

The last keynote was Alan “The Evil Tester” Richardson’s “Helping Testers Add Value to Agile Projects“. His story was full of insights and entertaining and I like how he explained that he doesn’t want to be called a ‘QA’:

Don't call me a QA

 

 

As a final note: I had a lot of fun talking to some of the other contributors to Lisa & Janet’s new book “More Agile Testing“. I wholeheartedly recommend this book — but may be I’m biased, since I’m a contributor. 😉 As I had the book with me, I got some signatures, not only from Janet & Lisa, but also from other contributors I met at the conference.

Thank you everyone at the conference! I’m already looking forward to seeing you again next year.

The Agile Testing Days 2014: Conference Day 2

The first keynote of day 2 “Test First Saves The World”, was Joe Justice who talked about applying Scrum in non-software industries, including the automobile industry. He also presented a very exciting project which attempts to build a car: http://wikispeed.org/car/

In fact, he brought parts of a car and invited the conference attendees to join a Scrum team and build a car in the hotel lobby.

People building a car in the hotel lobby
Building a car at the Agile Testing Days 2014

Joe also pointed to another project he started: The MicroHouse, that aims to provide a clean bathroom, a clean bedroom, a lockable front door at less than 100 USD. It is this project that is linked to the “save the world” part of the presentation title.

In the second keynote Fanny Pittack and Alexander Schwartz presented “Insights from Happy Change Agents”. Both of them have presented at previous conferences, but this time they went for a pair presentation and a keynote — even though they have never worked together before. I found this one very inspiring, to say the least. They demonstrated how a coach can take on the perspective of a team, rather than using her (or his) point of view from the outside. In addition to that, there was also a pair exercise for the attendees to do. They also shared their slides:

To me, the talk was not only about changing your point of view, but also about trust in a team as well as a single person. When the question session started, I made an unusual (for me) move and asked whether someone from the audience was willing to prepare a pair presentation submission for next year’s Agile Testing Days. Then two things happened rather quickly: First José Díaz announced, that if I find a pairing partner, then the session is already accepted:

How awesome — and trusting! — is that? The second thing to happen: The first person I noticed to signal willingness to co-present with me was George Dinwiddie. We met in person for the first time at this conference, have never worked together before and we’re separated by the Atlantic Ocean. I expect to have great fun and learn a lot while working on our presentation. I am sure that we will figure out how a distributed team (of two) can work.

Even now as I write this — a week later — I’m amazed, impressed and honoured by the trust and friendliness of all this. Thank you all: Every single one in the audience in general and George & José in particular!

After this, I had a short break from the ‘regular talks’ and attended the Open Space session (there were six of them, throughout the conference!) facilitated by Alex Schladebeck and Meike Mertsch. Since there were not too many people attending the sessions, we changed the format to a Lean Coffee. I like it a lot when a format is changed ‘on the fly’ in order to match the circumstances, instead of sticking to a plan that doesn’t fit well anymore.

Among other things, we discussed the question “What makes a good session at this conference?”, brought in by George and me, since we wanted to know what it is that people like about a session. Thank you for voting on this topic to everyone who attended!

The third keynote of the day was David Evans’ “The Three Pillars of Testing”. He explained how testing and agile fit together and placed just the right amount of puns into his talk. He explained the classic order of capitals, what ‘Euthynteria’ is — and what is isn’t:

Do not confuse euthynteria with 'youth interior'
What ‘euthynteria’ is — and what it is not

This was the end of a very pleasant and entertaining second conference day.

The Agile Testing Days 2014: Conference Day 1

If you’ve read my previous post about the tutorial day, you may wonder why there’s another ‘Day 1’. — Well, the official conference program mentions the 11th of November as the 1st day, so I stick with that.

For me the day started with a Lean Coffee, a format where people meet, gather topics everyone can bring, vote on these topics and then discuss the topics based on that voting (see the link to the site for more information). I like this format, because it allows to get to introduce a topic and discuss it without spending much time. That way one can see whether at least some other people are interested in a particular topic.

Afterwards, Lisa Crispin & Janet Gregory gave the inspiring first keynote, titled “WELCOME TO THE FUTURE – Preparing For Your Agile Testing Journeys”. They presented their view of how software testing may be in the future and also shared the slides. I liked the Star Trek theme presentation, which also nicely matched the topic.

Next, I attended George Dinwiddie‘s talk “A Poet’s Guide To Automated Testing”. He demonstrated how important a good choice of words is, when writing automated tests. By questioning every single word in a rather typical test, he showed how the tests can be improved. For example a typical test often reads: “When I log in to the system…”.

Who is the ‘I’ mentioned in that line? A customer? A system administrator? The ‘I’ who wrote the test, whatever his or her role was? — After a while, sometimes a rather short while, this knowledge gets lost. So it’s usually better to make this knowledge explicit in the automated test.

The following presentation by Carlos Sanchez was titled “Continuous Delivery, the Next Frontier”. I found it very interesting to see him talking about Docker a lot. Also interesting was so see that, while many people know about Docker and also use it, not many people do use it in a production environment, at least none of the people attending the talk.

Also he provided a funny explanation about where Docker works:

In the the early afternoon I attended Jeff “Cheezy” Morgan‘s workshop “Patterns of Automation”. There was an enormous amount of interest in the workshop and the room filled up quickly. He gave a good number of patterns and even (successfully!) live coded his examples. Super interesting, entertaining and funny!

At the end of the conference part of the day Bob “The Flowchain Sensei” Marshall gave his keynote “The Antimatter Principle” (explained on his blog), a very inspiring, thought-provoking and slideless presentation.

The conference day ended with the now traditional Halloween and costume party, excellent food, super interesting conversations and Matt Heusser receiving the “Most Influential Agile Testing Professional Person” award. Congratulations!

The Agile Testing Days 2014 – Day 1: The Tutorial

The 1st day of the Agile Testing Days for me was a full-day tutorial by Alan ‘The Evil Tester’ Richardson about technical testing. The tutorial was very hands on, and we actually tested something — a website.

I liked how we started with the website as such and focused on the relatively simple aspects of getting a user account and logging in. We did some testing and then reflected on what we were doing and how we did it. For example there were various ways of note-taking:

  • I mostly used pen & paper, and for some notes a text editor (e.g. when I knew that I would like to make a note of text I would enter more than once)
  • Some used their text editor of choice, Evernote or similar tools.

After interacting with the application ‘just’ using the basic browser feature of rendering HTML, we stepped down to a slightly deeper technical level and used ‘developer tools’. These allow interaction with the DOM and, for example, manipulate what an HTML form would submit back to the server — including, but not limited to, selected values of drop down lists. — While not every user will do that, some will. And it’s a good idea to test that your server can candle this unexpected input. We also looked into a number of tools to capture (and again manipulate) network traffic, such as HTTP proxies.

I liked how ‘technical testing’ was presented as something that is different from ‘test automation’. Many of the tools we use for testing enhance our possibilities as testers — and sometimes they also allow for some automation. The main point of technical testing though, is increasing the testers reach into the technical details of the system under test.

This is what I expected from the day and also what was delivered in the tutorial.

Thank you Alan, I liked it a lot!

CRUDCA – Create, Read, Update, Delete, Create Again

I recently tweeted:

A new test sequence: CRUDCA: Create, read, update, delete, create again. — Because sometimes an object can’t be again.

I got some feedback from this, so let’s present the idea in a bit more detail.
Many systems know these 4 basic actions for an object:
  • Create
  • Read
  • Update
  • Delete
That’s where the abbreviation CRUD comes from. In many cases that’s also a rather typical test sequence to check whether the system can handle these actions. — And often it’s also good enough testing.
But sometimes there are more restrictions at work:
  • An object may only be created once and only once. It may be removed, but then not created again.
  • It must be possible to create an object with identical properties again and again.
This is how I came up with ‘CRUDCA’: Create, read, update, delete, create again.
Obviously, it depends on the particular (business) context whether or not it is allowed to create a certain object. The ‘create again’ part covers the action of attempting to create the object. The expected behaviour comes from the requirements or specification of the system.

It’s Not Always A Commit That Breaks the Build

In many cases a red build means, that some commit to the version control system broke it.

However, occasionally it can be something as simple as waiting that breaks it. Here’s what happened to me very recently when changing a Ruby project:

  1. I didn’t commit (& push) to one of my projects for a while.
  2. Then I made a pretty minor change.
  3. The local test run was fine.
  4. So I committed & pushed the change to GitHub.
  5. The builds on Travis-CI turned red.
  6. Oh?!?

What happened?

Travis-CI always sets up an entirely new environment, including this:

bundle install

Now, RSpec has been updated (to 3.0.0) since the last test execution on Travis, and I didn’t specify a version in the Gemfile (actually the gem spec file of the project), and I didn’t specify which RSpec version to use, and some RSpec methods have been changed in the meantime.

In particular, some of the specs used be_true, to check a number of predicate methods. However the new RSpec way is to use is_truthy (and its counterpart is_falsey). These methods check something slightly different compared to this line:

expect(value).to be true

In RSpec 3.0 only true is true, and everything that is interpreted as true (everything other than false and nil) is truthy. Also note the absent underscore in be_true (as used in earlier versions of RSpec). See this short example of RSpec:

describe 'RSpec 3.0 true vs. truthy' do
  it {expect(true).to be_truthy}
  it {expect(true).to be true}
  it {expect(1).to be_truthy}
  it {expect(1).not_to be true}
end

Notice here, that 1 is truthy, but not true.

Lesson learned

In order to avoid trouble like this, it seems to be a good idea to fix gem versions for a project in the Gemfile (or the gemspec).

This can avoid broken builds on your Continuous Integration Service (as in my case), but it can also prevent a new team member from struggling through dependency issues after running the bundle command to set up a new machine for development. See, for example “Ruby’s Pessimistic Operator” and “Ruby Gems Guides – Patterns” on how to use the ‘twiddle wakka’ operator for gem versions.

Testing Rake Tasks

I’ve worked in several teams that used (and still use) Rake, a build tool written in Ruby, to perform various tasks—not just building software (or other artefacts). In this article I list some ways in which rake tasks can be tested, but I do not recommend all of them for all contexts.

Ways to test rake tasks

1. You don’t

Let’s face it, in some cases rake tasks are hardly tested at all, maybe just tried out a little bit. And in fact in some cases that’s just fine: When the tasks are particularly simple and/or they’re short lived anyway, a whole set of tests may be just too much. — But keep in mind that in this case using rake may also be going too far already.

For example, take to following code.

desc 'Write list of files in (sub) folders to "filelist.txt"'
task :dir_to_txt do
  File.open('filelist.txt', 'w') do | f |
    f.puts Dir['**/*']
  end
end

For most people this code is so simple, that they likely wouldn’t bother testing it (and yet… I’m not claiming it’s bug-free).

2. Non-Automated Testing

In many cases, rake tasks are ‘tested’ by manually running them and then examining the result. Depending on what you’re doing this can be fine. However, rake tasks process various input and they can be configured, too. For example, you may set an environment (such as ‘test’, ‘development, ‘production’) or a particular server to run them against. Sometimes you can cover the important combinations with manual testing. But then, maybe you’re missing a particular combination that causes a failure.

Also, don’t forget to document what, how and why you tested it the way you did. Someday someone will have to change the rake task, and then it will be important to know what behaviour is expected not to change.

2. Cucumber

You’re running the rake tasks in order to have a (more or less) permanent effect. You can test this using Cucumber, and the format could be like this:

Feature: Running task name_space:task_name
Scenario: Use default parameters
  Given the task is configured with the following setup
    | parameter_1 | 'some value' |
    | parameter_2 | a_number |
  When rake name_space:task_name is run
  Then some effect should be achieved

With Cucumber you can provide configuration data to run a single setup like the one above, but Cucumber also offers ‘Scenario Outlines’ which provide an even more parameterised way to run the checks. Combined with e.g. ‘all pairs testing‘, this can give a very reasonable test coverage (with respect to used values & combinations of these values).

3. MiniTest or RSpec + Refactored Rake Tasks

A rake task is just Ruby code. Therefore it can be unit tested just like any other Ruby code. (It can even be developed in a test-first way. Just saying.) If you’re also refactoring tasks into modules, classes and methods, it’s even easier to test and an additional benefit may be the fact that you’re creating an interface to the tasks that may be useful in a context other then running rake tasks.

4. ‘Redefine’ Rake Methods

Rake tasks are called using:

rake a_taskname

Rake searches for a file called ‘Rakefile‘ (or ‘rakefile’, with or without the ‘.rb’ suffix), and then processes it, in order to find a task with a matching name. Since the Rakefile itself doesn’t require ‘rake’ (using the command rake loads Rake’s context), you can (re-) define the methods rake provides (in a separate file), require that file, require your Rakefile and then use a test framework of your choice on those methods. Let’s look at a Rakefile with two simple tasks:

require 'fileutils'
namespace :doc do
  desc "Generate RDoc for the Rakefile"
  task :self do
    `rdoc ./Rakefile`
  end

  desc "Remove doc folder and its content"
  task :remove do
      FileUtils.rm_rf('doc')
    end
  end
end

While you could (re-) define rake’s methods ‘namespace’, ‘desc’, ‘task’ etc. and the call those methods to test them, this would only solve part of the problem: The tasks still change the outside world (in this case generate RDoc in a folder in one case and remove that fold in the other case). In at least some cases that’s undesirable, e.g. when there’s a task that’s supposed to switch your online shop into maintenance mode, just displaying a static page for all incoming requests. At least in those cases it’s preferable to check for the right behaviour instead of depending on checking a state change in the (real) world.

That’s possible in Ruby: You can redefine existing methods such as FileUtils.rm_rf and even ` in the example above. — Yes ` (the back tick) is a method in Ruby and you can redefine it. For more complicated (or complex) rake tasks, it’s a lot of work to find all the methods that you’d need to redefine. While it’s possible, I wouldn’t recommend it, since it seems to me that it’s also error prone and might well introduce more trouble (read: bugs) than anyone would like in their tests.

Some General Remarks

Since a rake task is code, I think it should be treated as carefully as any other code we write and it should be tested (and live in the same version control system used for other parts of the code base). Especially in case of tasks that control an online shop (e.g. switch to maintenance mode), deploy new software to production etc. it is in fact production code.

I personally prefer the rake tasks I’m working with to be well written, refactored and of course tested code. So I strive to extract single methods, modules and classes from rake tasks and test these in isolation.

Not matter what kind of automation you’re using to test your rake tasks, as soon as you’re starting to use a rake task to run these tests, e.g. as part of your regression tests on a Continuous Integration system like Jenkins, things may get tangled up: How would you test those rake tasks?

Other Articles on Testing Rake Tasks

Privacy Preference Center

Necessary

Advertising

Analytics

Other