3

I'm trying to output text to console during tests, to know what happens and have an history of the tests, but nothing seems to work, not printf, neither $stdout.write.

Should I just use a text log file and be done with it or it's possible to output to jenkins console?

3 Answers 3

2

As explained in https://content.pivotal.io/blog/what-happened-to-stdout-on-ci and https://github.com/ci-reporter/ci_reporter#environment-variables, you need to set CI_CAPTURE=off

Sign up to request clarification or add additional context in comments.

Comments

1

Here is a copy of my jenkins config for running RSpec tests of a Rails app in Jenkins:

[ -d jenkins ] && rm -rf jenkins
mkdir jenkins

cp ~/configs/yourApp/default-db-config config/database.yml

rake db:migrate
rake db:test:prepare

export RAILS_ENV=test
export SPEC_OPTS="--no-drb --format documentation --format html --out jenkins/rspec.html"

rake spec

First it deletes any previous test history from the workspace if it exists. Next it creates a jenkins directory in the workspace for storing the test output.

Then it sets up the app for testing with a working DB config (I don't store DB config files in my git repo).

Finally it migrates the dev DB if required, prepares the test DB, sets the RAILS_ENV to test and runs the tests with the specified SPEC_OPTS.

The important bits are as follows:

--format documentation ... this sends sensible output of test progress to your console log. Write your tests properly and this will be infinitely more useful than any puts commands you might have considered using.

--format html ... this outputs HTML files of the test results to the jenkins directory created earlier and specified in the --out attribute. Add the following to your job description to show those results on the main page of this job:

<iframe src='http://jenkins.your-domain.com/job/your-tests/ws/jenkins/rspec.html' width="100%" height="600" frameborder="0"/>

Hopefully that should get you up and running with a more useful jenkins test job for RSpec.

Comments

0

Not sure if Jenkins will change this (I don't think so), but in Rspec you can write

puts response.body

or

puts "My mommy made me mash my M&M's"

or whatever else you want and it will be put in the console/results

1 Comment

puts doesn't show in the output console either. The only output I get is something along the lines of: # Running tests: `` ............................................... Finished tests in 7.747092s, 42.2094 tests/s, 581.2504 assertions/s. 327 tests, 4503 assertions, 0 failures, 0 errors, 0 skips Coverage report Rcov style generated for Cucumber Features, Unit Tests to folder/rcov Recording test results Publishing rcov report... Finished: SUCCESS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.