File: tests_sampling.md

package info (click to toggle)
ruby-test-prof 1.6.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,448 kB
  • sloc: ruby: 13,093; sh: 4; makefile: 4
file content (36 lines) | stat: -rw-r--r-- 831 bytes parent folder | download
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!