diff --git a/README.md b/README.md index f5a285a..27aa2d1 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,17 @@ Execute tests: $ bundle exec turbo_tests ``` +To enable support for RSpec Junit formatting (ie for CircleCI), include `rspec_junit_formatter` in Gemfile, and pass the `-r rspec_junit_formatter` option. Output will be written to `rspec/rspec#{TEST_ENV_NUMBER}.xml` files. Update your Circle CI config: + +```yml +# .circleci/config.yml +- run: + name: RSpec + command: bundle exec turbo_tests -r rspec_junit_formatter +- store_test_results: + path: rspec +``` + Show help: ```bash diff --git a/lib/turbo_tests/runner.rb b/lib/turbo_tests/runner.rb index 026d593..e123311 100644 --- a/lib/turbo_tests/runner.rb +++ b/lib/turbo_tests/runner.rb @@ -155,11 +155,21 @@ def start_subprocess(env, extra_args, tests, process_id, record_runtime:) [] end + junit_options = if defined?(RspecJunitFormatter) + [ + "--format", "RspecJunitFormatter", + "--out", "rspec/rspec#{process_id}.xml" + ] + else + [] + end + command = [ *command_name, *extra_args, *seed_option, "--format", "TurboTests::JsonRowsFormatter", + *junit_options, *record_runtime_options, *tests, ]