Skip to main content

A h̶i̶t̶c̶h̶h̶i̶k̶e̶r̶'s̶ software tester's guide to randomised testing - Part 2

How would test a water sac? (Wow there, calm that tester brain... I know what you are thinking, Whats it used for? Who / what uses it? how long does it need to last? Does the temperature of the water matter?  Is it single use? etc. But let's assume a generic hiking or camping water sac for now) I'm guessing one of your suggestions includes filling it with water, shaking it a bit and checking for leaks.

Seems kind of obvious right? but when it comes to software, we often do away with old-fashioned techniques such as filling something up and looking at it. Where's the machine learning test algorithm? Call this a BDD scenario? Can Selenium check for H₂0? I have to run this past the B.A...

Image result for water leaking
This is your software.

We can treat randomly generated test data and inputs in much the same way as water. Data files or other inputs like user interactions are the ever-moving parts of our applications. Think about it, the code is entirely static - it's the state or data that is changing. This contradicts the commonly held notion that the code is like a set of complicated cogs churning away until they click into place on the answer.

If your app processes data files, JSON / XML feeds or some other kind of prescribed format of inputs - create one yourself, don't just rely on the examples a Business Analyst or Product Owner has given you. Some hand rolled examples will probably be essential for smoking out bugs. But a large set of randomly generated data will probably also flush out some more. Much as you could easily detect the wet patches from a leak, you can often check easily for where your randomised data causes problems in your application.

With one client I created a large spreadsheet that included randomised data for a subset of the data fields. The generated data all matched the documented specification. Despite essentially being garbage, the data had valid relationships, text values and numbers. I imported this data into the system and looked at the user interface. What did I see? A sea of red! It turned out that the UI validation did not match the spec - in several places. Ad hoc testing had previously only found the more obvious validation mistakes.

The real smarts here probably isn't the generated data file, though that made it easier to do this sort of analysis in bulk on a complicated app full of different data types and calculations. The clever bit here is: using the app to help check itself. The data fields that allow negative fields as per the spec, were highlighted in red in the UI when negative values were imported from our file. This made finding the inconsistencies in the validation easy. The random data helped us to try out things we might never have managed to think up for ourselves.

The same goes for a complicated series of user interactions. Let's say the user works through a series screens as they buy or choose a product. Each screen has options that can take you to an array of different options. (The same principle applies to a complicated series of API interactions.). Using a set of BDD scenarios with data tables isn't going to check many of the routes users are likely to follow.

Why not make random choices from valid options (you could also include invalid ones) and see what happens. You don't have to know in advance what needs to happen exactly, just think of some heuristics. For example, If you get a 404 that's probably a bug - take a closer look. You don't even need to check the UI for that error you could check in the applications log. (Especially useful if it tries to hide the problem from the user with a helpful message / incorrect response code.)

A simple script to pick random values from a pull-down menu to reach the next screen and repeat can run in an infinite loop between each code check-in. Over and Over. Ever vigilant for Javascript errors, error response codes, slow pages etc. Let the machine do the grunt work. Save the smart and detailed investigation for people.


Popular posts from this blog

The gamification of Software Testing

A while back, I sat in on a planning meeting. Many planning meetings slide awkwardly into a sort of ad-hoc technical analysis discussion, and this was no exception. With a little prompting, the team started to draw up what they wanted to build on a whiteboard.

The picture spoke its thousand words, and I could feel that the team now understood what needed to be done. The right questions were being asked, and initial development guesstimates were approaching common sense levels.

The discussion came around to testing, skipping over how they might test the feature, the team focused immediately on how long testing would take.

When probed as to how the testing would be performed? How we might find out what the team did wrong? Confused faces stared back at me. During our ensuing chat, I realised that they had been using BDD scenarios [only] as a metric of what testing needs to be done and when they are ready to ship. (Now I knew why I was hired to help)

There is nothing wrong with checking t…

Manumation, the worst best practice.

There is a pattern I see with many clients, often enough that I sought out a word to describe it: Manumation, A sort of well-meaning automation that usually requires frequent, extensive and expensive intervention to keep it 'working'.

You have probably seen it, the build server that needs a prod and a restart 'when things get a bit busy'. Or a deployment tool that, 'gets confused' and a 'test suite' that just needs another run or three.

The cause can be any number of the usual suspects - a corporate standard tool warped 5 ways to make it fit what your team needs. A one-off script 'that manager' decided was an investment and needed to be re-used... A well-intended attempt to 'automate all the things' that achieved the opposite.

They result in a manually intensive - automated process, where your team is like a character in the movie Metropolis, fighting with levers all day, just to keep the lights on upstairs. Manual-automation, manumatio…

Scatter guns and muskets.

Many, Many years ago I worked at a startup called (a European online travel company, back when a travel company didn't have to be online). For a while, I worked in what would now be described as a 'DevOps' team. A group of technical people with both programming and operational skills.

I was in a hybrid development/operations role, where I spent my time investigating and remedying production issues using my development, investigative and still nascent testing skills. It was a hectic job working long hours away from home. Finding myself overloaded with work, I quickly learned to be a little ruthless with my time when trying to figure out what was broken and what needed to be fixed.
One skill I picked up, was being able to distinguish whether I was researching a bug or trying to find a new bug. When researching, I would be changing one thing or removing something (etc) and seeing if that made the issue better or worse. When looking for bugs, I'd be casting…