Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minitest-proveit to force assertions #253

Merged
merged 1 commit into from
Jan 16, 2023
Merged

Conversation

teoljungberg
Copy link
Contributor

This PR adds minitest-proveit to force that all tests executes some kind
of assertion, and if they do not - they will fail automatically.

@teoljungberg
Copy link
Contributor Author

Example:

..b.com/fxn/zeitwerk fix-spelling-errors % git diff
diff --git a/test/lib/test_inflector.rb b/test/lib/test_inflector.rb
index 7a0af7d..13cdc1a 100644
--- a/test/lib/test_inflector.rb
+++ b/test/lib/test_inflector.rb
@@ -39,4 +39,8 @@ class TestInflector < Minitest::Test

     assert_equal "UsersController", inflector.camelize("users_controller", nil)
   end
+
+  test "no assertions fail" do
+    2 + 4 == 0
+  end
 end
..b.com/fxn/zeitwerk fix-spelling-errors % bundle exec rake

# Running tests with run options --seed 17253:

.........................................................................................................................................................................................................................................................................................................................................................................F.................

Finished tests in 2.280895s, 166.1628 tests/s, 394.5820 assertions/s.


Failure:
TestInflector#test_no_assertions_fail [/Users/teo/src/github.com/fxn/zeitwerk/.bundle/ruby/3.1.0/gems/minitest-5.17.0/lib/minitest/test.rb:107]
Minitest::Assertion: Absence of failure is not success. Prove it!

379 tests, 900 assertions, 1 failures, 0 errors, 0 skips
rake aborted!
Command failed with status (1)

@fxn
Copy link
Owner

fxn commented Jan 16, 2023

Seems like a good idea, let's give it a try at least.

Thanks!

@fxn fxn merged commit 3602de7 into fxn:main Jan 16, 2023
@teoljungberg
Copy link
Contributor Author

Since there were no test-cases without assertions it is another added development-dependency currently. But since zeitwerk can get contributions I felt that it was a good guard-railing to have.

It's at least worth a shot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants