1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
# Tests Sampling
Sometimes it's useful to run profilers against randomly chosen tests. Unfortunately, test frameworks don't support such functionality. That's why we've included small patches for RSpec and Minitest in TestProf.
## Instructions
Require the corresponding patch:
```ruby
# For RSpec in your spec_helper.rb
require "test_prof/recipes/rspec/sample"
# For Minitest in your test_helper.rb
require "test_prof/recipes/minitest/sample"
```
And then just add `SAMPLE` env variable with the number examples you want to run:
```sh
SAMPLE=10 rspec
```
You can also run random set of example groups (or suites) using `SAMPLE_GROUPS` variable:
```sh
SAMPLE_GROUPS=10 rspec
```
Note that you can use tests sampling with RSpec filters:
```sh
SAMPLE=10 rspec --tag=api
SAMPLE_GROUPS=10 rspec -e api
```
That's it. Enjoy!
|