# Testing Chef Recipes

**URL:** <https://discourse.chef.io/t/testing-chef-recipes/15631>\
**Category:** Chef Infra (archive)\
**Created:** [July 23, 2019, 2:55pm UTC](https://discourse.chef.io/t/testing-chef-recipes/15631 "2019-07-23T14:55:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexpatt](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@alexpatt](https://discourse.chef.io/u/alexpatt)\
**Post date:** [July 23, 2019, 2:55pm UTC](https://discourse.chef.io/t/testing-chef-recipes/15631/1 "2019-07-23T14:55:25Z")

</div>

Hey everyone;

I was wondering if there is a best practice for testing your chef cookbooks/recipes before pushing them to production. I can always have a test server that I would run the recipes on first, but after working with chef for a little bit now, I can't help but think there is something more efficient to use that I just don't know about.

P.S. I did try to install test-kitchen, but it gives me an error with the gem installer:

```
ERROR: Error installing test-kitchen:
ERROR: Failed to build gem native extension.

```

Thanks

---

<div class="post-metadata">

**Author:** ![ncerny](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ncerny/32/1319_2.png) [@ncerny](https://discourse.chef.io/u/ncerny)\
**Post date:** [July 23, 2019, 4:37pm UTC](https://discourse.chef.io/t/testing-chef-recipes/15631/2 "2019-07-23T16:37:28Z")

</div>

Hi @alexpatt!

The most simple way to get all the tools you need, is to use Chef Workstation ([https://downloads.chef.io/chef-workstation/0.7.4](https://downloads.chef.io/chef-workstation/0.7.4)) . That will include all the chef components (including test-kitchen) on most modern operating systems.

In order to install test-kitchen from a gem, you need C compilers enabled, as the gems use native extensions. There is a "build\_essentials" resource in the Chef Infra Client that you can use to install those, though I would recommend going with the Workstation approach.

You are absolutely correct that the best way to test your Chef Infra code is to use a combination of test-kitchen and Chef Inspec.

Hope that helps!

Nathan

---

<div class="post-metadata">

**Author:** ![alexpatt](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@alexpatt](https://discourse.chef.io/u/alexpatt)\
**Post date:** [July 23, 2019, 6:30pm UTC](https://discourse.chef.io/t/testing-chef-recipes/15631/3 "2019-07-23T18:30:54Z")

</div>

Hi @ncerny, thanks for the reply!

I've managed to get test-kitchen installed successfully, but when i run the command `kitchen create` the output is

```
-----> Starting Kitchen (v2.2.5)
-----> Creating <default-ubuntu-1804>...
       Bringing machine 'default' up with 'virtualbox' provider...
       ==> default: Checking if box 'bento/ubuntu-18.04' is up to date...
       ==> default: Machine not provisioned because `--no-provision` is specified.
       Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
       Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
       Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
       Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
       Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds

```

and it just keeps hanging on this until I force stop it. My .kitchen.yml file looks like this

```
---
driver:
  name: vagrant
  transport:
    ssh_key: /root/.ssh/id_rsa
    username: ubuntu

provisioner:
  name: chef_zero
  log_level: info

platforms:
  - name: ubuntu-18.04

suites:
  - name: default
    run_list:
      - recipe[standard-server::default]
    attributes:

```

Do you happen to have any ideas as to what could be causing this issue? Thanks again.

---

<div class="post-metadata">

**Author:** ![ncerny](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ncerny/32/1319_2.png) [@ncerny](https://discourse.chef.io/u/ncerny)\
**Post date:** [July 23, 2019, 7:53pm UTC](https://discourse.chef.io/t/testing-chef-recipes/15631/4 "2019-07-23T19:53:27Z")

</div>

Can you open Virtualbox and see if the VM is created? If it's created but appears to be hanging, then you may not have virtualization enabled on your host/desktop/laptop.
