Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Three identical tests, first one fails on Mac OS X
Three identical tests, first one fails on Mac OS X [message #726123] Fri, 16 September 2011 15:31 Go to next message
Bernhard Pieber is currently offline Bernhard PieberFriend
Messages: 11
Registered: July 2009
Junior Member
Hi everyone,

We are SWTBot newbies and have experienced very strange behavior on Mac
OS X (Cocoa, Indigo). We run three identical trivial tests (Run As >
JUnit Test) in a row. However, it always fails for the first time with a
WidgetNotFoundException. Why? Any help is greatly appreciated.

If we use new SWTBot(shell) instead of new SWTBot(), it works fine.

The same test works fine on Windows.

Cheers,
Bernhard & Görge

package com.softwaregeneration.learning;

import static org.junit.Assert.assertNotNull;

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.After;
import org.junit.Before;
import org.junit.Test;

public class SWTBotFinderTest {

private Display display;

@Before
public void setUp() {
display = new Display();
}

@After
public void tearDown() {
display.dispose();
}

@Test
public void testFindButton1() throws Exception {
findButton();
}

@Test
public void testFindButton2() throws Exception {
findButton();
}

@Test
public void testFindButton3() throws Exception {
findButton();
}

private void findButton() throws InterruptedException {
Shell shell = new Shell(display);
shell.setSize(200, 150);

Button button = new Button(shell, SWT.PUSH);
button.setText("hello world");

shell.open();

assertNotNull(new SWTBot().button("hello world"));
}
}



SWTBotFinderTest
com.softwaregeneration.learning.SWTBotFinderTest
testFindButton1(com.softwaregeneration.learning.SWTBotFinderTest)
org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException: Could
not find widget.
at
org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetAppears(SWTBotFactory.java:348)
at
org.eclipse.swtbot.swt.finder.SWTBotFactory.widget(SWTBotFactory.java:308)
at org.eclipse.swtbot.swt.finder.SWTBot.button(SWTBot.java:183)
at org.eclipse.swtbot.swt.finder.SWTBot.button(SWTBot.java:171)
at
com.softwaregeneration.learning.SWTBotFinderTest.findButton(SWTBotFinderTest.java:52)
at
com.softwaregeneration.learning.SWTBotFinderTest.testFindButton1(SWTBotFinderTest.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at
org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.eclipse.swtbot.swt.finder.widgets.TimeoutException:
Timeout after: 5000 ms.: Could not find widget matching: (of type
'Button' and with mnemonic 'hello world' and with style 'SWT.PUSH')
at
org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:398)
at
org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:372)
at
org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:360)
at
org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetAppears(SWTBotFactory.java:346)
... 30 more
Re: Three identical tests, first one fails on Mac OS X [message #726127 is a reply to message #726123] Fri, 16 September 2011 16:02 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Usually a good idea is to focus the shell before interacting with it.

So I'd add the following to your snippet to make it robust:

private void findButton() throws InterruptedException {
Shell shell = new Shell(display);
shell.setTitle("SWT"); // set title
shell.setSize(200, 150);

Button button = new Button(shell, SWT.PUSH);
button.setText("hello world");

shell.open();
SWTBot bot = new SWTBot();
bot.shell("SWT").activate(); // focus on the right shell

// the assert will never execute because swtbot will throw an error
and never return null. Try it out if you wish by removing the button :)
assertNotNull(bot.button("hello world"));
}
Re: Three identical tests, first one fails on Mac OS X [message #726145 is a reply to message #726127] Fri, 16 September 2011 16:28 Go to previous messageGo to next message
Bernhard Pieber is currently offline Bernhard PieberFriend
Messages: 11
Registered: July 2009
Junior Member
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?

Bernhard & Görge

Am 16.09.11 18:02, schrieb Ketan Padegaonkar:
> SWTBot bot = new SWTBot();
> bot.shell("SWT").activate(); // focus on the right shell
>
> // the assert will never execute because swtbot will throw an error
> and never return null. Try it out if you wish by removing the button :)
> assertNotNull(bot.button("hello world"));

package com.softwaregeneration.learning;

import static org.junit.Assert.assertNotNull;

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.After;
import org.junit.Before;
import org.junit.Test;

public class SWTBotFinderTest {

private Display display;

@Before
public void setUp() {
display = new Display();
}

@After
public void tearDown() {
display.dispose();
}

@Test
public void testFindButton1() throws Exception {
findButton();
}

@Test
public void testFindButton2() throws Exception {
findButton();
}

@Test
public void testFindButton3() throws Exception {
findButton();
}

private void findButton() throws InterruptedException {
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(); // focus on the right shell

// the assert will never execute because swtbot will throw an error
and never return null. Try it out if you wish by removing the button
assertNotNull(bot.button("hello world"));
}
}


SWTBotFinderTest
com.softwaregeneration.learning.SWTBotFinderTest
testFindButton1(com.softwaregeneration.learning.SWTBotFinderTest)
org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after:
5000 ms.: Timed out waiting for Shell {Test} to get activated
at
org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:398)
at
org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:372)
at
org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:360)
at
org.eclipse.swtbot.swt.finder.widgets.SWTBotShell.activate(SWTBotShell.java:71)
at
com.softwaregeneration.learning.SWTBotFinderTest.findButton(SWTBotFinderTest.java:54)
at
com.softwaregeneration.learning.SWTBotFinderTest.testFindButton1(SWTBotFinderTest.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at
org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
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 Go to previous messageGo to next message
Bernhard Pieber is currently offline Bernhard PieberFriend
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 Go to previous messageGo to next message
Bernhard Pieber is currently offline Bernhard PieberFriend
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 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
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 Go to previous messageGo to next message
Bernhard Pieber is currently offline Bernhard PieberFriend
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 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
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 Go to previous messageGo to next message
Bernhard Pieber is currently offline Bernhard PieberFriend
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 Go to previous message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
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 Go to previous message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
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
>>>>
>>>>
>>>
>>
>
Previous Topic:How to emulate mouse click to set a "breakpoint" in left side of eclipse code area?
Next Topic:Previous SWTBot versions in the p2 repo
Goto Forum:
  


Current Time: Thu Mar 28 09:54:58 GMT 2024

Powered by FUDForum. Page generated in 0.03316 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top