JRuby Support [message #6023] |
Wed, 03 December 2008 09:27  |
Eclipse User |
|
|
|
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 #8963 is a reply to message #8900] |
Fri, 12 December 2008 01:48   |
Eclipse User |
|
|
|
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 11:20   |
Eclipse User |
|
|
|
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 12:06   |
Eclipse User |
|
|
|
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
>
>
|
|
|
|
Re: JRuby Support [message #1410313 is a reply to message #12160] |
Wed, 20 August 2014 07:48  |
Eclipse User |
|
|
|
Hi,
I am trying to test GUI based application in SWTBot. I am executing the test cases through testng framework. But i am getting following error.Can any one help me so i can go further implementation.
Thanks in advance
java.lang.IllegalStateException: Could not find a display
at org.eclipse.swtbot.swt.finder.utils.SWTUtils.display(SWTUtils.java:250)
at org.eclipse.swtbot.swt.finder.finders.ControlFinder.<init>(ControlFinder.java:83)
at org.eclipse.swtbot.swt.finder.finders.ControlFinder.<init>(ControlFinder.java:73)
at org.eclipse.swtbot.swt.finder.SWTBot.<init>(SWTBot.java:115)
at org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot.<init>(SWTWorkbenchBot.java:61)
at temp.NewTest.beforeClass(NewTest.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
|
|
|
Powered by
FUDForum. Page generated in 0.05403 seconds