When discussing my article on ServerSpec in the scope integration testing, a colleague of mine asked me why not use InSpec?
This is my response.
Essentially, if you are Chef and TestKitchen, the primary choice will be InSpec hands-down. However, be warned that InSpec is not yet feature parity with ServerSpec, and so may be missing some functionality, such as resources. At the same time, it adds new resources that are not available in ServerSpec.
Outside of Chef, it is one of those answers: It depends.
Both frameworks are flexible and extensible, but in different ways. For change configuration, when combined with the robust TestKitchen tool, InSpec fits in nicely. For building systems or images, such as with the tool Vagrant or Packer, TestKitchen may be overkill, and ServerSpec would be more flexible to kick off some quick tests.
ServerSpec is an extension the ruby RSpec framework. RSpec robust and integrates well into ruby workflow. There are numerous extensions to RSpec, where RSpec is used for not only web application testing with frameworks like Rails, but also change configuration configuration platforms like Puppet with respec-puppet and Chef with ChefSpec.
ServerSpec by proxy of being built on top of RSpec integrates well with ruby workflow. As with other RSpec projects, Rake tool could be the entry point to execute the test suite, and self configures itself with spechelper and specinfra library.
As InSpec functionality is encapsulated within the inspec command line tool, it does not share the same flexibility. With InSpec you would an external tool to orchestrate tests like TestKitchen to test locally and ChefCompliance for testing the infrastructure.
Flexibility: Backend Transport
Both ServerSpec and InSpec support local shell execution and remote execution with SSH, WinRM, and Docker API. ServerSpec gains this functionality through specinfra extensions, and InSpec gets there through the train (transport interface) library.
ServerSpec can use
ssh-config file and has direct integration with Vagrant, while InSpec does not yet have support for
ssh-config files. This makes it cumbersome when working directly with Vagrant or cloud platforms like GCP or AWS that require different private SSH keys.
In the scope of acceptance testing with server integration tests, both tools are similar. ServerSpec is ideal for image or system building with tools Packer or Vagrant, and InSpec is ideal to test final results from change configuration tools.
Lastly, important to mention is that the scope not mentioned is compliance and security, where InSpec excels on as has richer description metadata, context driven tests with levels of criticality rather than all pass or all fail of RSPec.