chef-boneyard / minitest-chef-handler

Run minitest suites after your Chef recipes to check the status of your system.
Other
163 stars 44 forks source link

minitest-reporters #15

Open jperry opened 12 years ago

jperry commented 12 years ago

Hi,

It would be nice if minitest-chef-handler supported different minitest reporters. I'll see about forking the repo and adding this functionality to allow the user to specify different reporters as an option. Just wanted to mention it in case you had this code already in the works.

https://github.com/CapnKernul/minitest-reporters

Thanks, Jay

jperry commented 12 years ago

I tried adding the minitest-reporters gem to minitest-chef-handler but not having much success. Any ideas?

Changed runner.rb to:

class Runner < MiniTest::SuiteRunner

Changed minitest-chef-handler.rb have:

runner = Runner.new(run_status)
        MiniTest::Unit.runner = runner

        # Add reporters
        MiniTest::Unit.runner.reporters << MiniTest::Reporters::SpecReporter.new

Failure:

Run options: -v --seed 34541

Started

TestXML

  ERROR
 test_that_the_libxml2_package_was_installed (0.01s)

        undefined method `[]' for nil:NilClass

        /var/chef/minitest/xml/xml_test.rb:12:in `test_that_the_libxml2_package_was_installed'

        /usr/local/lib/ruby/1.9.1/minitest/unit.rb:949:in `run'

  ERROR test_that_the_libxml_devel_package_was_installed (0.00s)
        undefined method `[]' for nil:NilClass
        /var/chef/minitest/xml/xml_test.rb:3:in `test_that_the_libxml_devel_package_was_installed'
        /usr/local/lib/ruby/1.9.1/minitest/unit.rb:949:in `run'
calavera commented 12 years ago

You don't need to call MiniTest::Unit.runner since you already have the runner instance a few lines above.

jperry commented 12 years ago

So you think just doing below would suffice?

runner.reporters << MiniTest::Reporters::SpecReporter.new

When I wasn't setting MiniTest::Unit.runner I was having issue with this line:

https://github.com/CapnKernul/minitest-reporters/blob/develop/lib/minitest/reporter.rb#L4

calavera commented 12 years ago

I see. The problem is that I don't set Minitest::Unit.runner anywhere because it's not used. I don't see the point to set it and I feel that behaviour is wrong, the reporter should not rely on a global variable but in the runner that has been assigned to.

jperry commented 12 years ago

Yeah, maybe I'll just fork that code and not use that approach but instead use the runner that is already set. Does that sound like that would fix the problem?

jperry commented 12 years ago

I changed the minitest-reporters to not use a global variable and pass the runner to the reporter and I'm getting a undefined method [] for nil:NilClass

# Running tests:

EE

Finished tests in 0.006150s, 325.2033 tests/s, 0.0000 assertions/s.

  1) Error:
test_that_the_zip_package_was_installed(TestZip):
NoMethodError: undefined method `[]' for nil:NilClass
    /vagrant/cookbooks/zip/files/default/tests/minitest/zip_test.rb:3:in `test_that_the_zip_package_was_installed'
    /usr/local/lib/ruby/1.9.1/minitest/unit.rb:949:in `run'

  2) Error:
test_that_the_unzip_package_was_installed(TestZip):
NoMethodError: undefined method `[]' for nil:NilClass
    /vagrant/cookbooks/zip/files/default/tests/minitest/zip_test.rb:12:in `test_that_the_unzip_package_was_installed'
    /usr/local/lib/ruby/1.9.1/minitest/unit.rb:949:in `run'

It's becoming hard to debug or track this one down.

calavera commented 12 years ago

for what I see, that project is basically a complete refactor of minitest. I'm afraid that unless it's merged with minitest the reporters won't work.

mrjcleaver commented 11 years ago

I note a flurry of activity over on minitest-reporters in the last few days. Is their project still incompatible? I didn't see an open ticket regarding the incompatibility noted here - perhaps someone here would like to check if the incompatibility issue still exists?