Skip to content

Latest commit

 

History

History
71 lines (56 loc) · 3.01 KB

TESTING.md

File metadata and controls

71 lines (56 loc) · 3.01 KB

Testing Documentation

Prerequisites

VSTS Build Agent cookbook requires ChefDK installation - download it here.

Integration testing uses Hashicorp's Vagrant and Oracle's Virtualbox, which must be installed first.

You'll also need the following from VSTS:

Integration testing using boxes and Virtualbox

Integration tests are orchestrated by test-kitchen. Although Linux boxes are freely available from Vagrant's repository, for Mac and Windows, you'll need to build your own using Hashicorp's Packer.

Guides for building Mac and Windows boxes

Running the tests

Set environment variables

Windows:

set VSTS_URL='https://account.visualstudio.com'
set VSTS_POOL=default
set VSTS_USER=username
set VSTS_TOKEN=my_secret_token_from_vsts
set VSTS_DEPLOYMENT_GROUP_NAME=test-chef-deployment
set VSTS_DEPLOYMENT_GROUP_PROJECT=test

Linux / Mac:

export VSTS_URL='https://account.visualstudio.com'
export VSTS_POOL=default
export VSTS_USER=username
export VSTS_TOKEN=my_secret_token_from_vsts
export VSTS_DEPLOYMENT_GROUP_NAME=test-chef-deployment
export VSTS_DEPLOYMENT_GROUP_PROJECT=test

If the username of the box you're testing differs from standard "vagrant":

export BOX_USERNAME=username

Executing the tests

The kitchen test instance states are in order: destroy, create, converge, setup, verify, destroy. kitchen test changes the state of one or more instances to destroyed, then executes the actions for each state up to destroy. At any sign of failure, executing the actions stops and the instance is left in the last successful execution state.

kitchen test VAGRANT_BOX_NAME

Examples:

$ kitchen test osx1010
$ kitchen test windows_2012_r2
$ kitchen test ubuntu1604

🔺 The Windows and Mac boxes must be built prior to testing. Once built, you'll need to modify the .kitchen.yml file. To find out list of available boxes and their names, simply execute vagrant box list. See the Chef documentation or comments in .kitchen.yml for how to modify it for your boxes.

Style Testing

Several style checks can be performed by running any of the following:

$ chef exec rake style
$ rake style
$ foodcritic .
$ rubocop .