New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rspec output should be configurable #9

Closed
tolleiv opened this Issue May 23, 2014 · 11 comments

Comments

Projects
None yet
8 participants
@tolleiv
Copy link

tolleiv commented May 23, 2014

Hi,

especially when using test-kitchen / busser within a CI system it's quite odd that the test result output is just part of the stdout stream. It would be great if you could allow to pass other formatter options to rspec / serverspec. So that HTML or junit reports could be generated from the testruns.

Cheers

@lsimons

This comment has been minimized.

Copy link

lsimons commented Jul 31, 2014

+1

My own 'fix' right now is along the lines of lsimons@01ca795, patching things up by hard coding in junit report outputs.

@cl-lab-k

This comment has been minimized.

Copy link
Contributor

cl-lab-k commented Aug 1, 2014

i think this feature is not only in busser-serverspec but also in test-kitchen / busser.
would you please open issue at test-kitchen for a starter?

@cl-lab-k cl-lab-k added the question label Aug 22, 2014

@jsirex

This comment has been minimized.

Copy link

jsirex commented Aug 29, 2014

@lsimons, how do you get report from test machine on host?
I'm using kitchen-docker and has the same problem. I have report, but it inside vm.

@buettner123

This comment has been minimized.

Copy link

buettner123 commented Sep 9, 2014

I needed to format my serverspec results in JUnit xml format (I used the yarjuf gem for doing this). After some research I found out, how to do this with the default busser-serverspec.
I added the following lines to the spec_helper.rb of the serverspec tests:

require 'yarjuf'

RSpec.configure do |c|
  [...]
  c.output_stream = File.open('serverspec-result.xml', 'w')
  c.formatter = 'JUnit'
end

Further I had the problem that the busser environment did not install the yarjuf gem on its own. I found a workaround, described here: https://gist.github.com/juanje/9603938.

After this my spec_helper.rb looked like this:

$LOAD_PATH << '../lib' # add ../lib to the $LOAD_PATH so busser-serverspec can find the yarjuf lib
require 'busser/rubygems'
Busser::RubyGems.install_gem('yarjuf', '~> 1.0.6') # version 1.0.6 because busser-serverspec seems to be using rspec 2.x instead of 3.x

require 'serverspec'
require 'yarjuf'

include SpecInfra::Helper::Exec
include SpecInfra::Helper::DetectOS

RSpec.configure do |c|
  if ENV['ASK_SUDO_PASSWORD']
    require 'highline/import'
    c.sudo_password = ask('Enter sudo password: ') { |q| q.echo = false }
  else
    c.sudo_password = ENV['SUDO_PASSWORD']
  end

  c.output_stream = File.open('serverspec-result.xml', 'w')
  c.formatter = 'JUnit'
end

this did the job for me.

@cl-lab-k

This comment has been minimized.

Copy link
Contributor

cl-lab-k commented Sep 26, 2014

FYI, busser-serverspec 0.2.7 now can handle Gemfile. you can install gem you need using Gemfile.

@cstewart87

This comment has been minimized.

Copy link

cstewart87 commented Nov 24, 2014

@buettner123 Thanks for the tip! My test results are output, but they're on the test-kitchen instance. Is there a way to output the results to the host running test-kitchen?

@buettner123

This comment has been minimized.

Copy link

buettner123 commented Nov 26, 2014

@cstewart87 I used this in a kitchen/docker enviroment where I could copy the file from the docker container to the host. If you are using vagrant a synced folder will propably work for you.

@ytsarev

This comment has been minimized.

Copy link

ytsarev commented Jul 16, 2015

test-kitchen/test-kitchen#783

Here I implemented generic way to get a file from an instance to host.

@atward

This comment has been minimized.

Copy link

atward commented Oct 8, 2015

+1 for this. Though the solution should really be provided upstream in test-kitchen/busser, as it stand the format options are implemented in each busser plugin.

For anyone using TeamCity, CI integration works using rspec-teamcity.

# test/integration/helpers/serverspec/Gemfile
gem 'rspec-teamcity'
# test/integration/helpers/serverspec/spec_helper.rb
require 'rspec/teamcity'
RSpec.configure do |config|
  config.add_formatter Spec::Runner::Formatter::TeamcityFormatter
end

Output isn't pretty as it still includes color + documentation formatter passed in by busser-serverspec, but results are extracted as expected.

@cl-lab-k

This comment has been minimized.

Copy link
Contributor

cl-lab-k commented Feb 12, 2016

you can use shell verifer instead of busser, it lets serverspec run with any options.

here is my shell verifer and serverspec example:
https://github.com/cl-lab-k/apache2-take/tree/shell_verifier

I have no plan to make any drastic changes to busser-serverspec.
And I think shell-verifier + serverspec is better choice for testing cookbooks than busser verifier + busser-serverspec.
So I am preparing the document for translation frombusser verifier + busser-serverspec to shell-verifier + serverspec.
If the document is prepared, I will put link to it in README.

@cl-lab-k cl-lab-k closed this Feb 12, 2016

@cl-lab-k

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment