README.md in knapsack_pro-0.40.0 vs README.md in knapsack_pro-0.41.0
- old
+ new
@@ -39,11 +39,11 @@
* API returns which files should be executed on particular CI node (example KNAPSACK_PRO_CI_NODE_INDEX=0)
* when API server has info about previous tests runs then it will use it to return more accurate test split results, in other case API returns simple split based on directory names
* knapsack_pro will run test files which got from API
* after tests finished knapsack_pro will send information about time execution of each file to API http://docs.knapsackpro.com/api/v1/#build_subsets_post so data can be used for future test runs
-The knapsack_pro has also [queue mode](#queue-mode) to get most optimal test suite split.
+The knapsack_pro has also [queue mode](#queue-mode) to get optimal test suite split.
# Requirements
`>= Ruby 2.0.0`
@@ -119,10 +119,12 @@
- [How to split tests based on test level instead of test file level?](#how-to-split-tests-based-on-test-level-instead-of-test-file-level)
- [A. Create multiple small test files](#a-create-multiple-small-test-files)
- [B. Use tags to mark set of tests in particular test file](#b-use-tags-to-mark-set-of-tests-in-particular-test-file)
- [How to make knapsack_pro works for forked repositories of my project?](#how-to-make-knapsack_pro-works-for-forked-repositories-of-my-project)
- [How to use junit formatter?](#how-to-use-junit-formatter)
+ - [How to use junit formatter with knapsack_pro regular mode?](#how-to-use-junit-formatter-with-knapsack_pro-regular-mode)
+ - [How to use junit formatter with knapsack_pro queue mode?](#how-to-use-junit-formatter-with-knapsack_pro-queue-mode)
- [How many API keys I need?](#how-many-api-keys-i-need)
- [What is optimal order of test commands?](#what-is-optimal-order-of-test-commands)
- [How to set `before(:suite)` and `after(:suite)` RSpec hooks in Queue Mode (Percy.io example)?](#how-to-set-beforesuite-and-aftersuite-rspec-hooks-in-queue-mode-percyio-example)
- [How to call `before(:suite)` and `after(:suite)` RSpec hooks only once in Queue Mode?](#how-to-call-beforesuite-and-aftersuite-rspec-hooks-only-once-in-queue-mode)
- [How to run knapsack_pro with parallel_tests gem?](#how-to-run-knapsack_pro-with-parallel_tests-gem)
@@ -393,11 +395,11 @@
#### KNAPSACK_PRO_FIXED_QUEUE_SPLIT (remember queue split on retry CI node)
* `KNAPSACK_PRO_FIXED_QUEUE_SPLIT=false` (default)
- By default, the fixed queue split is off. It means when you will run tests for the same commit hash and a total number of nodes and for the same branch, and the CI build ID is different with second tests run then the queue will be generated dynamically and CI nodes will fetch from Knapsack Pro API the test files in a dynamic way. This is default because it gives the most optimal test suite split for the whole test build across all CI nodes.
+ By default, the fixed queue split is off. It means when you will run tests for the same commit hash and a total number of nodes and for the same branch, and the CI build ID is different with second tests run then the queue will be generated dynamically and CI nodes will fetch from Knapsack Pro API the test files in a dynamic way. This is default because it gives the optimal test suite split for the whole test build across all CI nodes.
* `KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true`
You can enable fixed queue split in order to remember the test suite split across CI nodes when you used Queue Mode.
@@ -887,11 +889,11 @@
Please use fixed version of capybara-screenshot.
```
# Gemfile
group :test do
- gem 'capybara-screenshot', github: 'ArturT/capybara-screenshot', branch: 'fix-reporter_module-loaded-twice'
+ gem 'capybara-screenshot', github: 'mattheworiordan/capybara-screenshot', branch: 'master'
end
```
Here is [fix PR](https://github.com/mattheworiordan/capybara-screenshot/pull/205) to official capybara-screenshot repository and the explanation of the problem.
@@ -1073,18 +1075,34 @@
Now you can use `bin/knapsack_pro_rspec` command instead of `bundle exec rake knapsack_pro:rspec`.
Remember to follow other steps required for your CI provider.
#### How to use junit formatter?
+##### How to use junit formatter with knapsack_pro regular mode?
+
You can use junit formatter for rspec thanks to gem [rspec_junit_formatter](https://github.com/sj26/rspec_junit_formatter).
Here you can find example how to generate `rspec.xml` file with junit format and at the same time show normal documentation format output for RSpec.
# Regular Mode
bundle exec rake "knapsack_pro:rspec[--format documentation --format RspecJunitFormatter --out tmp/rspec.xml]"
+##### How to use junit formatter with knapsack_pro queue mode?
+
+You can use junit formatter for rspec thanks to gem [rspec_junit_formatter](https://github.com/sj26/rspec_junit_formatter).
+
# Queue Mode
- # The xml report will contain all tests executed across intermediate test subset runs based on queue
bundle exec rake "knapsack_pro:queue:rspec[--format documentation --format RspecJunitFormatter --out tmp/rspec.xml]"
+
+The xml report will contain all tests executed across intermediate test subset runs based on work queue. You need to add after subset queue hook to rename `rspec.xml` to `rspec_final_results.xml` thanks to that the final results file will contain only single xml tag with all tests executed on the CI node. This is related to the way how queue mode works. Detailed explanation is in the [issue](https://github.com/KnapsackPro/knapsack_pro-ruby/issues/40).
+
+ # spec_helper.rb or rails_helper.rb
+ KnapsackPro::Hooks::Queue.after_subset_queue do |queue_id, subset_queue_id|
+ # TODO This must be the same path as value for rspec --out argument
+ old_xml_file = 'tmp/rspec.xml'
+ # move results to new_xml_file so the results won't accumulate with duplicated xml tags in old_xml_file
+ new_xml_file = 'tmp/rspec_final_results.xml'
+ FileUtils.mv(old_xml_file, new_xml_file) if File.exists?(old_xml_file)
+ end
#### How many API keys I need?
Basically you need as many API keys as you have steps in your build.