Releases: 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_duplicates
option forlet_it_be
(to warn or raise if a let_it_be declaration has been overridden in the nested context).
1.3.0
1.2.0
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 | true
configuration 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_default
intocreate
) by setting theFACTORY_DEFAULT_DISABLED=1
environmental variable.
Before All
- Added tags support to
before_all
hooks.
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.
1.0.11
1.0.7
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_heckler
mode 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)
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_dump
to 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_all
to Minitest in addition tobefore_all
. -
Add support for RSpec aliases detection when linting specs using
let_it_be
/before_all
withrubocop-rspec
2.0.
Changes
-
Minitest's
before_all
is not longer experimental. -
Remove deprecated
AggregateFailures
cop. -
Remove
ActiveRecordSharedConnection
. -
Replaced
TestProf::AnyFixture.reporting_enabled = true
withTestProf::AnyFixture.config.reporting_enabled = true
.
0.12.0
Features
- Added state leakage detection for
let_it_be
.
See documentation.
- Added ability to configure default
let_it_be
modifiers.
TestProf::LetItBe.configure do |config|
# Make refind activated by default
config.default_modifiers[:refind] = true
end
- Added ability to configure
let_it_be
modifiers 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_INTERVAL
env 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.
0.10.0
Features
- Add ability to add custom
let_it_be
modifiers.
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_be
with modifiers.
# Now you can use modifiers with arrays
let_it_be(:posts, reload: true) { create_pair(:post) }
Other
- Print warning when
ActiveRecordSharedConnection
is used in the version of Rails
supportinglock_threads
(5.1+).