O'Reilly logo

The Cucumber Book, 2nd Edition by Steve Tooke, Aslak Hellesoy, Matt Wynne

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

What We Just Learned

Testing applications that use databases can be difficult. You have to make sure each scenario starts with a clean slate, but cleaning the slate can have its own pitfalls. In this chapter, we learned about the benefits and drawbacks of two strategies—transaction and truncation. To sum it up:

  • ActiveRecord is a useful library for quickly connecting to SQL databases.

  • Resetting state between scenarios is vital; otherwise, you get weird failures.

  • Transaction-based cleaning is preferred because it is fast, but it works only when there is one single-threaded process.

  • Truncation-based cleaning is a slower, brute-force technique that works in multiprocess and multithreaded environments.

Try This

Find an existing database, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required