Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » hanging on new SWTWorkbenchBot()
hanging on new SWTWorkbenchBot() [message #1111566] Wed, 18 September 2013 11:53 Go to next message
Benoit Ries is currently offline Benoit Ries
Messages: 50
Registered: May 2013
Member
Hi,

I'm newbie with SWTBot. I installed latest version 2.1.1 and junit 4.8.1 in Eclipse juno 4.2.2 on mac platform following http://wiki.eclipse.org/SWTBot/UsersGuide.

1) I could not add dependency to org.hamcrest. because in the SWTBot update-site, I could only find org.hamcrest.library and org.hamcrest.core This may have nothing to do with my issue, but I wanted to mention it, just in case.

2.a) When I run an extremely simple example like this one, it works fine:

---------------------------------------------
import static org.junit.Assert.assertTrue;

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(SWTBotJunit4ClassRunner.class)
public class MyFirstTest {
@Test
public void alwaysTrue() throws Exception {
assertTrue(true);
}
}
---------------------------------------------

2.b) But as soon as I add new SWTWorkbenchBot() either in the BeforeClass or Test as below, the code is hanging forever when I run it (using Run as SWTBot Test). I don't get any exception in the Console view.

---------------------------------------------
import static org.junit.Assert.assertTrue;

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(SWTBotJunit4ClassRunner.class)
public class MyFirstTest {
private static SWTWorkbenchBot bot;

@BeforeClass
public static void beforeClass() throws Exception {
bot = new SWTWorkbenchBot();
}

@Test
public void alwaysTrue() throws Exception {
assertTrue(true);
}
}
---------------------------------------------

2.c) if I debug this code step-by-step using Debug as SWTBot Test. The code works ok without hanging and the eclipse instance launched by SWBot is closed properly.


Any idea where this could be coming from ? maybe any configuration step I've missed.

Many thanks in advance,
BenoƮt


[Updated on: Wed, 18 September 2013 11:53]

Report message to a moderator

Re: hanging on new SWTWorkbenchBot() [message #1111614 is a reply to message #1111566] Wed, 18 September 2013 13:05 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael Istria
Messages: 755
Registered: July 2009
Location: Grenoble, France
Senior Member
On 09/18/2013 01:53 PM, Benoit Ries wrote:
> 1) I could not add dependency to org.hamcrest. because in the SWTBot
> update-site, I could only find org.hamcrest.library and
> org.hamcrest.core This may have nothing to do with my issue, but I
> wanted to mention it, just in case.

Those Hamcrest bundles are on the SWTBot update-site, but they are not
shown in installer. They are silently installed together with the SWTBot
features or bundles which depend on them.

> 2.b) But when as soon as I add new SWTWorkbenchBot() either in the
> BeforeClass or Test as below, the code is hanging forever when I run it
> (using Run as SWTBot Test). I don't get any exception in the Console view.
>
> 2.c) if I debug this code step-by-step using Debug as SWTBot Test. The
> code works ok without hanging and the eclipse instance launched by SWBot
> is closed properly.
>
> Any idea where this could be coming from ? maybe any configuration step
> I've missed.

Not really.
What does happen if you use Debug as SWTBot but set no breakpoint?
Is there any difference between you Run and Debug configuration. A cause
of locks in SWTBot are tests running in UI Thread (they shouldn't run in
UI Thread).

--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: hanging on new SWTWorkbenchBot() [message #1111624 is a reply to message #1111614] Wed, 18 September 2013 13:29 Go to previous messageGo to next message
Benoit Ries is currently offline Benoit Ries
Messages: 50
Registered: May 2013
Member

[quote title=Mickael Istria wrote on Wed, 18 September 2013 15:05]On 09/18/2013

> Those Hamcrest bundles are on the SWTBot update-site, but they are not
> shown in installer. They are silently installed together with the SWTBot
> features or bundles which depend on them.

ok, I have installed the two features available in the update-site namely "Hamcrest Core Library Matchers" and "Hamcrest Library of Addiitonal Matchers" v1.3.0 (and thei

But, when I want to add the "org.hamcrest" plugin in the Dependencies of the manifest file (as mentioned in the UsersGuide page), the problem is that particular plugin (i.e. org.hamcrest) doesn't appear. I have the choice between org.hamcrest.core.source and org.hamcrest.library, is this normal ?

> What does happen if you use Debug as SWTBot but set no breakpoint?
> Is there any difference between you Run and Debug configuration.

no difference if I set no breakpoints, then the eclipse instance is hanging like when running it.

> A cause of locks in SWTBot are tests running in UI Thread (they shouldn't run in
> UI Thread).

I have read this in the documentation, but what does it mean concretely. you see my simple example + I run using Run as SWTBot Test. Is it enough ? or is there some other trick/configuration in order to run the tests outside UI thread ?

thanks,
Re: hanging on new SWTWorkbenchBot() [message #1112136 is a reply to message #1111624] Thu, 19 September 2013 06:55 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael Istria
Messages: 755
Registered: July 2009
Location: Grenoble, France
Senior Member
On 09/18/2013 03:29 PM, Benoit Ries wrote:
> But, when I want to add the "org.hamcrest" plugin in the Dependencies of
> the manifest file (as mentioned in the UsersGuide page), the problem is
> that particular plugin (i.e. org.hamcrest) doesn't appear. I have the
> choice between org.hamcrest.core.source and org.hamcrest.library, is
> this normal ?

org.hamcrest doesn't exist. It's org.hamcrest.core.
And I guess the plugin selection dialog doesn't show them because they
are re-exported by some other dependency.
Anyway, feel free to bypass the dialog and open the MANIFEST.MF and add
those bundles as dependencies if you want.


>> What does happen if you use Debug as SWTBot but set no breakpoint?
>> Is there any difference between you Run and Debug configuration.
>
> no difference if I set no breakpoints, then the eclipse instance is
> hanging like when running it.

Sorry, I don't have a clue. It seems to be specific to your use-case.
Maybe some concurrent work causing a deadlock.

> I have read this in the documentation, but what does it mean concretely.
> you see my simple example + I run using Run as SWTBot Test. Is it enough
> ? or is there some other trick/configuration in order to run the tests
> outside UI thread ?

Run as SWTBot Test is configured to always Run outside of UI Thread, so
it should be fine.
You can give a try to the "Run As Plugin Test" dialog (which does almost
the same thing and allow to control whether or not to run in UI Thread).
Maybe you'll get more luck or notice a small difference that will help
you to find the reason of this strange behavior.

--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: hanging on new SWTWorkbenchBot() [message #1112208 is a reply to message #1112136] Thu, 19 September 2013 08:53 Go to previous message
Benoit Ries is currently offline Benoit Ries
Messages: 50
Registered: May 2013
Member
[quote title=Mickael Istria wrote on Thu, 19 September 2013 08:55]On 09/18/2013

> org.hamcrest doesn't exist. It's org.hamcrest.core.

ok thanks for the clarification, maybe the UsersGuide page could be updated to avoid other people having the same kind of confusion.

> You can give a try to the "Run As Plugin Test" dialog (which does almost
> the same thing and allow to control whether or not to run in UI Thread).
> Maybe you'll get more luck or notice a small difference that will help
> you to find the reason of this strange behavior.

Thanks a lot for the tip, my simple example is now running correctly when using Run as JUnit plug-in test Smile
Previous Topic:Clicking Source, Design tabs for XML files
Next Topic:250 EUR to win for the best SWTBot logo!
Goto Forum:
  


Current Time: Tue Sep 23 04:36:34 GMT 2014

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

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