From f9d5050d93c702a1ad5267874c2108c8fad795d3 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Thu, 6 Mar 2025 15:24:49 +0100 Subject: [PATCH 1/4] update(docs): Missing test execution times in Minitest --- docusaurus/docs/ruby/troubleshooting.mdx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docusaurus/docs/ruby/troubleshooting.mdx b/docusaurus/docs/ruby/troubleshooting.mdx index 2ae219c6..8ab15a07 100644 --- a/docusaurus/docs/ruby/troubleshooting.mdx +++ b/docusaurus/docs/ruby/troubleshooting.mdx @@ -516,3 +516,27 @@ Please consider: - [Splitting by test examples](split-by-test-examples.mdx) if you have a bottleneck file that is packed with test examples - If it's a retry, remember that [`KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true`](reference.md#knapsack_pro_fixed_queue_split-queue-mode) uses a cached split + +## Missing test execution times in Minitest + +Test execution times are not measured if you use the `minitest-spec-rails` gem with the not-recommended test style: + +```ruby +require 'test_helper' +describe User do + # THIS IS NOT RECOMMENDED! +end +``` + +Please use [the recommended style as suggested in the minitest-spec-rails documentation](https://github.com/metaskills/minitest-spec-rails?tab=readme-ov-file#test-styles). +Only then Knapsack Pro can measure test execution times. + +```ruby +require 'test_helper' +class UserTest < ActiveSupport::TestCase + let(:user_ken) { User.create! :email => 'ken@metaskills.net' } + it 'works' do + expect(user_ken).must_be_instance_of User + end +end +``` From 499746643d994e74ba3d5164720167d2d214c469 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Thu, 6 Mar 2025 17:31:44 +0100 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Riccardo --- docusaurus/docs/ruby/troubleshooting.mdx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/docusaurus/docs/ruby/troubleshooting.mdx b/docusaurus/docs/ruby/troubleshooting.mdx index 8ab15a07..3054bada 100644 --- a/docusaurus/docs/ruby/troubleshooting.mdx +++ b/docusaurus/docs/ruby/troubleshooting.mdx @@ -517,21 +517,17 @@ Please consider: - [Splitting by test examples](split-by-test-examples.mdx) if you have a bottleneck file that is packed with test examples - If it's a retry, remember that [`KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true`](reference.md#knapsack_pro_fixed_queue_split-queue-mode) uses a cached split -## Missing test execution times in Minitest +## Execution times are all 0 seconds in Minitest -Test execution times are not measured if you use the `minitest-spec-rails` gem with the not-recommended test style: +When using `minitest-spec-rails`, avoid the [unsupported *outer describe*](https://github.com/metaskills/minitest-spec-rails). Otherwise, Knapsack Pro won't be able to track the execution time of each test. ```ruby +# ⛔️ Bad require 'test_helper' describe User do - # THIS IS NOT RECOMMENDED! end -``` - -Please use [the recommended style as suggested in the minitest-spec-rails documentation](https://github.com/metaskills/minitest-spec-rails?tab=readme-ov-file#test-styles). -Only then Knapsack Pro can measure test execution times. -```ruby +# ✅ Good require 'test_helper' class UserTest < ActiveSupport::TestCase let(:user_ken) { User.create! :email => 'ken@metaskills.net' } @@ -539,4 +535,3 @@ class UserTest < ActiveSupport::TestCase expect(user_ken).must_be_instance_of User end end -``` From 6592f01e183cb946215a224b0e5e654998d2f304 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Thu, 6 Mar 2025 17:33:05 +0100 Subject: [PATCH 3/4] update(troubleshooting ruby): Remove entry: NameError: uninitialized constant MyModule::MyModelName --- docusaurus/docs/ruby/troubleshooting.mdx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docusaurus/docs/ruby/troubleshooting.mdx b/docusaurus/docs/ruby/troubleshooting.mdx index 3054bada..2d913b2f 100644 --- a/docusaurus/docs/ruby/troubleshooting.mdx +++ b/docusaurus/docs/ruby/troubleshooting.mdx @@ -5,10 +5,6 @@ pagination_prev: null # Ruby Troubleshooting -## `NameError: uninitialized constant MyModule::MyModelName` - -Try with full namespacing `::SomeModule::MyModule::MyModelName`. - ## Debug Knapsack Pro on your development environment/machine ### Regular Mode From 1b1de6c1f1309818680f1ebf8e691dbff3382e94 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Thu, 6 Mar 2025 17:41:53 +0100 Subject: [PATCH 4/4] Update troubleshooting.mdx --- docusaurus/docs/ruby/troubleshooting.mdx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docusaurus/docs/ruby/troubleshooting.mdx b/docusaurus/docs/ruby/troubleshooting.mdx index 2d913b2f..6072b565 100644 --- a/docusaurus/docs/ruby/troubleshooting.mdx +++ b/docusaurus/docs/ruby/troubleshooting.mdx @@ -515,18 +515,21 @@ Please consider: ## Execution times are all 0 seconds in Minitest -When using `minitest-spec-rails`, avoid the [unsupported *outer describe*](https://github.com/metaskills/minitest-spec-rails). Otherwise, Knapsack Pro won't be able to track the execution time of each test. +When using `minitest-spec-rails`, avoid the [unsupported *outer describe*](https://github.com/metaskills/minitest-spec-rails?tab=readme-ov-file#test-styles). Otherwise, Knapsack Pro won't be able to track the execution time of each test. ```ruby # ⛔️ Bad require 'test_helper' describe User do end +``` +```ruby # ✅ Good require 'test_helper' class UserTest < ActiveSupport::TestCase - let(:user_ken) { User.create! :email => 'ken@metaskills.net' } + let(:user_ken) { User.create!(email: 'ken@example.com') } + it 'works' do expect(user_ken).must_be_instance_of User end