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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9e460563f35b0b25d8671d6ef83f54ce?d=identicon&s=25 Clinton Forbes (Guest)
on 2009-01-31 14:51
(Received via mailing list)
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.
24d3df508ced34482056f6a939588152?d=identicon&s=25 Bryan Ash (bryan-ash)
on 2009-01-31 15:44
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
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2009-02-01 04:26
(Received via mailing list)
Bryan Ash 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
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2009-02-01 04:30
(Received via mailing list)
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/test...
(Ruby 1.8)
http://wxruby.rubyforge.org/svn/trunk/wxruby2/test...
(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
24d3df508ced34482056f6a939588152?d=identicon&s=25 Bryan Ash (bryan-ash)
on 2009-02-10 04:03
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 <a
href="http://github.com/bryan-ash/wx-nobbie/tree">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
24d3df508ced34482056f6a939588152?d=identicon&s=25 Bryan Ash (bryan-ash)
on 2009-02-10 04:05
Bryan Ash wrote:
> I've uploaded it to <a
> href="http://github.com/bryan-ash/wx-nobbie/tree">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
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2009-02-11 18:34
(Received via mailing list)
Bryan Ash 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
24d3df508ced34482056f6a939588152?d=identicon&s=25 Bryan Ash (bryan-ash)
on 2009-02-11 19:07
Alex Fenton 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 ;-)

Bryan
This topic is locked and can not be replied to.