とーますメモ

Ruby on Rails / Goなどの学習メモ

【CircleCI2.0】Rspecの並行テストの設定

RailsのCircleCIのサンプルyml(Sample.yml)を見ると
以下のような記述がある

# run tests!
- run:
    name: run tests
    command: |
      mkdir /tmp/test-results
      TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"

      bundle exec rspec --format progress \
                      --format RspecJunitFormatter \
                      --out /tmp/test-results/rspec.xml \
                      --format progress \
                      "${TEST_FILES}"

初見では、正直何をやってるのかわからなかったが
rspecでテストを行っているコードなのはわかる。

試しに動作させてみると、こんなエラーがでたが

LoadError: cannot load such file -- rspec_junit_formatter

よく調べてみると、これは「rspec_junit_formatter」というgemを
入れてないから発生していたエラーだった。

とりあえずインストールしたら、

gem install rspec_junit_formatter

ちゃんと動作した。


[参考]
discuss.circleci.com
codenote.net