|
|
|
|
|
|
Re: JRuby Support [message #8963 is a reply to message #8900] |
Fri, 12 December 2008 06:48 |
Andy Maleh Messages: 28 Registered: July 2009 |
Junior Member |
|
|
Ok, help! :)
When I attempt to run more than one feature test (story runner test
written with RSpec cucumber,) SWTBot freaks out.
Here is the JRuby code that launches it before each test:
require File.dirname(__FILE__) + "/../../samples/login.rb"
import "net.sf.swtbot.SWTBot"
def startApplicationInAnotherThread(&runnable)
thread = java.lang.Thread.new &runnable
thread.start
end
Before do
startApplicationInAnotherThread do
Login.new.launch
end
@bot = SWTBot.new
end
After do
@bot.active_shell.close
end
I get the following message after the second feature test starts running
(Before and After block executed once, and Before block being executed
again):
java.lang.IllegalStateException: Could not find a display
at net.sf.swtbot.utils.SWTUtils.display(SWTUtils.java:241)
at net.sf.swtbot.finder.ControlFinder.<init>(ControlFinder.java:88)
at
net.sf.swtbot.finder.ControlFinder.<init>(ControlFinder.java:78)method:
bind and args: #<LoginPresenter:0xddaabc>logged_out
Do you have any idea what it may be? Should I be doing something special
with the Login application related to the Display to prevent this? Am I
not cleaning up correctly by calling @bot.active_shell.close?
(btw, in case you didn't already know, JRuby allows calling Java methods
with Ruby's underscored naming convention instead of camel case, thus
active_shell instead of activeShell)
Andy
Andy Maleh wrote:
> Sure. I am planning to talk about the technical details in my next blog
> post. Will keep you posted.
> Andy
> Ketan Padegaonkar wrote:
>> Andy,
>> That's great news.
>> Perhaps you could blog about how you went about writing the
>> implementation of the test to wire up with SWTBot etc.
>> -- Ketan
>> On 11/12/08 21:49, Andy Maleh wrote:
>>> Done!!! SWTBot works with Glimmer via JRuby and RSpec.
>>>
>>> Check out the initial details over here:
>>>
> http://andymaleh.blogspot.com/2008/12/glimmers-got-bdd-throu gh-rspec-and.html
>>>
>>>
>>> Andy
>>>
>>> Andy Maleh wrote:
>>>
>>>> Great! I may give it a spin myself as well. I'll report about it on my
>>>> blog if I do.
>>>
>>>> Thanks,
>>>
>>>> Andy
>>>> http://andymaleh.blogspot.com
>>>
>>>> Ketan Padegaonkar wrote:
>>>
>>>>> Hi Andy,
>>>
>>>>> Since SWTBot is just plain java code, you should just be able to
>>>>> import the SWTBot class and start using it right away. Just as you
>>>>> would with SWT.
>>>
>>>>> I could probably do a spike around this and post some results.
>>>
>>>>> -- Ketan
>>>
>>>>> On 3/12/08 19:57, Andy Maleh wrote:
>>>>>> Hi Ketan,
>>>>>>
>>>>>> I'm curious. Have you ever tried SWTBot in JRuby? Are you familiar with
>>>>>> RSpec's new Story Runner (Cucumber)? I'm wondering if SWTBot can be
>>>>>> hooked to it somehow. These are all research projects that I'd like to
>>>>>> look into in the future as they will enable easy functional testing of
>>>>>> Glimmer applications.
>>>>>>
>>>
|
|
|
|
|
Re: JRuby Support [message #10201 is a reply to message #9004] |
Mon, 15 December 2008 16:20 |
Andy Maleh Messages: 28 Registered: July 2009 |
Junior Member |
|
|
Thanks Ketan,
I tried using the wait-for-display function, and I tried adding a sleep
period between every test run. Here is the modified test setup code:
def start_in_another_thread(&runnable)
thread = java.lang.Thread.new &runnable
thread.start
end
def wait_for_display_to_appear(time_out)
endTime = java.lang.System.current_time_millis() + time_out;
while (java.lang.System.current_time_millis() < endTime)
begin
display = SWTUtils.display();
return if (display != nil)
rescue Exception
end
java.lang.Thread.sleep(100);
end
raise TimeoutException.new("timed out");
end
Before do
start_in_another_thread { Login.new.launch }
wait_for_display_to_appear(5000)
java.lang.Thread.sleep(100);
@bot ||= SWTBot.new
end
After do
@bot.active_shell.close
@bot.display.dispose
end
That helped run all scenario tests successfully. However, every once in a
while I got this exception:
Mon Dec 15 10:15:14 andy-malehs-macbook-pro.local java[3302] <Warning>:
CGSResolveShmemReference : reference offset (47216) exceeds bounds (32768)
on shmem obj 0x1b745
Exception in thread "Thread-3" org/eclipse/swt/SWT.java:3803:in `error':
org.eclipse.swt.SWTError: No more handles (NativeException)
from org/eclipse/swt/SWT.java:3695:in `error'
from org/eclipse/swt/SWT.java:3666:in `error'
from org/eclipse/swt/widgets/Widget.java:681:in `error'
from org/eclipse/swt/widgets/Shell.java:512:in `createHandle'
from org/eclipse/swt/widgets/Widget.java:595:in `createWidget'
from org/eclipse/swt/widgets/Control.java:639:in `createWidget'
from org/eclipse/swt/widgets/Scrollable.java:138:in `createWidget'
from org/eclipse/swt/widgets/Shell.java:574:in `createWidget'
... 88 levels...
from features/step_definitions/../../samples/login.rb:68:in `launch'
from features/step_definitions/common_steps.rb:27:in `__cucumber_38'
from :1
Complete Java stackTrace
org.eclipse.swt.SWTError: No more handles
at org.eclipse.swt.SWT.error(SWT.java:3803)
at org.eclipse.swt.SWT.error(SWT.java:3695)
at org.eclipse.swt.SWT.error(SWT.java:3666)
Have you encountered that exception before? Do you know how to prevent it?
Thanks,
Andy
Ketan Padegaonkar wrote:
> On 12/12/08 12:18, Andy Maleh wrote:
>> I get the following message after the second feature test starts running
>> (Before and After block executed once, and Before block being executed
>> again):
>>
>> java.lang.IllegalStateException: Could not find a display
>> at net.sf.swtbot.utils.SWTUtils.display(SWTUtils.java:241)
>> at net.sf.swtbot.finder.ControlFinder.<init>(ControlFinder.java:88)
>> at
>> net.sf.swtbot.finder.ControlFinder.<init>(ControlFinder.java:78)method:
>> bind and args: #<LoginPresenter:0xddaabc>logged_out
> This is a small issue with the SWTUtils.display method, it throws an
> exception if it does not find a display.
> SWTUtils.display() should ideally wait for a display to appear, but it
> does not. I think it's high time I fix this issue.
> As a workaround, try doing the rest of the initialization(creating the
> SWTBot object) a couple of seconds after the app has started.
> The waitForDisplayToAppear() is what you'd be interested in on the page
> at
>
http://wiki.eclipse.org/SWTBot/UserGuide#Getting_started_wit h_SWTBot_for_SWT_applications
> -- Ketan
|
|
|
Re: JRuby Support [message #10263 is a reply to message #10201] |
Mon, 15 December 2008 17:06 |
Ketan Padegaonkar Messages: 873 Registered: July 2009 |
Senior Member |
|
|
Andy,
I've seen this problem before with swt apps. It basically happens when
SWT is no longer able to allocate OS resources to create widgets and
other things.
The problem persists until I reboot. Perhaps you have leaks in your
sample app and it does not dispose() swt objects correctly.
-- Ketan
On 15/12/08 21:50, Andy Maleh wrote:
> Thanks Ketan,
>
> I tried using the wait-for-display function, and I tried adding a sleep
> period between every test run. Here is the modified test setup code:
>
> def start_in_another_thread(&runnable)
> thread = java.lang.Thread.new &runnable
> thread.start
> end
>
> def wait_for_display_to_appear(time_out)
> endTime = java.lang.System.current_time_millis() + time_out;
> while (java.lang.System.current_time_millis() < endTime)
> begin
> display = SWTUtils.display();
> return if (display != nil)
> rescue Exception
> end
> java.lang.Thread.sleep(100); end
> raise TimeoutException.new("timed out");
> end
>
> Before do
> start_in_another_thread { Login.new.launch }
> wait_for_display_to_appear(5000)
> java.lang.Thread.sleep(100); @bot ||= SWTBot.new
> end
>
> After do
> @bot.active_shell.close
> @bot.display.dispose
> end
>
> That helped run all scenario tests successfully. However, every once in
> a while I got this exception:
>
> Mon Dec 15 10:15:14 andy-malehs-macbook-pro.local java[3302] <Warning>:
> CGSResolveShmemReference : reference offset (47216) exceeds bounds
> (32768) on shmem obj 0x1b745
> Exception in thread "Thread-3" org/eclipse/swt/SWT.java:3803:in `error':
> org.eclipse.swt.SWTError: No more handles (NativeException)
> from org/eclipse/swt/SWT.java:3695:in `error'
> from org/eclipse/swt/SWT.java:3666:in `error'
> from org/eclipse/swt/widgets/Widget.java:681:in `error'
> from org/eclipse/swt/widgets/Shell.java:512:in `createHandle'
> from org/eclipse/swt/widgets/Widget.java:595:in `createWidget'
> from org/eclipse/swt/widgets/Control.java:639:in `createWidget'
> from org/eclipse/swt/widgets/Scrollable.java:138:in `createWidget'
> from org/eclipse/swt/widgets/Shell.java:574:in `createWidget'
> ... 88 levels...
> from features/step_definitions/../../samples/login.rb:68:in `launch'
> from features/step_definitions/common_steps.rb:27:in `__cucumber_38'
> from :1
> Complete Java stackTrace
> org.eclipse.swt.SWTError: No more handles
> at org.eclipse.swt.SWT.error(SWT.java:3803)
> at org.eclipse.swt.SWT.error(SWT.java:3695)
> at org.eclipse.swt.SWT.error(SWT.java:3666)
>
> Have you encountered that exception before? Do you know how to prevent it?
>
> Thanks,
>
> Andy
>
> Ketan Padegaonkar wrote:
>
>> On 12/12/08 12:18, Andy Maleh wrote:
>>> I get the following message after the second feature test starts running
>>> (Before and After block executed once, and Before block being executed
>>> again):
>>>
>>> java.lang.IllegalStateException: Could not find a display
>>> at net.sf.swtbot.utils.SWTUtils.display(SWTUtils.java:241)
>>> at net.sf.swtbot.finder.ControlFinder.<init>(ControlFinder.java:88)
>>> at
>>> net.sf.swtbot.finder.ControlFinder.<init>(ControlFinder.java:78)method:
>>> bind and args: #<LoginPresenter:0xddaabc>logged_out
>
>> This is a small issue with the SWTUtils.display method, it throws an
>> exception if it does not find a display.
>
>> SWTUtils.display() should ideally wait for a display to appear, but it
>> does not. I think it's high time I fix this issue.
>
>> As a workaround, try doing the rest of the initialization(creating the
>> SWTBot object) a couple of seconds after the app has started.
>
>> The waitForDisplayToAppear() is what you'd be interested in on the
>> page at
> http://wiki.eclipse.org/SWTBot/UserGuide#Getting_started_wit h_SWTBot_for_SWT_applications
>
>
>> -- Ketan
>
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03725 seconds