Skip to Main Content
Cucumber Recipes
book

Cucumber Recipes

by Ian Dees, Matt Wynne, Aslak Hellesoy
February 2013
Intermediate to advanced content levelIntermediate to advanced
272 pages
5h 45m
English
Pragmatic Bookshelf
Content preview from Cucumber Recipes
Recipe 6Compare Images

Problem

You’re using Cucumber to test an app that generates or manipulates images. You want to compare the result to a reference picture—with a little wiggle room for minor differences.

Ingredients

  • pdiff (short for “perceptual diff”),[37] a command-line image comparison tool that accounts for the way people perceive images

  • chunky_png[38] for generating PNG files in the example code

Solution

It sounds so simple, doesn’t it? “Compare these two pictures and tell me whether they match.” But the devil is in the details. What does it mean for two images to match?

Do they need to be pixel-for-pixel identical? If not, what percentage difference is acceptable? What about images that are slightly rotated or scaled? Or discolored ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Cucumber Cookbook

Cucumber Cookbook

Shankar Garg
Basiswissen Softwaretest , 6th Edition

Basiswissen Softwaretest , 6th Edition

Andreas Spillner, Tilo Linz
React Cookbook

React Cookbook

David Griffiths, Dawn Griffiths

Publisher Resources

ISBN: 9781941222607Errata