Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8553023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:33:13+00:00 2026-06-11T14:33:13+00:00

Ruby’s Test::Unit has assert_nothing_raised . Test::Unit has been replaced by MiniTest . Why don’t

  • 0

Ruby’s Test::Unit has assert_nothing_raised. Test::Unit has been replaced by MiniTest. Why don’t MiniTest’s assertions / expectations have anything parallel to this? For example you can expect must_raise but not wont_raise.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:33:15+00:00Added an answer on June 11, 2026 at 2:33 pm

    MiniTest does implement assert_nothing_raised in its Test::Unit compatibility layer, but in its own tests (MiniTest::Unit and MiniTest::Spec) it does not implement any test like this. The reason is, the programmer argues, that testing for nothing raised is not a test of anything; you never expect anything to be raised in a test, except when you are testing for an exception. If an unexpected (uncaught) exception occurs in the code for a test, you’ll get an exception reported in good order by the test and you’ll know you have a problem.

    Example:

    require 'minitest/autorun'
    
    describe "something" do
      it "does something" do
        Ooops
      end
    end
    

    Output:

    Run options: --seed 41521
    
    # Running tests:
    
    E
    
    Finished tests in 0.000729s, 1371.7421 tests/s, 0.0000 assertions/s.
    
      1) Error:
    test_0001_does_something(something):
    NameError: uninitialized constant Ooops
        untitled:5:in `block (2 levels) in <main>'
    
    1 tests, 0 assertions, 0 failures, 1 errors, 0 skips
    

    Which is exactly what you wanted to know. If you were expecting nothing to be raised, you didn’t get it and you’ve been told so.

    So, the argument here is: do not use assert_nothing_raised! It’s just a meaningless crutch. See, for example:

    https://github.com/seattlerb/minitest/issues/70

    https://github.com/seattlerb/minitest/issues/159

    http://blog.zenspider.com/blog/2012/01/assert_nothing_tested.html

    On the other hand, clearly assert_nothing_raised corresponds to some intuition among users, since so many people expect a wont_raise to go with must_raise, etc. In particular one would like to focus an assertion on this, not merely a test. Luckily, MiniTest is extremely minimalist and flexible, so if you want to add your own routine, you can. So you can write a method that tests for no exception and returns a known outcome if there is no exception, and now you can assert for that known outcome.

    For example (I’m not saying this is perfect, just showing the idea):

    class TestMyRequire < MiniTest::Spec
      def testForError # pass me a block and I'll tell you if it raised
        yield
        "ok"
      rescue
        $!
      end
      it "blends" do
        testForError do
          something_or_other
        end.must_equal "ok"
      end
    end
    

    The point is not that this is a good or bad idea but that it was never the responsibility of MiniTest to do it for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ruby's unit testing framework executes unit tests even though nobody creates unit test object.
Ruby has two different exceptions mechanisms: Throw/Catch and Raise/Rescue. Why do we have two?
Ruby compacts the sequence only if it has nil value, how do I compact
Ruby has a select method that takes an array and returns a subarray consisting
Ruby doesn't seem to have a facility for defining a protected/private block like so:
Ruby on Rails has become a new competitive face in the server programming industry,
Ruby has conditional initialization. Apparently, Java does not or does it? I try to
Ruby has this very interesting functionality in which when you create a class with
Ruby has Enumerable#max and Enumerable#max_by and I am using max_by in the following way.
Ruby on Rails has many different generators and other such things. In my experience,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.