Home » Eclipse Projects » SWTBot » Three identical tests, first one fails on Mac OS X
| | |
Re: Three identical tests, first one fails on Mac OS X [message #726180 is a reply to message #726145] |
Fri, 16 September 2011 17:33 |
Bernhard Pieber Messages: 11 Registered: July 2009 |
Junior Member |
|
|
Am 16.09.11 18:28, schrieb Bernhard Pieber:
> Thanks for your answer! We added the shell activation to our tests (see
> below). However, the behavior is unchanged. The first test fails, but
> the other two succeed.
I just saw that the failure is a different one, though. This time I got:
org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after:
5000 ms.: Timed out waiting for Shell {Test} to get activated
Before we got:
com.softwaregeneration.learning.SWTBotFinderTest
testFindButton1(com.softwaregeneration.learning.SWTBotFinderTest)
org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException: Could
not find widget.
We wanted to get the simplest possible test to work from the SWTBot
class comment:
SWTBot bot = new SWTBot();
bot.button("hello world").click();
Our original test class looks like this:
package com.softwaregeneration.learning;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.junit.Test;
public class SWTBotTest {
@Test
public void testClickButton() throws Exception {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Test");
shell.setSize(200, 150);
Button button = new Button(shell, SWT.PUSH);
button.setText("hello world");
shell.open();
SWTBot bot = new SWTBot();
bot.shell("Test").activate();
bot.button("hello world").click();
}
}
However, we get
org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after:
5000 ms.: Timed out waiting for Shell {Test} to get activated
Without the activate we get:
org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException: Could
not find widget.
Thanks for your support!
Cheers,
Bernhard
|
|
|
Re: Three identical tests, first one fails on Mac OS X [message #727016 is a reply to message #726180] |
Tue, 20 September 2011 07:41 |
Bernhard Pieber Messages: 11 Registered: July 2009 |
Junior Member |
|
|
Can any Mac user reproduce this behavior, or am I the only one who
experiences this?
Thanks for your support.
Cheers,
Bernhard
Am 16.09.11 19:33, schrieb Bernhard Pieber:
> Am 16.09.11 18:28, schrieb Bernhard Pieber:
>> Thanks for your answer! We added the shell activation to our tests (see
>> below). However, the behavior is unchanged. The first test fails, but
>> the other two succeed.
> I just saw that the failure is a different one, though. This time I got:
> org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after:
> 5000 ms.: Timed out waiting for Shell {Test} to get activated
>
> Before we got:
> com.softwaregeneration.learning.SWTBotFinderTest
> testFindButton1(com.softwaregeneration.learning.SWTBotFinderTest)
> org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException: Could
> not find widget.
>
> We wanted to get the simplest possible test to work from the SWTBot
> class comment:
>
> SWTBot bot = new SWTBot();
>
> bot.button("hello world").click();
>
> Our original test class looks like this:
>
> package com.softwaregeneration.learning;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.swtbot.swt.finder.SWTBot;
> import org.junit.Test;
>
> public class SWTBotTest {
>
> @Test
> public void testClickButton() throws Exception {
> Display display = new Display();
> Shell shell = new Shell(display);
> shell.setText("Test");
> shell.setSize(200, 150);
>
> Button button = new Button(shell, SWT.PUSH);
> button.setText("hello world");
>
> shell.open();
>
> SWTBot bot = new SWTBot();
> bot.shell("Test").activate();
> bot.button("hello world").click();
> }
> }
>
> However, we get
> org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after:
> 5000 ms.: Timed out waiting for Shell {Test} to get activated
>
> Without the activate we get:
> org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException: Could
> not find widget.
>
> Thanks for your support!
>
> Cheers,
> Bernhard
|
|
|
Re: Three identical tests, first one fails on Mac OS X [message #727227 is a reply to message #726145] |
Tue, 20 September 2011 16:20 |
Ketan Padegaonkar Messages: 873 Registered: July 2009 |
Senior Member |
|
|
On 9/16/11 9:28 AM, Bernhard Pieber wrote:
> Thanks for your answer! We added the shell activation to our tests (see
> below). However, the behavior is unchanged. The first test fails, but
> the other two succeed.
>
> Do you have any idea why?
I think I may know why.
SWTBot requires that the tests run on a non-ui thread. Which means that
your tests must run on a thread different from the thread that starts
the app.
However in the case of your snippet, your test app and swtbot run on the
same thread, which is why you're seeing these weird errors.
Unfortunately in case of cocoa, the UI thread must start on the main
thread, implying that the tests should run on a non-main thread.
Unfortunately this has the side-effect that plain swt apps cannot be
tested with swtbot on a mac.
I was in the middle of fixing this issue, but it's been a while since
anyone mentioned swt and cocoa :) So here's what you'd need to do:
Copy the class BaseSWTTest
(https://github.com/ketan/SWTBot/commit/dadb1782247f0d169a6717f6819cfccc5cd4861a#diff-23)
and all required dependencies to make the class compile
(UIThreadTestRunner, UIThread)
You'll eventually need to subclass BaseSWTTest and run your tests using
"run as > junit tests"
Hope that helps.
-- Ketan
|
|
|
Re: Three identical tests, first one fails on Mac OS X [message #731317 is a reply to message #727227] |
Fri, 30 September 2011 15:48 |
Bernhard Pieber Messages: 11 Registered: July 2009 |
Junior Member |
|
|
Hi Ketan,
Thank you very much for your answer. I just wanted to let you know that
I did not ignore it. I just did not have time to try your suggestion
yet. As soon as I have tried I will give you feedback.
Could I also just use your fork, or wouldn't it work for some reason?
Cheers,
Bernhard
Am 20.09.11 18:20, schrieb Ketan Padegaonkar:
> On 9/16/11 9:28 AM, Bernhard Pieber wrote:
>> Thanks for your answer! We added the shell activation to our tests (see
>> below). However, the behavior is unchanged. The first test fails, but
>> the other two succeed.
>>
>> Do you have any idea why?
>
> I think I may know why.
>
> SWTBot requires that the tests run on a non-ui thread. Which means that
> your tests must run on a thread different from the thread that starts
> the app.
>
> However in the case of your snippet, your test app and swtbot run on the
> same thread, which is why you're seeing these weird errors.
>
> Unfortunately in case of cocoa, the UI thread must start on the main
> thread, implying that the tests should run on a non-main thread.
>
> Unfortunately this has the side-effect that plain swt apps cannot be
> tested with swtbot on a mac.
>
> I was in the middle of fixing this issue, but it's been a while since
> anyone mentioned swt and cocoa :) So here's what you'd need to do:
>
> Copy the class BaseSWTTest
> (https://github.com/ketan/SWTBot/commit/dadb1782247f0d169a6717f6819cfccc5cd4861a#diff-23)
> and all required dependencies to make the class compile
> (UIThreadTestRunner, UIThread)
>
> You'll eventually need to subclass BaseSWTTest and run your tests using
> "run as > junit tests"
>
> Hope that helps.
>
> -- Ketan
>
>
|
|
|
Re: Three identical tests, first one fails on Mac OS X [message #732028 is a reply to message #731317] |
Mon, 03 October 2011 18:07 |
Ketan Padegaonkar Messages: 873 Registered: July 2009 |
Senior Member |
|
|
I've recently merged this into trunk, so this should be a bit simpler.
You may use the artifacts generated by the build machine at
https://hudson.eclipse.org/hudson/view/SWTBot/job/swtbot-e36/lastSuccessfulBuild/artifact/org.eclipse.swtbot.releng/artifacts/
and let me know if this version works for you.
To write your SWTBot tests, checkout this example I put together for you
https://gist.github.com/18f4760c92da2a7c0767. If this works for you, let
me know and I'll document it properly.
-- Ketan
On 9/30/11 8:48 AM, Bernhard Pieber wrote:
> Hi Ketan,
>
> Thank you very much for your answer. I just wanted to let you know that
> I did not ignore it. I just did not have time to try your suggestion
> yet. As soon as I have tried I will give you feedback.
>
> Could I also just use your fork, or wouldn't it work for some reason?
>
> Cheers,
> Bernhard
>
> Am 20.09.11 18:20, schrieb Ketan Padegaonkar:
>> On 9/16/11 9:28 AM, Bernhard Pieber wrote:
>>> Thanks for your answer! We added the shell activation to our tests (see
>>> below). However, the behavior is unchanged. The first test fails, but
>>> the other two succeed.
>>>
>>> Do you have any idea why?
>>
>> I think I may know why.
>>
>> SWTBot requires that the tests run on a non-ui thread. Which means that
>> your tests must run on a thread different from the thread that starts
>> the app.
>>
>> However in the case of your snippet, your test app and swtbot run on the
>> same thread, which is why you're seeing these weird errors.
>>
>> Unfortunately in case of cocoa, the UI thread must start on the main
>> thread, implying that the tests should run on a non-main thread.
>>
>> Unfortunately this has the side-effect that plain swt apps cannot be
>> tested with swtbot on a mac.
>>
>> I was in the middle of fixing this issue, but it's been a while since
>> anyone mentioned swt and cocoa :) So here's what you'd need to do:
>>
>> Copy the class BaseSWTTest
>> (https://github.com/ketan/SWTBot/commit/dadb1782247f0d169a6717f6819cfccc5cd4861a#diff-23)
>>
>> and all required dependencies to make the class compile
>> (UIThreadTestRunner, UIThread)
>>
>> You'll eventually need to subclass BaseSWTTest and run your tests using
>> "run as > junit tests"
>>
>> Hope that helps.
>>
>> -- Ketan
>>
>>
>
|
|
|
Re: Three identical tests, first one fails on Mac OS X [message #732340 is a reply to message #732028] |
Tue, 04 October 2011 13:45 |
Bernhard Pieber Messages: 11 Registered: July 2009 |
Junior Member |
|
|
Hi Ketan,
Thank you for your answer. We tried to follow your advice. However, we
were unsure which of the artifacts to use. We added the following jars
to the classpath:
org.eclipse.swtbot.junit4_x_2.0.5.20111003_1754-3676ac8-dev-e36.jar
org.eclipse.swtbot.swt.finder_2.0.5.20111003_1754-3676ac8-dev-e36.jar
org.apache.log4j_1.2.13.v200903072027.jar
When we tried out your example from
https://gist.github.com/18f4760c92da2a7c0767, we miss the class
RunUIThreadRule and the annotation UIThread.
Which jar or jars are we missing?
How do we set up your example correctly?
Thanks for your support.
Cheers,
Bernhard & Görge
Am 03.10.11 20:07, schrieb Ketan Padegaonkar:
> I've recently merged this into trunk, so this should be a bit simpler.
>
> You may use the artifacts generated by the build machine at
> https://hudson.eclipse.org/hudson/view/SWTBot/job/swtbot-e36/lastSuccessfulBuild/artifact/org.eclipse.swtbot.releng/artifacts/
> and let me know if this version works for you.
>
> To write your SWTBot tests, checkout this example I put together for you
> https://gist.github.com/18f4760c92da2a7c0767. If this works for you, let
> me know and I'll document it properly.
>
>
> -- Ketan
>
> On 9/30/11 8:48 AM, Bernhard Pieber wrote:
>> Hi Ketan,
>>
>> Thank you very much for your answer. I just wanted to let you know that
>> I did not ignore it. I just did not have time to try your suggestion
>> yet. As soon as I have tried I will give you feedback.
>>
>> Could I also just use your fork, or wouldn't it work for some reason?
>>
>> Cheers,
>> Bernhard
>>
>> Am 20.09.11 18:20, schrieb Ketan Padegaonkar:
>>> On 9/16/11 9:28 AM, Bernhard Pieber wrote:
>>>> Thanks for your answer! We added the shell activation to our tests (see
>>>> below). However, the behavior is unchanged. The first test fails, but
>>>> the other two succeed.
>>>>
>>>> Do you have any idea why?
>>>
>>> I think I may know why.
>>>
>>> SWTBot requires that the tests run on a non-ui thread. Which means that
>>> your tests must run on a thread different from the thread that starts
>>> the app.
>>>
>>> However in the case of your snippet, your test app and swtbot run on the
>>> same thread, which is why you're seeing these weird errors.
>>>
>>> Unfortunately in case of cocoa, the UI thread must start on the main
>>> thread, implying that the tests should run on a non-main thread.
>>>
>>> Unfortunately this has the side-effect that plain swt apps cannot be
>>> tested with swtbot on a mac.
>>>
>>> I was in the middle of fixing this issue, but it's been a while since
>>> anyone mentioned swt and cocoa :) So here's what you'd need to do:
>>>
>>> Copy the class BaseSWTTest
>>> (https://github.com/ketan/SWTBot/commit/dadb1782247f0d169a6717f6819cfccc5cd4861a#diff-23)
>>>
>>>
>>> and all required dependencies to make the class compile
>>> (UIThreadTestRunner, UIThread)
>>>
>>> You'll eventually need to subclass BaseSWTTest and run your tests using
>>> "run as > junit tests"
>>>
>>> Hope that helps.
>>>
>>> -- Ketan
>>>
>>>
>>
>
|
|
|
Re: Three identical tests, first one fails on Mac OS X [message #733543 is a reply to message #732340] |
Wed, 05 October 2011 01:49 |
Ketan Padegaonkar Messages: 873 Registered: July 2009 |
Senior Member |
|
|
I'd suggest downloading(https://github.com/ketan/SWTBot/downloads) the
source code and looking at the existing swtbot tests in the
swt.finder.tests plugin. Pick a simple SWTBotButtonTest and find your
way to the superclass and copy over the classes needed.
Hope that helps.
-- Ketan
On 10/4/11 6:45 AM, Bernhard Pieber wrote:
> Hi Ketan,
>
> Thank you for your answer. We tried to follow your advice. However, we
> were unsure which of the artifacts to use. We added the following jars
> to the classpath:
> org.eclipse.swtbot.junit4_x_2.0.5.20111003_1754-3676ac8-dev-e36.jar
> org.eclipse.swtbot.swt.finder_2.0.5.20111003_1754-3676ac8-dev-e36.jar
> org.apache.log4j_1.2.13.v200903072027.jar
>
> When we tried out your example from
> https://gist.github.com/18f4760c92da2a7c0767, we miss the class
> RunUIThreadRule and the annotation UIThread.
>
> Which jar or jars are we missing?
> How do we set up your example correctly?
>
> Thanks for your support.
>
> Cheers,
> Bernhard & Görge
>
>
>
> Am 03.10.11 20:07, schrieb Ketan Padegaonkar:
>> I've recently merged this into trunk, so this should be a bit simpler.
>>
>> You may use the artifacts generated by the build machine at
>> https://hudson.eclipse.org/hudson/view/SWTBot/job/swtbot-e36/lastSuccessfulBuild/artifact/org.eclipse.swtbot.releng/artifacts/
>>
>> and let me know if this version works for you.
>>
>> To write your SWTBot tests, checkout this example I put together for you
>> https://gist.github.com/18f4760c92da2a7c0767. If this works for you, let
>> me know and I'll document it properly.
>>
>>
>> -- Ketan
>>
>> On 9/30/11 8:48 AM, Bernhard Pieber wrote:
>>> Hi Ketan,
>>>
>>> Thank you very much for your answer. I just wanted to let you know that
>>> I did not ignore it. I just did not have time to try your suggestion
>>> yet. As soon as I have tried I will give you feedback.
>>>
>>> Could I also just use your fork, or wouldn't it work for some reason?
>>>
>>> Cheers,
>>> Bernhard
>>>
>>> Am 20.09.11 18:20, schrieb Ketan Padegaonkar:
>>>> On 9/16/11 9:28 AM, Bernhard Pieber wrote:
>>>>> Thanks for your answer! We added the shell activation to our tests
>>>>> (see
>>>>> below). However, the behavior is unchanged. The first test fails, but
>>>>> the other two succeed.
>>>>>
>>>>> Do you have any idea why?
>>>>
>>>> I think I may know why.
>>>>
>>>> SWTBot requires that the tests run on a non-ui thread. Which means that
>>>> your tests must run on a thread different from the thread that starts
>>>> the app.
>>>>
>>>> However in the case of your snippet, your test app and swtbot run on
>>>> the
>>>> same thread, which is why you're seeing these weird errors.
>>>>
>>>> Unfortunately in case of cocoa, the UI thread must start on the main
>>>> thread, implying that the tests should run on a non-main thread.
>>>>
>>>> Unfortunately this has the side-effect that plain swt apps cannot be
>>>> tested with swtbot on a mac.
>>>>
>>>> I was in the middle of fixing this issue, but it's been a while since
>>>> anyone mentioned swt and cocoa :) So here's what you'd need to do:
>>>>
>>>> Copy the class BaseSWTTest
>>>> (https://github.com/ketan/SWTBot/commit/dadb1782247f0d169a6717f6819cfccc5cd4861a#diff-23)
>>>>
>>>>
>>>>
>>>> and all required dependencies to make the class compile
>>>> (UIThreadTestRunner, UIThread)
>>>>
>>>> You'll eventually need to subclass BaseSWTTest and run your tests using
>>>> "run as > junit tests"
>>>>
>>>> Hope that helps.
>>>>
>>>> -- Ketan
>>>>
>>>>
>>>
>>
>
|
|
|
Re: Three identical tests, first one fails on Mac OS X [message #733544 is a reply to message #732340] |
Wed, 05 October 2011 01:49 |
Ketan Padegaonkar Messages: 873 Registered: July 2009 |
Senior Member |
|
|
I'd suggest downloading(https://github.com/ketan/SWTBot/downloads) the
source code and looking at the existing swtbot tests in the
swt.finder.tests plugin. Pick a simple SWTBotButtonTest and find your
way to the superclass and copy over the classes needed.
Hope that helps.
-- Ketan
On 10/4/11 6:45 AM, Bernhard Pieber wrote:
> Hi Ketan,
>
> Thank you for your answer. We tried to follow your advice. However, we
> were unsure which of the artifacts to use. We added the following jars
> to the classpath:
> org.eclipse.swtbot.junit4_x_2.0.5.20111003_1754-3676ac8-dev-e36.jar
> org.eclipse.swtbot.swt.finder_2.0.5.20111003_1754-3676ac8-dev-e36.jar
> org.apache.log4j_1.2.13.v200903072027.jar
>
> When we tried out your example from
> https://gist.github.com/18f4760c92da2a7c0767, we miss the class
> RunUIThreadRule and the annotation UIThread.
>
> Which jar or jars are we missing?
> How do we set up your example correctly?
>
> Thanks for your support.
>
> Cheers,
> Bernhard & Görge
>
>
>
> Am 03.10.11 20:07, schrieb Ketan Padegaonkar:
>> I've recently merged this into trunk, so this should be a bit simpler.
>>
>> You may use the artifacts generated by the build machine at
>> https://hudson.eclipse.org/hudson/view/SWTBot/job/swtbot-e36/lastSuccessfulBuild/artifact/org.eclipse.swtbot.releng/artifacts/
>>
>> and let me know if this version works for you.
>>
>> To write your SWTBot tests, checkout this example I put together for you
>> https://gist.github.com/18f4760c92da2a7c0767. If this works for you, let
>> me know and I'll document it properly.
>>
>>
>> -- Ketan
>>
>> On 9/30/11 8:48 AM, Bernhard Pieber wrote:
>>> Hi Ketan,
>>>
>>> Thank you very much for your answer. I just wanted to let you know that
>>> I did not ignore it. I just did not have time to try your suggestion
>>> yet. As soon as I have tried I will give you feedback.
>>>
>>> Could I also just use your fork, or wouldn't it work for some reason?
>>>
>>> Cheers,
>>> Bernhard
>>>
>>> Am 20.09.11 18:20, schrieb Ketan Padegaonkar:
>>>> On 9/16/11 9:28 AM, Bernhard Pieber wrote:
>>>>> Thanks for your answer! We added the shell activation to our tests
>>>>> (see
>>>>> below). However, the behavior is unchanged. The first test fails, but
>>>>> the other two succeed.
>>>>>
>>>>> Do you have any idea why?
>>>>
>>>> I think I may know why.
>>>>
>>>> SWTBot requires that the tests run on a non-ui thread. Which means that
>>>> your tests must run on a thread different from the thread that starts
>>>> the app.
>>>>
>>>> However in the case of your snippet, your test app and swtbot run on
>>>> the
>>>> same thread, which is why you're seeing these weird errors.
>>>>
>>>> Unfortunately in case of cocoa, the UI thread must start on the main
>>>> thread, implying that the tests should run on a non-main thread.
>>>>
>>>> Unfortunately this has the side-effect that plain swt apps cannot be
>>>> tested with swtbot on a mac.
>>>>
>>>> I was in the middle of fixing this issue, but it's been a while since
>>>> anyone mentioned swt and cocoa :) So here's what you'd need to do:
>>>>
>>>> Copy the class BaseSWTTest
>>>> (https://github.com/ketan/SWTBot/commit/dadb1782247f0d169a6717f6819cfccc5cd4861a#diff-23)
>>>>
>>>>
>>>>
>>>> and all required dependencies to make the class compile
>>>> (UIThreadTestRunner, UIThread)
>>>>
>>>> You'll eventually need to subclass BaseSWTTest and run your tests using
>>>> "run as > junit tests"
>>>>
>>>> Hope that helps.
>>>>
>>>> -- Ketan
>>>>
>>>>
>>>
>>
>
|
|
|
Goto Forum:
Current Time: Thu Sep 26 18:41:09 GMT 2024
Powered by FUDForum. Page generated in 0.04504 seconds
|