Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Not found Junit Test Case
Not found Junit Test Case [message #14168] Thu, 15 January 2009 11:17 Go to next message
Luis Miguel is currently offline Luis MiguelFriend
Messages: 31
Registered: July 2009
Member
Hello,

I am trying to test a eclipse plugin with SWTbot, but I having problems.

1)I added the plugins necessary for SWTbot.
2)I created a plug-in project in Eclipse and added my Junit Test case.
3)I configured my classpath and run this class like junit3 (Test runner)
4) Finally, I run a product like org.eclipse.sdk.ide

The result is:
Class not found eee.FooTest
java.lang.ClassNotFoundException: eee.FooTest
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl assInternal(BundleLoader.java:481)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:397)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:385)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:87)
at java.lang.ClassLoader.loadClass(Unknown Source)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.loadCl ass(BundleLoader.java:313)
at
org.eclipse.osgi.framework.internal.core.BundleHost.loadClas s(BundleHost.java:227)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.load Class(AbstractBundle.java:1274)
at
org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunne r$BundleClassLoader.findClass(RemotePluginTestRunner.java:38 )
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadC lass(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadC lasses(RemoteTestRunner.java:425)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:445)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
at
org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunne r.main(RemotePluginTestRunner.java:62)
at
net.sf.swtbot.eclipse.ui.TestApplication.runTests(TestApplic ation.java:122)
at
org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(Work benchTestable.java:68)
at java.lang.Thread.run(Unknown Source)

Can someone help me??

Thanks and regards.
Re: Not found Junit Test Case [message #14188 is a reply to message #14168] Thu, 15 January 2009 11:53 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
You may not be exporting the package from your plugin.

Also use JUnit 4 is not supported for execution from within Ant. I'd
recommend using JUnit 3. More on this here:
http://wiki.eclipse.org/SWTBot/UsersGuide

-- Ketan

On 15/1/09 16:47, Luis Miguel wrote:
> Hello,
>
> I am trying to test a eclipse plugin with SWTbot, but I having problems.
>
> 1)I added the plugins necessary for SWTbot.
> 2)I created a plug-in project in Eclipse and added my Junit Test case.
> 3)I configured my classpath and run this class like junit3 (Test runner)
> 4) Finally, I run a product like org.eclipse.sdk.ide
>
> The result is:
> Class not found eee.FooTest
> java.lang.ClassNotFoundException: eee.FooTest
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findCl assInternal(BundleLoader.java:481)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:397)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:385)
>
> at
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:87)
>
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.loadCl ass(BundleLoader.java:313)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleHost.loadClas s(BundleHost.java:227)
>
> at
> org.eclipse.osgi.framework.internal.core.AbstractBundle.load Class(AbstractBundle.java:1274)
>
> at
> org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunne r$BundleClassLoader.findClass(RemotePluginTestRunner.java:38 )
>
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadC lass(RemoteTestRunner.java:683)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadC lasses(RemoteTestRunner.java:425)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:445)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>
> at
> org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunne r.main(RemotePluginTestRunner.java:62)
>
> at
> net.sf.swtbot.eclipse.ui.TestApplication.runTests(TestApplic ation.java:122)
> at
> org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(Work benchTestable.java:68)
>
> at java.lang.Thread.run(Unknown Source)
>
> Can someone help me??
>
> Thanks and regards.
>
Re: Not found Junit Test Case [message #14205 is a reply to message #14188] Thu, 15 January 2009 12:54 Go to previous messageGo to next message
Luis Miguel is currently offline Luis MiguelFriend
Messages: 31
Registered: July 2009
Member
Hello Ketan!!

The plugin that I want to test is imported with Eclipse, because it
appears new functionality from my plugin in Eclipse.

In the second screenshot of
http://wiki.eclipse.org/SWTBot/UsersGuide#Getting_started_wi th_SWTBot_for_Eclipse_Plugins,
we must make a default workspace Data?

Thanks and regards

Luis Miguel
Re: Not found Junit Test Case [message #14256 is a reply to message #14205] Thu, 15 January 2009 13:09 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Hi,

I did not get the second part about the default workspace data, could
you elaborate ?

-- Ketan

On 15/1/09 18:24, Luis Miguel wrote:
> Hello Ketan!!
>
> The plugin that I want to test is imported with Eclipse, because it
> appears new functionality from my plugin in Eclipse.
> In the second screenshot of
> http://wiki.eclipse.org/SWTBot/UsersGuide#Getting_started_wi th_SWTBot_for_Eclipse_Plugins,
> we must make a default workspace Data?
>
> Thanks and regards
>
> Luis Miguel
>
Re: Not found Junit Test Case [message #14272 is a reply to message #14256] Thu, 15 January 2009 15:19 Go to previous messageGo to next message
Luis Miguel is currently offline Luis MiguelFriend
Messages: 31
Registered: July 2009
Member
Hi,
If you look the part of tutorial: "Executing SWTBot Tests for Eclipse
Plugins", when we select the application that I want to test,there are
three parts that we must configure: Workspace data, Program to run and
Java Runtime Environment.
The first (Workspace data), we select
"${workspace_loc}/../junit-workspace" or we select a new workspace? Is
this important?

Thanks and regards

Luis Miguel
Re: Not found Junit Test Case [message #14288 is a reply to message #14272] Thu, 15 January 2009 16:05 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
It does not matter where your workspace is located.

In order that tests are repeatable, and reproducible every time, it is
generally the case that you clear your workspace.

If you need some projects or some workspace settings that you need in
your workspace, you may import them as part of your test setup.

-- Ketan

On 15/1/09 20:49, Luis Miguel wrote:
> Hi,
> If you look the part of tutorial: "Executing SWTBot Tests for Eclipse
> Plugins", when we select the application that I want to test,there are
> three parts that we must configure: Workspace data, Program to run and
> Java Runtime Environment. The first (Workspace data), we select
> "${workspace_loc}/../junit-workspace" or we select a new workspace? Is
> this important?
>
> Thanks and regards
>
> Luis Miguel
>
Re: Not found Junit Test Case [message #14305 is a reply to message #14288] Thu, 15 January 2009 17:31 Go to previous messageGo to next message
Luis Miguel is currently offline Luis MiguelFriend
Messages: 31
Registered: July 2009
Member
Hello Ketan,

Thanks for yours answers.
Now, I can to run my Test Case but some actions do not work. For example,
in my test Case:

public class FooTest extends SWTBotEclipseTestCase {
// stuff you can do with Eclipse
public void testDoSomethingInterestingWithEclipse() throws Exception {
SWTBotView vista=bot.view("Package Explorer");
vista.close();

SWTBotMenu menuF=bot.menu("Window");
menuF.click();
}
}

The action: SWTBotView vista=bot.view("Package Explorer");
vista.close();
works, but the next action does not work. Console from Eclipse prints:

log4j:WARN No appenders could be found for logger
(net.sf.swtbot.matcher.AbstractMatcher).
log4j:WARN Please initialize the log4j system properly.

Any suggestions?

Thanks again.

Luis Miguel
Re: Not found Junit Test Case [message #15170 is a reply to message #14305] Fri, 16 January 2009 00:53 Go to previous messageGo to next message
Ketan Patel is currently offline Ketan PatelFriend
Messages: 68
Registered: July 2009
Member
You need to enable logging...see following:
http://wiki.eclipse.org/SWTBot/FAQ#How_do_I_configure_log4j_ to_turn_on_logging_for_SWTBot.3F
Re: Not found Junit Test Case [message #15203 is a reply to message #15170] Mon, 19 January 2009 08:31 Go to previous messageGo to next message
Luis Miguel is currently offline Luis MiguelFriend
Messages: 31
Registered: July 2009
Member
Hello Ketan,

Thanks for yours answers one more time. Now, I can to run my Test Case
without WARNINGS about log4j but I have problems with
AbstractMatcher.java. If I run this code:

public class FooTest extends SWTBotEclipseTestCase {
// stuff you can do with Eclipse
public void testDoSomethingInterestingWithEclipse() throws Exception {
bot.view("Package Explorer").close();
bot.menu("File").menu("New").click();
}
}

The action " bot.menu("File").menu("New").click()" does not work. Console
from Eclipse prints:

16 ene 2009 13:40:53.140 - main - TRACE - AbstractMatcher -
(AbstractMatcher.java:63) - +---Widget: MenuItem{Format Eleme&nt}
16 ene 2009 13:40:53.140 - main - TRACE - AbstractMatcher -
(AbstractMatcher.java:51) - did not match MenuItem A&dd Import, using
matcher: with mnemonic 'File'
.......................

If I capture this action between a "try..catch" structure throws a
WidgetNotFoundException.

Thanks and regards.

Luis Miguel
Re: Not found Junit Test Case [message #15268 is a reply to message #15203] Mon, 19 January 2009 09:06 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
On 19/1/09 14:01, Luis Miguel wrote:
> Hello Ketan,
>
> Thanks for yours answers one more time. Now, I can to run my Test Case
> without WARNINGS about log4j but I have problems with
> AbstractMatcher.java. If I run this code:
>
> public class FooTest extends SWTBotEclipseTestCase {
> // stuff you can do with Eclipse
> public void testDoSomethingInterestingWithEclipse() throws Exception {
> bot.view("Package Explorer").close(); bot.menu("File").menu("New").click();
> }
> }
>
> The action " bot.menu("File").menu("New").click()" does not work.

You're probably getting an exception on the "Package Explorer" closing.
bot.view("Welcome").close();

Also you'd perhaps want to do:
bot.menu("File").menu("New").menu("Class").click();

"New" happens to be a container for menu items, and clicking on it does
nothing. There's a screenshots folder in your plugin that may have more
information on why the test actually failed.

-- Ketan
Re: Not found Junit Test Case [message #15334 is a reply to message #15268] Mon, 19 January 2009 10:57 Go to previous messageGo to next message
Luis Miguel is currently offline Luis MiguelFriend
Messages: 31
Registered: July 2009
Member
Hello Ketan,
I write below your last post for to explain my problem:

- "You're probably getting an exception on the "Package Explorer" closing.
bot.view("Welcome").close();"

This does not happen because I have tried without this line and continuing
the same problem.

- "Also you'd perhaps want to do:
bot.menu("File").menu("New").menu("Class").click();
"New" happens to be a container for menu items, and clicking on it does
nothing.

It is true, but the problem is about the first menu: "File".
If I try with the action: "bot.menu("Window").menu("New
Window").click();", the problem is with "Window" (first menu).

With the action "bot.menu("File").menu("New").menu("Class").click();": My
problem does not change. Console prints:

AbstractMatcher - (AbstractMatcher.java:51) - did not match MenuItem
Togg&le Comment, using matcher: with mnemonic 'File'
AbstractMatcher - (AbstractMatcher.java:63) - +---Widget: MenuItem{Togg&le
Comment}
AbstractMatcher - (AbstractMatcher.java:51) - did not match MenuItem Add
&Block Comment, using matcher: with mnemonic 'File'
AbstractMatcher - (AbstractMatcher.java:63) - +---Widget: MenuItem{Add
&Block Comment}
....
....

If you want to, I could send the entire log.

Thanks and regards

Luis Miguel
Re: Not found Junit Test Case [message #15367 is a reply to message #15334] Mon, 19 January 2009 12:01 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Please file a bug with a reproducible test case that I can execute on my
machine.

I'll need to know the version number of eclipse and SWTBot that you're
using.

-- Ketan

On 19/1/09 16:27, Luis Miguel wrote:
> If you want to, I could send the entire log.
>
> Thanks and regards
>
> Luis Miguel
>
Re: Not found Junit Test Case [message #15400 is a reply to message #15367] Mon, 19 January 2009 12:30 Go to previous messageGo to next message
Luis Miguel is currently offline Luis MiguelFriend
Messages: 31
Registered: July 2009
Member
Hi,
Eclipse version: 3.4.1
SWTBot version: 2.0

If you put the next code in your junit test case, you will have my problem:

import net.sf.swtbot.eclipse.finder.SWTBotEclipseTestCase;

public class FooTest extends SWTBotEclipseTestCase {

public void testDoSomethingInterestingWithEclipse() throws Exception {
bot.view("Package Explorer").close(); //This works.
bot.menu("Window").menu("New Window").click();

}

Regards.

Luis Miguel
Re: Not found Junit Test Case [message #15530 is a reply to message #15400] Tue, 20 January 2009 03:08 Go to previous messageGo to next message
Ketan Patel is currently offline Ketan PatelFriend
Messages: 68
Registered: July 2009
Member
Interesting, I am not seeing this issue...using swtbot 2.0.0.75
Re: Not found Junit Test Case [message #15561 is a reply to message #15400] Tue, 20 January 2009 03:21 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
On 19/1/09 18:00, Luis Miguel wrote:
> Hi,
> Eclipse version: 3.4.1
> SWTBot version: 2.0

2.0 is quite a broad version I'll need the full version number of the
form "2.0.0.SOME_NUMBER"

-- Ketan
Re: Not found Junit Test Case [message #15591 is a reply to message #15561] Tue, 20 January 2009 08:34 Go to previous messageGo to next message
Luis Miguel is currently offline Luis MiguelFriend
Messages: 31
Registered: July 2009
Member
Sorry,
My SWTBot version is 2.0.0.1164.


Luis Miguel
Re: Not found Junit Test Case [message #15623 is a reply to message #15591] Tue, 20 January 2009 08:40 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
On 20/1/09 14:04, Luis Miguel wrote:
> Sorry,
> My SWTBot version is 2.0.0.1164.
>
> Luis Miguel
>


You're using an older version of swtbot that was available at the old
website.

Please uninstall the old version first and use a new version available
at: http://swtbot.sourceforge.net/artifacts/2.0-eclipse/update-s ite/

-- Ketan
Re: Not found Junit Test Case [message #15683 is a reply to message #15623] Tue, 20 January 2009 11:50 Go to previous messageGo to next message
Luis Miguel is currently offline Luis MiguelFriend
Messages: 31
Registered: July 2009
Member
Hi,

I'm desperate.The same problem again! Perhaps I have wrong the plugin
configuration. I have org.eclipse.swtbot.eclipse-2.0.0.75-dev.zip with two
folders ("features" and "plugins"). Before you start Eclipse with SWTBot,
I add the content of "features" to "features" of my Eclipse. The same for
the "plugins" folder.
In addition, I add the contents of "features" and "plugins" from
net.sf.swtbot.eclipse-2.0.0.1164-dev to "features" and "plugins" of my
Eclipse. I do this because it says the tutorial from
http://swtbot.sourceforge.net/users-guide.html.

Okay this configuration?

Thanks!!

Luis Miguel
Re: Not found Junit Test Case [message #15709 is a reply to message #15683] Tue, 20 January 2009 13:04 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Luis,

Can you try taking a fresh eclipse install, and extract the zip file
into the eclipse's 'dropins' folder, the update site is broken for
version 2.0.0.75, and I'll be fixing it later.

Type in the following test:

public class FooTest extends SWTBotTestCase {
public void testDoSomethingInterestingWithEclipse() throws Exception {
bot.view("Welcome").close();
bot.menu("File").menu("New").menu("Class").click();
}
}

and you should get a green bar.

-- Ketan

On 20/1/09 17:20, Luis Miguel wrote:
> Hi,
>
> I'm desperate.The same problem again! Perhaps I have wrong the plugin
> configuration. I have org.eclipse.swtbot.eclipse-2.0.0.75-dev.zip with
> two folders ("features" and "plugins"). Before you start Eclipse with
> SWTBot, I add the content of "features" to "features" of my Eclipse. The
> same for the "plugins" folder.
> In addition, I add the contents of "features" and "plugins" from
> net.sf.swtbot.eclipse-2.0.0.1164-dev to "features" and "plugins" of my
> Eclipse. I do this because it says the tutorial from
> http://swtbot.sourceforge.net/users-guide.html.
>
> Okay this configuration?
>
> Thanks!!
>
> Luis Miguel
>
Re: Not found Junit Test Case [message #16401 is a reply to message #15709] Tue, 20 January 2009 17:04 Go to previous messageGo to next message
Luis Miguel is currently offline Luis MiguelFriend
Messages: 31
Registered: July 2009
Member
Hi,
If I extend from SWTBotTestCase class, I need import
net.sf.swtbot.SWTBotTestCase and the last version is
net.sf.swtbot-2.0.0.1164-dev.
In addition, if I extend from SWTBotTestCase, the action bot.view
("Welcome").close() does not work.
Re: Not found Junit Test Case [message #16408 is a reply to message #16401] Tue, 20 January 2009 17:09 Go to previous message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Oops, I'd meant SWTBotEclipseTestCase.

If things do not work, please file a bug at bugs.eclipse.org and attach
the complete log file (compress it please)

-- Ketan

On 20/1/09 22:34, Luis Miguel wrote:
> Hi,
> If I extend from SWTBotTestCase class, I need import
> net.sf.swtbot.SWTBotTestCase and the last version is
> net.sf.swtbot-2.0.0.1164-dev. In addition, if I extend from
> SWTBotTestCase, the action bot.view ("Welcome").close() does not work.
>
Previous Topic:drag-and-drop
Next Topic:Close a graphical editor
Goto Forum:
  


Current Time: Fri Apr 19 11:41:25 GMT 2024

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

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

Back to the top