Ruby test-unit not showing summary after tests

109 Views Asked by At

Normally Ruby test-unit will display a summary of tests run after they are finished, something like this:

Finished in 0.117158443 seconds.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
10 tests, 10 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
298.74 tests/s, 0.00 assertions/s

This was working, but now something has changed and when the unit tests are run it shows the dots but then stops. I tried re-organizing some test file into different directories and made absolutely sure to change the filepaths in the testrunner. Also, the dots do not match the number of tests/assertions.

Loaded suite test
Started
.................$prompt> // <<-- does not put newline here.

I notice that if I run the testrunner from another directory, the summary will show, but it will cause errors with the test dependencies. I should be able to run the testrunner from the same directory. This is an example of the testrunner I am using: https://test-unit.github.io/test-unit/en/file.how-to.html. What are the reasons that this would not display at the end?

1

There are 1 best solutions below

2
centuryfall On

Seems like it could be an issue with not having the test-unit.yml file in the same directory as which you run the script.

See here in the code or in the same section in that document you posted.

See how it's configured here, for example:

runner: console
console_options:
  color_scheme: inverted
color_schemes:
  inverted:
    success:
      name: red
      bold: true
    failure:
      name: green
      bold: true

This part of the code documentation really stuck out:

  # ## Test Runners
  #
  # So, now you have this great test class, but you still
  # need a way to run it and view any failures that occur
  # during the run. There are some test runner; console test
  # runner, GTK+ test runner and so on. The console test
  # runner is automatically invoked for you if you require
  # 'test/unit' and simply run the file. To use another
  # runner simply set default test runner ID to
  # Test::Unit::AutoRunner:

Maybe you need to have that runner specified in your YML file?

Without seeing how you are calling your script and your directory organization, it will be hard to tell what is causing that issue but I think it begins with it not reading that yaml file for instance.

If all else fails, let me recommend two great unit testing libraries for Ruby if you feel compelled to switch to a more widely-used library:

  1. minitest
  2. RSpec

Edit: You could also revert your directories to be in the same order as before and hardcode in your Gemfile for that test-unit gem the last version that worked for you, like `"test-unit": "3.4.0".