Test Driven Cookbook Development in 2017

We are constantly asked to deliver our infrastructure faster at what seems like a compromise of its quality. Waiting until it’s time to deploy into production is not the moment to see if the cookbooks we have written will work. By adopting a test driven approach to cookbook development we quickly receive feedback through simple tests that ensure the code we have written is correct. It also gives us the tools to automate the process of creating virtual instances, applying our cookbook code, and verifying that our cookbook has delivered the desired state correctly. Testing helps us increase our velocity while diminishing risk by ensuring the changes we make are verified.

If you’ve been a part of the Chef community for awhile, you may have seen the wildly popular Test Driven Cookbook Development webinar I delivered early last year. Since then, the Chef Development Kit (ChefDK) has seen 26 releases (2.3.4). In addition, InSpec has matured as an incredibly powerful testing and compliance language with 87 resources to describe systems. Most importantly, it has become the default integration testing framework when you use the ChefDK cookbook generator. ChefSpec has also seen a number of releases over the past year-and-a-half maintaining its relevance as the unit testing framework for cookbooks.

This updated presentation gives a fresh look at Test Driven Cookbook Development with the most current technology we have to date. I encourage you to use it as a comprehensive resource for you and your team to employ as you start your journey with testing.

 

In this video I address some of the most frequently asked questions about testing:

  • Why would I want to write tests? Doesn’t Chef fail when there is a problem?
  • What is the difference between an integration test and a unit test
  • Should I write unit tests or integration tests?

You’ll hear explanations and see visuals to ensure you and your team understand why testing is such a powerful tool and how you can make the right decision when you sit down to deliver your infrastructure. Watch to learn about:

  • Test Kitchen configuration and commands
  • InSpec language fundamentals
  • RSpec’s default conventions and common flags
  • ChefSpec basic structure and helpers

Testing your Chef cookbooks will lead to more confidence when it comes time to deploy your infrastructure. Taking the time to learn these tools will greatly benefit you in your work ahead. Do yourself a favor and start testing.

Keep Learning

Get hands on experience with testing in the Local Development and Testing track on Learn Chef Rally, a learning site for Chef practitioners.

Franklin Webber

College dropout, turned instructor who found software development because everything else in his life was going too well. Forged by the fires of tech support, quality assurance and software development, he now brings technology to the hungry, sullied masses with raw energy, immeasurable empathy and a strong injection of humor.