test-prof 0.4.9 → 0.5.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +63 -20
- data/README.md +10 -57
- data/assets/tagprof.demo.html +447 -0
- data/assets/tagprof.template.html +447 -0
- data/lib/minitest/event_prof_formatter.rb +18 -16
- data/lib/test_prof.rb +2 -1
- data/lib/test_prof/any_fixture.rb +80 -4
- data/lib/test_prof/any_fixture/dsl.rb +18 -0
- data/lib/test_prof/event_prof.rb +10 -108
- data/lib/test_prof/event_prof/custom_events.rb +30 -0
- data/lib/test_prof/event_prof/custom_events/factory_create.rb +1 -1
- data/lib/test_prof/event_prof/custom_events/sidekiq_inline.rb +1 -1
- data/lib/test_prof/event_prof/custom_events/sidekiq_jobs.rb +1 -1
- data/lib/test_prof/event_prof/minitest.rb +6 -0
- data/lib/test_prof/event_prof/profiler.rb +129 -0
- data/lib/test_prof/event_prof/rspec.rb +20 -11
- data/lib/test_prof/factory_all_stub.rb +32 -0
- data/lib/test_prof/factory_all_stub/factory_bot_patch.rb +13 -0
- data/lib/test_prof/factory_doctor/rspec.rb +3 -2
- data/lib/test_prof/factory_prof/printers/flamegraph.rb +9 -13
- data/lib/test_prof/recipes/active_record_shared_connection.rb +55 -0
- data/lib/test_prof/recipes/logging.rb +37 -0
- data/lib/test_prof/recipes/rspec/any_fixture.rb +4 -1
- data/lib/test_prof/recipes/rspec/factory_all_stub.rb +10 -0
- data/lib/test_prof/rspec_dissect/rspec.rb +4 -2
- data/lib/test_prof/rspec_stamp/rspec.rb +3 -2
- data/lib/test_prof/tag_prof.rb +4 -0
- data/lib/test_prof/tag_prof/printers/html.rb +24 -0
- data/lib/test_prof/tag_prof/printers/simple.rb +82 -0
- data/lib/test_prof/tag_prof/result.rb +38 -0
- data/lib/test_prof/tag_prof/rspec.rb +43 -40
- data/lib/test_prof/utils/html_builder.rb +21 -0
- data/lib/test_prof/version.rb +1 -1
- metadata +20 -24
- data/assets/logo.svg +0 -1
- data/assets/testprof.png +0 -0
- data/guides/.rubocop.yml +0 -1
- data/guides/any_fixture.md +0 -114
- data/guides/before_all.md +0 -98
- data/guides/event_prof.md +0 -177
- data/guides/factory_default.md +0 -111
- data/guides/factory_doctor.md +0 -119
- data/guides/factory_prof.md +0 -86
- data/guides/let_it_be.md +0 -97
- data/guides/rspec_dissect.md +0 -60
- data/guides/rspec_stamp.md +0 -52
- data/guides/rubocop.md +0 -48
- data/guides/ruby_prof.md +0 -63
- data/guides/stack_prof.md +0 -47
- data/guides/tag_prof.md +0 -51
- data/guides/tests_sampling.md +0 -24
data/guides/tag_prof.md
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# TagProf
|
2
|
-
|
3
|
-
TagProf is a simple profiler which collects examples statistics grouped by a provided tag value.
|
4
|
-
|
5
|
-
That's pretty useful in conjunction with `rspec-rails` built-in feature – `infer_spec_types_from_location!` – which automatically adds `type` to examples metadata.
|
6
|
-
|
7
|
-
Example output:
|
8
|
-
|
9
|
-
```sh
|
10
|
-
[TEST PROF INFO] TagProf report for type
|
11
|
-
|
12
|
-
type time total %total %time avg
|
13
|
-
|
14
|
-
request 00:04.808 42 33.87 54.70 00:00.114
|
15
|
-
controller 00:02.855 42 33.87 32.48 00:00.067
|
16
|
-
model 00:01.127 40 32.26 12.82 00:00.028
|
17
|
-
```
|
18
|
-
|
19
|
-
|
20
|
-
It shows both the total number of examples in each group and the total time spent (as long as percentages and average values).
|
21
|
-
|
22
|
-
|
23
|
-
## Instructions
|
24
|
-
|
25
|
-
TagProf can only be used with RSpec.
|
26
|
-
|
27
|
-
To activate TagProf use `TAG_PROF` environment variable:
|
28
|
-
|
29
|
-
```sh
|
30
|
-
# Group by type
|
31
|
-
TAG_PROF=type rspec
|
32
|
-
```
|
33
|
-
|
34
|
-
## Pro-Tip: More Types
|
35
|
-
|
36
|
-
By default, RSpec only infers types for default Rails app entities (such as controllers, models, mailers, etc.).
|
37
|
-
Modern Rails applications typically contain other abstractions too (e.g. services, forms, presenters, etc.), but RSpec is not aware of them and doesn't add any metadata.
|
38
|
-
|
39
|
-
That's the quick workaround:
|
40
|
-
|
41
|
-
```ruby
|
42
|
-
RSpec.configure do |config|
|
43
|
-
# ...
|
44
|
-
config.define_derived_metadata(file_path: %r{/spec/}) do |metadata|
|
45
|
-
# do not overwrite type if it's already set
|
46
|
-
next if metadata.key?(:type)
|
47
|
-
match = metadata[:location].match(%r{/spec/([^/]+)/})
|
48
|
-
metadata[:type] = match[1].singularize.to_sym
|
49
|
-
end
|
50
|
-
end
|
51
|
-
```
|
data/guides/tests_sampling.md
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# Tests Sampling
|
2
|
-
|
3
|
-
Sometimes it's useful to run profilers against randomly chosen tests. Unfortunetaly, test frameworks don's support such functionality. That's why we've included small patches for RSpec and Minitest in TestProf.
|
4
|
-
|
5
|
-
|
6
|
-
## Instructions
|
7
|
-
|
8
|
-
Require the corresponding patch:
|
9
|
-
|
10
|
-
```ruby
|
11
|
-
# For RSpec in your spec_helper.rb
|
12
|
-
require 'test_prof/recipes/rspec/sample'
|
13
|
-
|
14
|
-
# For Minitest in your test_helper.rb
|
15
|
-
require 'test_prof/recipes/minitest/sample'
|
16
|
-
```
|
17
|
-
|
18
|
-
And then just add `SAMPLE` env variable with the number of example groups (or suites) you want to run:
|
19
|
-
|
20
|
-
```sh
|
21
|
-
SAMPLE=10 rspec
|
22
|
-
```
|
23
|
-
|
24
|
-
That's it. Enjoy!
|