wxRuby and Test::Unit (or Rspec or whatever)

This is my first post to the mailing list, so “Hello All”.

I have a question about wxRuby and having automated tests of my GUI.
Is anyone doing this? I have plenty of experience testing Rails apps
with Test::Unit and Rspec, but I couldn’t find any examples for wxRuby.

At the moment I start my app by calling MyApp.new.mainloop, but this
method blocks until I quit it. Should I start another thread to run
my tests, sending messages to my running application?

If anyone has a simple example to show me, that would be fantastic.

Thanks,

Clinton.

Clinton,

I’ve been looking for the same thing. I came across wx-nobbie in
rubyforge which looks like Webrat for wx apps but it is quite old and
doesn’t work with the latest wx.

I’ve started looking at updating wx-nobbie but the tests are failing on
find_window_by_name.

wx-nobbie does use a separate thread as you suggested.

If you’re interested, I could put wx-nobbie up on github and we could
take it from there.

Bryan

Bryan A. wrote:

take it from there.
It’d be good to see nobbie updated. I’d be happy to help get it working
with latest wxRuby.

alex

Hi Clinton

Clinton Forbes wrote:

I have a question about wxRuby and having automated tests of my GUI.
Is anyone doing this? I have plenty of experience testing Rails apps
with Test::Unit and Rspec, but I couldn’t find any examples for wxRuby.

There are some in the wxRuby repository and tarball which use test/unit

http://wxruby.rubyforge.org/svn/trunk/wxruby2/tests/test_item_data.rb
(Ruby 1.8)
http://wxruby.rubyforge.org/svn/trunk/wxruby2/tests/test_clipboard.rb
(Ruby 1.9)

At the moment I start my app by calling MyApp.new.mainloop, but this
method blocks until I quit it. Should I start another thread to run
my tests, sending messages to my running application?

For simple tests, you don’t need to run threads. Just call the test
library’s method to run whatever tests you want within your app’s
on_init method, or Wx::App.run { … } block. The way to do this with
Ruby’s standard test/unit varies between ruby versions 1.8 and 1.9. I
haven’t used rspec but i expect there’s something similar.

If you return false or nil from the application start-up, then the
program should exit cleanly.

alex

Turns Nobbie works just fine with current wxRuby, the problem was with
the Gem’s dependence on an old wxSugar. When I just updated wxSugar
most of the issues disappeared.

I’ve uploaded it to GitHub with a
gemspec, so it can be installed:

gem sources -a http://gems.github.com
gem install bryan-ash-wx-nobbie

All the tests pass, but they do give a number of warnings like:

listen is deprecated, use evt_xxx directly
(C:/ruby/lib/ruby/gems/1.8/gems/bryan-ash-wx-nobbie-0.0.3.2/test/suite/app.rb:19:in
`initialize’)

Bryan

Bryan A. wrote:

I’ve uploaded it to GitHub with a

I guess posting links is easier than I thought, all I needed was:
http://github.com/bryan-ash/wx-nobbie/tree

Bryan

Alex F. wrote:

The test runs well for a while for me, but then segfaults after a while.
This is with Ruby 1.8.6 on OS X, using the latest wxRuby. Strangely, the
backtrace of the segfault is not in wxRuby code anywhere.

The original author, Paul, had mentioned that in the KNOWN_ISSUES. I’m
still waiting for someone to donate a MacBook Pro to me so I can
investigate these :wink:

Bryan

Bryan A. wrote:

Turns Nobbie works just fine with current wxRuby, the problem was with
the Gem’s dependence on an old wxSugar. When I just updated wxSugar
most of the issues disappeared.

I’ve uploaded it to http://github.com/bryan-ash/wx-nobbie/tree with a
gemspec, so it can be installed:

Thanks for doing this. It looks good. I never got it working before.

All the tests pass,

The test runs well for a while for me, but then segfaults after a while.
This is with Ruby 1.8.6 on OS X, using the latest wxRuby. Strangely, the
backtrace of the segfault is not in wxRuby code anywhere.

but they do give a number of warnings like:

listen is deprecated, use evt_xxx directly

‘listen’ was in wxSugar for a while as an experiment in better event
handling syntax. In the end most of what ‘listen’ did was rolled into
core wxRuby, but there didn’t seem to be any advantage to writing

listen :text

rather than just

evt_text

So I deprecated it.

alex