Knapsack Pro

Check out the new docs for the updated documentation.

FAQ / knapsack_pro / General questions for knapsack_pro gem

How to run a specific list of test files or only some tests from test file?

Note: If you don't want to use the pattern KNAPSACK_PRO_TEST_FILE_PATTERN (see) to define a list of tests to run then read below two options.

Option 1 - read a list of test files from env var

If you want to run a specific list of test files that are explicitly defined by you or auto-generated by some kind of script you created then please use:


KNAPSACK_PRO_TEST_FILE_LIST=spec/features/dashboard_spec.rb,spec/models/user.rb:10,spec/models/user.rb:29

Note KNAPSACK_PRO_TEST_FILE_LIST must be a list of test files comma separated. You can provide line number for tests inside of spec file in case of RSpec (this way you can run only one test or a group of tests from RSpec spec file). You can provide the same file a few times with different test line number.

Option 2 - read a list of test files from a source file

Similarly, you can also provide a source file containing the test files that you would like to run. This might be useful when you have a very large list of test files.

For example: KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE=spec/fixtures/test_file_list_source_file.txt And the content of the source file can be any of the format below:

./spec/test1_spec.rb
spec/test2_spec.rb[1]
./spec/test3_spec.rb[1:2:3:4]
./spec/test4_spec.rb:4
./spec/test4_spec.rb:5

Note that each of the line must be ending with \n the new line.

important

Note when you set KNAPSACK_PRO_TEST_FILE_LIST or KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE then below environment variables are ignored:

  • KNAPSACK_PRO_TEST_FILE_PATTERN
  • KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN

# General questions for knapsack_pro gem
See questions outside of this category

Start using Knapsack Pro

Sign up and speed up your tests.

Get started free