3

Consider this, I have two cookbooks A and B with each having their own integration testing using serverspec tests and kitchen. Everything works fine if I want to test just one cookbook against its own test suites. Now, if I create a cookbook C that include cookbook A and B along with its own implementation and corresponding integration testing code. Can I reuse the serverspec tests of A and B in C's serverspec tests?

Magnus
  • 73
  • 8
  • if you respect the semantics of `serverspec`, then you could use symbolic links to mange the directory structure. otherwise, you can `require` the file that you need. – Mr. Apr 14 '16 at 19:55

2 Answers2

1

Not currently, other than some manual require '../../../../othercookbook/test/integration/default/serverspec/other_spec' or similar wonkiness which will depend on the precise folder layout you happen to use.

InSpec makes this a bit easier, as both cookbooks could use a single, shared InSpec test profile.

coderanger
  • 52,400
  • 4
  • 52
  • 75
0

I wont comment about Inspec which has its own issues. However to do what you want to I was trying to do something similar without a lot of relative path and weirdness. I found http://serverspec.org/advanced_tips.html helpful especially the part on shared behaviors but the one I found most helpful was http://vincent.bernat.im/en/blog/2014-serverspec-test-infrastructure.html and his source on github. With some easy mods it works better than I hoped and much better than anything I had in InSpec. Hope this help but of course YMMV.