Recent Releases of https://github.com/test-prof/test-prof
https://github.com/test-prof/test-prof - 1.4.0
Features
-
Rails 7.2 compatibility.
-
Added variations support to FactoryProf.
Now you can also see which traits and overrides have been used by factories.
-
Added Fabrication support to FactoryDefault.
-
Added
report_duplicatesoption forlet_it_be(to warn or raise if a let_it_be declaration has been overridden in the nested context).
- Ruby
Published by palkan over 1 year ago
https://github.com/test-prof/test-prof - 1.3.0
Features
- Added Vernier integration.
- Added MemoryProf.
Changes
- StackProf now uses JSON format by default.
- Ruby
Published by palkan over 1 year ago
https://github.com/test-prof/test-prof - 1.2.0
Features
before_all/let_it_benow support Active Record multi-database configuration.
- Ruby
Published by palkan about 3 years ago
https://github.com/test-prof/test-prof - 1.1.0
Highlights
- Added Factory Default (or factory associations) profiler and FactoryDefault usage stats.
Factory Default profiles shows which factories (and variations) were created via associations and how many times. This information can help you estimate the effect of adding a default record.
Here is an example report:
$ FACTORY_DEFAULT_PROF=1 bin/rspec
[TEST PROF INFO] Factory associations usage:
factory count total time
track 281 00:12.671
user{organization:<Organization#<id>>} 62 00:05.830
user 46 00:04.401
assessment 6 00:02.599
specialist_vertical 24 00:02.209
user[without_plan] 16 00:01.201
organization 352 00:01.138
admin 341 00:00.999
After adding default factory records, you can now also get the information about the actual usage:
$ FACTORY_DEFAULT_STATS=1 bin/rspec spec/models/user_spec.rb
[TEST PROF INFO] FactoryDefault usage stats:
factory hit miss
track 224 51
admin 83 0
organization 77 89
user 51 82
FactoryDefault summary: hit=435 miss=222
Factory Default
- Added
skip_factory_default(&block)to temporary disable default factories.
You can also use TestProf::FactoryDefault.disable!(&block).
- Defaults now could be created per trait (or set of traits).
Now create_default(:user) and create_default(:user, :admin) would result into two defaults corresponding to the specified traits.
- Added
preserve_attributes = false | trueconfiguration option.
Allow skipping defaults if association is defined with overrides, e.g.:
factory :post do
association :user, name: "Post Author"
end
- Added ability to dynamically disable Factory Default (turn
create_defaultintocreate) by setting theFACTORY_DEFAULT_DISABLED=1environmental variable.
Before All
- Added tags support to
before_allhooks.
TestProf::BeforeAll.configure do |config|
config.before(:begin, reset_sequences: true, foo: :bar) do
warn <<~MESSAGE
Do NOT create objects outside of transaction
because all db sequences will be reset to 1
in every single example, so that IDs of new objects
can get into conflict with the long-living ones.
MESSAGE
end
end
- Support using Factory Default within
before_all/let_it_be.
Default factories created within before_all or let_it_be are not reset 'till the end of the corresponding context. Thus, now it's possible to use create_default within let_it_be without any additional hacks. Currently, RSpec only.
Fixes
- Records created with
let_it_be(:x, freeze: true)are now frozen during initialization, not at the access (let) time.
- Ruby
Published by palkan about 3 years ago
https://github.com/test-prof/test-prof - 1.0.11
Features
- Added
TEST_STACK_PROF_IGNORE_GCenv variable to ignore GC frames from collection.
Fixes
-
Fix monitoring methods with keyword args in Ruby 3+.
-
Fixed restoring
lock_threadvalue in nested contexts.
- Ruby
Published by palkan over 3 years ago
https://github.com/test-prof/test-prof - 1.0.7
-
Added experimental support for using
before_allwith Rails' test parallelization using processes.
Make sure to includeTestProf::BeforeAll::Minitestbefore you callparallelize. -
Fixed access to
let_it_bevariables inafter(:all)hook.
- Ruby
Published by palkan over 4 years ago
https://github.com/test-prof/test-prof - 1.0.4
Features
- Add ability to use custom logger.
TestProf.configure do |config|
config.logger = Logger.new($stdout, level: Logger::WARN)
end
- Add
nate_hecklermode for FactoryProf.
Drop this into your rails_helper.rb or test_helper.rb:
require "test_prof/factory_prof/nate_heckler"
And for every test run see the overall factories usage:
[TEST PROF INFO] Time spent in factories: 04:31.222 (54% of total time)
- Ruby
Published by palkan almost 5 years ago
https://github.com/test-prof/test-prof - 1.0.0
This is the first major version of TestProf: the APIs have been stabilized, all the features we planned initially have been implemented and battle-tested. The work on v1.x will continue (mostly, maintenance, minor features), and the work on new version, v2, is starting.
P.S. You can support us on GitHub Sponsors.
Features
- Add
AnyFixture#register_dumpto cache fixtures using SQL dumps.
- Make Rails fixtures accesible in
before_all.
You can load and access fixtures when explicitly enabling them via before_all(setup_fixtures: true, &block).
-
Add
after_allto Minitest in addition tobefore_all. -
Add support for RSpec aliases detection when linting specs using
let_it_be/before_allwithrubocop-rspec2.0.
Changes
-
Minitest's
before_allis not longer experimental. -
Remove deprecated
AggregateFailurescop. -
Remove
ActiveRecordSharedConnection. -
Replaced
TestProf::AnyFixture.reporting_enabled = truewithTestProf::AnyFixture.config.reporting_enabled = true.
- Ruby
Published by palkan about 5 years ago
https://github.com/test-prof/test-prof - 0.12.0
Features
- Added state leakage detection for
let_it_be.
See documentation.
- Added ability to configure default
let_it_bemodifiers.
TestProf::LetItBe.configure do |config|
# Make refind activated by default
config.default_modifiers[:refind] = true
end
- Added ability to configure
let_it_bemodifiers via metadata.
context "with let_it_be reload", let_it_be_modifiers: {reload: true} do
# examples
end
- Added ability to define stackprof's interval sampling by using
TEST_STACK_PROF_INTERVALenv variable.
Now you can use $ TEST_STACK_PROF=1 TEST_STACK_PROF_INTERVAL=10000 rspec to define a custom interval (in microseconds).
Changes
- Dropped Ruby 2.4 support.
Fixes
-
SAMPLE and SAMPLE_GROUP work consistently with seed in RSpec and Minitest.
-
Make sure EventProf is not affected by time freezing.
EventProf results now is not affected by Timecop.freeze or similar.
See more in #181.
- Ruby
Published by palkan over 5 years ago
https://github.com/test-prof/test-prof - 0.10.0
Features
- Add ability to add custom
let_it_bemodifiers.
In addition to two built-in modifiers (reload and refind), you can add your own:
TestProf::LetItBe.config.register_modifier :reload do |record, val|
# ignore when `reload: false`
next record unless val
# ignore non-ActiveRecord objects
next record unless record.is_a?(::ActiveRecord::Base)
record.reload
end
Changes
- Use RSpec example ID instead of full description for RubyProf/Stackprof report names.
For more complex scenarios feel free to use your own report name generator:
# for RubyProf
TestProf::RubyProf::Listener.report_name_generator = ->(example) { "..." }
# for Stackprof
TestProf::StackProf::Listener.report_name_generator = ->(example) { "..." }
- Support arrays in
let_it_bewith modifiers.
# Now you can use modifiers with arrays
let_it_be(:posts, reload: true) { create_pair(:post) }
Other
- Print warning when
ActiveRecordSharedConnectionis used in the version of Rails
supportinglock_threads(5.1+).
- Ruby
Published by palkan over 6 years ago
https://github.com/test-prof/test-prof - 0.9.0
This release is inspired by ideas discussed and implemented in this PR to Discourse. Specials thanks to @danielwaterworth and @SamSaffron.
tl;dr before_all hooks, let_it_be aliases, better Fabrication support.
before_all
- Added global callbacks to
before_all.
Now you can execute additional code before and after every before_all transaction begins and rollbacks:
TestProf::BeforeAll.configure do |config|
config.before(:begin) do
# do something before transaction opens
end
config.after(:rollback) do
# do something after transaction closes
end
end
let_it_be
- Added ability to use
let_it_bealiases with predefined options.
TestProf::LetItBe.configure do |config|
config.alias_to :let_it_be_with_refind, refind: true
end
Then use it in your tests:
describe "smth" do
let_it_be_with_refind(:foo) { Foo.create }
# refind can still be overridden
let_it_be_with_refind(:bar, refind: false) { Bar.create }
end
FactoryProf
- Added timings to FactoryProf report.
[TEST PROF INFO] Factories usage
Total: 15285
Total top-level: 10286
Total time: 299.5937s
Total uniq factories: 119
total top-level total time top-level time name
6091 2715 115.7671s 50.2517s user
2142 2098 93.3152s 92.1915s post
FactoryDoctor
-
Added Fabrication support.
-
Added threshold and instrumentation event customization.
NOTE: default threshold is 0.01s (i.e. if the DB time is less for the example, we consider it "good").
$ FDOC=1 FDOC_EVENT="sql.rom" FDOC_THRESHOLD=0.1 rspec
EventProf
- Added
guardandtop_leveloptions toEventProf::Monitor.
For example:
TestProf::EventProf.monitor(
Sidekiq::Client,
"sidekiq.inline",
:raw_push,
# top_level: true means that we do not trigger events when the method is
# called recursively within itself
top_level: true,
# only trigger the event when guard returns `true`
guard: ->(*) { Sidekiq::Testing.inline? }
)
- Added Fabrication support for
factory.createevent.
- Ruby
Published by palkan almost 7 years ago
https://github.com/test-prof/test-prof - 0.8.0 "To the future 🚀"
Cosmonautics Day special.
Major changes
This release makes Ruby 2.4+ required and also RSpec 3.5+ required (for RSpec-related functionality).
Features
- Make
before_allcompatible withisolator.
- Add
with_loggingandwith_ar_logginghelpers to logging recipe.
- Ruby
Published by palkan almost 7 years ago
https://github.com/test-prof/test-prof - 0.7.5
Changes
Make let_it_be and before_all work with include_context in RSpec.configure.
Fixes #117
- Ruby
Published by palkan about 7 years ago
https://github.com/test-prof/test-prof - 0.7.4
Features
- Add JSON report support for StackProf.
Use TEST_STACK_PROF_FORMAT=json to generate a JSON dump (e.g. to use with https://www.speedscope.app)
- Add ability to specify report/artifact name suffixes.
Use TEST_PROF_REPORT env variable to add custom suffix to generated reports (to distinguish runs from each other).
- Ruby
Published by palkan about 7 years ago
https://github.com/test-prof/test-prof - 0.7.3
Features
- Added header with the general factories usage stats to FactoryProf report (PR):
[TEST PROF INFO] Factories usage
# new is added
Total: 12321
Total top-level: 3234
Total uniq factories: 42
# then goes the existing table
total top-level name
# ...
- Added event time percentage to EventProf report (PR):
[TEST PROF INFO] EventProf results for factory.create
Total time: 03:07.353 of 07:25:232 (42.02%)
Total events: 7459
Something (./my_spec.rb:21) – 09:16.100 (7 / 3) of 12:29:233 (74.13%)
Improvements
- Test sampling now allows to sample examples and preserver RSpec filters (PR):
# runs 10 random test examples
SAMPLE=10 rake test
# runs 10 random example groups
SAMPLE_GROUPS=10 rake test
# run 10 random examples with filtering
SAMPLE=10 rspec --tag slow
From Cult of Martians.
- Ruby
Published by palkan over 7 years ago
https://github.com/test-prof/test-prof -
Ruby 2.3+ is required
- Ruby
Published by palkan over 7 years ago
https://github.com/test-prof/test-prof - 0.6.0 "Crusty Baguette" 🇫🇷🥖
Paris.rb 2018 special.
Features
- Add
EventProf.monitorto instrument arbitrary methods 📝 Docs
Add custom instrumetation easily:
class Work
def do
# ...
end
end
# Instrument Work#do calls with "my.work" event
TestProf::EventProf.monitor(Work, "my.work", :do)
- Adapterize
before_all📝 Docs
Now it's possible to write your own adapter for before_all to manage
transactions.
- Add
before_allfor Minitest 📝 Docs
Fixes & Improvements
- Show top
letdeclarations per example group in RSpecDissect profiler.
The output now includes the following information:
Top 5 slowest suites (by `let` time):
FunnelsController (./spec/controllers/funnels_controller_spec.rb:3) – 00:38.532 of 00:43.649 (133)
↳ user – 3
↳ funnel – 2
ApplicantsController (./spec/controllers/applicants_controller_spec.rb:3) – 00:33.252 of 00:41.407 (222)
↳ user – 10
↳ funnel – 5
Enabled by default. Disable it with:
TestProf::RSpecDissect.configure do |config|
config.let_stats_enabled = false
end
- Added ability to preserve traits in
FactoryDefault. 📝 Docs
Disabled by default for compatibility.
Enable globally by FactoryDefault.preserve_traits = true or for a single create_default: create_default(:user, preserve_traits: true)
When enabled the default object is only used when there's no traits in the association.
-
Add ability to run only
letorbeforeprofiler with RSpecDissect. -
Collect raw data with StackProf by default.
-
Refactor
:with_clean_fixtureto clean data once per group. -
Fix
RSpec/Aggregatefailures with non-regular examples.
Do not take into account xit, pending, its, etc. examples,
only consider regular it, specify, scenario, example.
- Ruby
Published by palkan over 7 years ago
https://github.com/test-prof/test-prof - 0.5.0 "Sunny Balkans" ☀️ ⛰
BalkanRuby 2018 special.
TestProf documentation now lives here: https://test-prof.evilmartians.io.
Features
- Add events support to TagProf. 📝 Docs
Example usage:
TAG_PROF=type TAG_PROF_EVENT=sql.active_record rspec
- Add logging helpers for Rails. 📝 Docs
Enalbe verbose logging globally:
LOG=all rspec
Or per example (group):
it 'does smth weird', :log do
# ...
end
- Add HTML report for
TagProf.
Generate HTML report by setting TAG_PROF_FORMAT to html.
-
Add ability to track multiple events at the same time with
EventProf. -
Add
AnyFixtureDSL. 📝 Docs
Example:
# Enable DSL
using TestProf::AnyFixture::DSL
# and then you can use `fixture` method (which is just an alias for `TestProf::AnyFixture.register`)
before(:all) { fixture(:account) }
# You can also use it to fetch the record (instead of storing it in instance variable)
let(:account) { fixture(:account) }
- Add
AnyFixtureusage report. 📝 Docs
Enable AnyFixture usage reporting with ANYFIXTURE_REPORTING=1 or with:
TestProf::AnyFixture.reporting_enabled = true
- Add
ActiveRecordSharedConnectionrecipe. 📝 Docs
Force ActiveRecord to use the same connection between threads (to avoid database cleaning in browser tests).
NOTE: For Rails <5.1.
Fixes & Improvements
- Disable referential integrity when cleaning AnyFixture.
- Ruby
Published by palkan almost 8 years ago
https://github.com/test-prof/test-prof -
Features
-
EventProf now works with Minitest. (#29)
-
Fabrication support for FactoryProf added. (#30)
- Ruby
Published by palkan over 8 years ago
https://github.com/test-prof/test-prof -
This release bring some new features as long as bug fixes and improvements (see Changelog).
RSpecDissect profiler
RSpecDissect tracks how much time do you spend in before hooks
and memoization helpers (i.e. let) in your tests:
RD_PROF=1 rspec ...
[TEST PROF INFO] RSpecDissect enabled
Total time: 25:14.870
Total `before(:each)` time: 14:36.482
Total `let` time: 19:20.259
Top 5 slowest suites (by `before(:each)` time):
Webhooks::DispatchTransition (./spec/services/webhooks/dispatch_transition_spec.rb:3) – 00:29.895 of 00:33.706 (327)
FunnelsController (./spec/controllers/funnels_controller_spec.rb:3) – 00:22.117 of 00:43.649 (133)
...
let_it_be helper for RSpec
Just like let, but persist the result for the whole group (i.e. let + before_all).
RSpecStamp improvements
RSpecStamp is now integrated with FactoryDoctor, EventProf and RSpecDissect to automatically mark slow (or bad) examples and groups with custom tags:
EVENT_PROF="sql.active_record" EVENT_PROF_STAMP="slow:sql" rspec ...
After running the command above the top 5 slowest example groups would be marked with slow: :sql tag.
- Ruby
Published by palkan over 8 years ago
https://github.com/test-prof/test-prof - v0.2.5
Ruby 2.2.x support has been added.
- Ruby
Published by palkan over 8 years ago