Commit 945b8950 authored by Jamie Tanna's avatar Jamie Tanna
Browse files

Blogument Chef testing reports

Closes #1060.
parent e180c193
Pipeline #278407351 passed with stage
in 2 minutes and 2 seconds
title: "Better Chef Reporting for Automated Pipelines"
description: "How to get better machine-parseable reports for your Chef Pipelines."
date: 2021-03-29T19:39:21+0100
- "blogumentation"
- "chef"
- "jenkins"
- "test-kitchen"
- "rubocop"
- "cookstyle"
- "rspec"
license_code: Apache-2.0
license_prose: CC-BY-NC-SA-4.0
slug: "chef-build-reporting"
image: /img/vendor/chef-logo.png
When building your Chef cookbooks, you likely will want an automated pipeline which allows you to enforce a quality bar for how your cookbooks are developed.
However, you probably want a little more visibility than "did that build succeed", and want to be able to drill into exactly what failed. To do this, across many automated build platforms, like Jenkins, you want to produce a (well) supported machine-parseable format.
One of the most commonly usable formats is the JUnit output format, made popular with the Java testing library JUnit.
Fortunately, all of the Chef tools that we would want to use in a pipeline support the JUnit report format.
# Cookstyle
Because Cookstyle is built upon the wonderful [Rubocop](, which means we can use the inbuild formatters that Rubocop provides, such as [the built-in JUnit formatter](
rubocop --format junit --out test-reports/junit.xml
# or, only show failed Cops
rubocop --format junit --out test-reports/junit.xml --display-only-failed
# RSpec
Unfortunately [RSpec]( doesn't, out of the box, support JUnit format, but there's a great gem `rspec_junit_formatter` which when installed, allows us to run:
rspec --format RspecJunitFormatter --out test-reports/rspec.xml
# Test Kitchen + InSpec
Test Kitchen fortunately supports JUnit format results [out-of-the-box](
name: inspec
- cli
- junit:path/to/results/%{platform}_%{suite}_inspec.xml
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment