I tried to summarise years of working with TestProf and help those who have yet to start. The presentation mostly touches the let_it_be and before_all helpers and problems developers could face when start using that
Provokes state leaks between f iles 😕 • Destroying records is also slow 😕 • Advised against in RSpec docs 😕 • Has a dedicated RuboCop https://docs.rubocop.org/rubocop-rspec/ cops_rspec.html#rspecbeforeafterall 😕 35
tests (each in an individual transaction) • Rollback the transaction (much faster than destroying) • … and that’s pretty much what Test Prof’s before_all & let_it_be does. 37
blank • Simple let - > let_it_be replacement might not work • let_it_be is run in before(:all) hook • Sometimes your tests might need serious rearrangement 46
replacement might not work • let_it_be is run in before(:all) hook • let_it_be is order dependent • Sometimes your tests might need serious rearrangement 47
let_it_be replacement might not work • let_it_be is run in before(:all) hook • let_it_be is order dependent • Sometimes your tests might need serious rearrangement 48
replacement might not work • let_it_be is run in before(:all) hook • let_it_be is order dependent • let_it_be doesn’t update associations automatically • Sometimes your tests might need serious rearrangement ✅ ✅ 49
ier, we still might have some state leaks • It is because reload doesn’t work within before_all / before(:all) hooks • Possible solutions: reload manually, freeze objects with freeze modi f ier to prevent updates 51
Suite consisting of one test doesn’t require let_it_be (though it won’t hurt) • Non-factory declarations could bene f it from let • Some suites might bene f it from preferring let to let_it_be 57
can re-use • Might provoke state leaks between f iles (make sure to reload) • Adding just one f ixture may give a signi f icant improvement • https://test-prof.evilmartians.io/recipes/any_ f ixture 68
currently split by example between 4 workers • The feeling is, it decreases the gain we’re getting from let_it_be • The possible side e ff ect: CI nodes become unbalanced • Experiment shows: • RSpec time for slowest node decreased from 6:12 to 5:33 (-11%) • The di ff erence was consumed by CI operations (7:18 vs 7:13) 69