How Ruby’s test suite autoruns from the command line

1
2
3
4
5
6
7
8
9
10
11
    ##
    # Registers MiniTest::Unit to run tests at process exit

    def self.autorun
      at_exit {
        next if $! # don't run if there was an exception
        exit_code = MiniTest::Unit.new.run(ARGV)
        exit false if exit_code && exit_code != 0
      } unless @@installed_at_exit
      @@installed_at_exit = true
    end

When digging around in the test/unit files, I found out how the test cases run when your just run the test files. Basically, test/unit relies on another set of test libs called Minitest. In Minitest, there’s a method called autorun that gets called inside of test/unit.rb. In it, it calls a kernel method hook, at_exit() that runs a MiniTest when it’s done loading all the code.

And here, reading at_exit() in the docs, all I could think of to put in there was just a line that says, “done!”

Back to work….

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s