callbacks before/after tests run : where to start?

Is there/will there ever be a way to execute code when tests start running and when they are finished?

I've just got my hands on a Logitech G19 keyboard, and it comes equiped with a LCD screen.
I'd like to use it to display the test results (orange/green/red), by creating and storing an image in a given directory.

Comment actions Permalink


I'd like to use it to display the test results (orange/green/red), by creating and storing an image in a given directory.

Cool idea =)

RM doesn't provide any API for such feature and I don't know ETA when we will implement it (sorry, we have lots of critical issues).  But I think that it is still possible to do. The easiest way is to plug into our test reporters which are written in Ruby.

1. If it is enough to show statistics after all tests have finished:
Usually each reporter provides method which outputs passed/finished/pending/failed/.. tests in the end. Method names depends on rspec/cucumber/Test::Unit formatters/reporters API. So you need to patch

cucumber - [RubyMine installation directory]/rb/testing/patch/bdd/teamcity/cucumber/formatter_03103.rb
rspec - [RubyMine installation directory]/rb/testing/patch/bdd/teamcity/spec/runner/formatter/teamcity/formatter.rb
test::unit, shoulda - [RubyMine installation directory]/rb/testing/patch/testunit/test/unit/ui/teamcity/testrunner_events.rb

Unfortunately we change these files from time to time after each rspec/cucumber/testunit/shoulda API breakage

2. If you wan't to track status in real time (probably image generation will affect test suite performance)

Each test reporter generates test event messages (test or suite started/finished/failed) and sends it to stdout. For msg generation reporters use [RubyMine installation directory]/rb/testing/patch/common/teamcity/utils/service_message_factory.rb factory

The src code in this factory is much more clear and and changes in it are rare.

So you can play with all this stuff, try to implement your callback for some test framework. If you have success in it I think we will add some API and you will be able to write a Ruby or Java plugin for RubyMine.

Comment actions Permalink

Thanks Roman. That's a good starting point.


Please sign in to leave a comment.