Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Problem executing SWTbot+Junit4 test
Problem executing SWTbot+Junit4 test [message #510729] Thu, 28 January 2010 13:25 Go to next message
Ivan Delibashev is currently offline Ivan Delibashev
Messages: 5
Registered: January 2010
Junior Member
Hi all,

I have been trying to execute example from user guide wiki.

But i have got following error after eclipse instance was started and shown:
java.lang.Exception: No runnable methods
at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMet hods(BlockJUnit4ClassRunner.java:154)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializati onErrors(BlockJUnit4ClassRunner.java:112)
at org.junit.runners.ParentRunner.validate(ParentRunner.java:25 3)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:55)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:56)
at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUn it4Builder.java:13)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(Run nerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.r unnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(Run nerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequ est.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init >(JUnit4TestReference.java:29)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassRefere nce. <init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.crea teTest(JUnit4TestLoader.java:40)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.load Tests(JUnit4TestLoader.java:30)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:390)
at org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main( RemotePluginTestRunner.java:64)
at org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(U ITestApplication.java:117)
at org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(Work benchTestable.java:71)
at java.lang.Thread.run(Thread.java:619)

I think i have set everything in run configuration.

Your help will be much appreciated

Regards
Ivan
Re: Problem executing SWTbot+Junit4 test [message #510778 is a reply to message #510729] Thu, 28 January 2010 10:32 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan Padegaonkar
Messages: 873
Registered: July 2009
Senior Member
Assuming that you are using junit4, did you mark your methods with an
@Test annotation.

-- Ketan

On 1/28/10 5:25 AM, Ivan Delibashev wrote:
> Hi all,
>
> I have been trying to execute example from user guide wiki.
>
> But i have got following error after eclipse instance was started and
> shown:
> java.lang.Exception: No runnable methods
> at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMet
> hods(BlockJUnit4ClassRunner.java:154)
> at org.junit.runners.BlockJUnit4ClassRunner.collectInitializati
> onErrors(BlockJUnit4ClassRunner.java:112)
> at org.junit.runners.ParentRunner.validate(ParentRunner.java:25 3)
> at org.junit.runners.ParentRunner.<init>(ParentRunner.java:55)
> at
> org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:56)
>
> at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUn
> it4Builder.java:13)
> at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(Run
> nerBuilder.java:57)
> at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.r
> unnerForClass(AllDefaultPossibilitiesBuilder.java:29)
> at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(Run
> nerBuilder.java:57)
> at org.junit.internal.requests.ClassRequest.getRunner(ClassRequ
> est.java:24)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init
> >(JUnit4TestReference.java:29)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassRefere nce.
> <init>(JUnit4TestClassReference.java:25)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.crea
> teTest(JUnit4TestLoader.java:40)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.load
> Tests(JUnit4TestLoader.java:30)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe
> sts(RemoteTestRunner.java:452)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe
> sts(RemoteTestRunner.java:683)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R
> emoteTestRunner.java:390)
> at org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main(
> RemotePluginTestRunner.java:64)
> at org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(U
> ITestApplication.java:117)
> at org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(Work
> benchTestable.java:71)
> at java.lang.Thread.run(Thread.java:619)
>
> I think i have set everything in run configuration.
>
> Your help will be much appreciated
>
> Regards
> Ivan
Re: Problem executing SWTbot+Junit4 test [message #510906 is a reply to message #510778] Fri, 29 January 2010 06:09 Go to previous messageGo to next message
Ivan Delibashev is currently offline Ivan Delibashev
Messages: 5
Registered: January 2010
Junior Member
Yes, I have used the example from user guide wiki. Here is the code:
import junit.framework.TestCase;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(SWTBotJunit4ClassRunner.class)
public class TestClass{

private static SWTWorkbenchBot bot;

@BeforeClass
public static void beforeClass() throws Exception {
bot = new SWTWorkbenchBot();
bot.viewByTitle("Welcome").close();
}

@Test
public void canCreateANewJavaProject() throws Exception {
bot.menu("File").menu("New").menu("Project...").click();

SWTBotShell shell = bot.shell("New Project");
shell.activate();
bot.tree().select("Project");
bot.button("Next >").click();

bot.textWithLabel("Project name:").setText("MyFirstProject");

bot.button("Finish").click();
// FIXME: assert that the project is actually created, for later
}

@AfterClass
public static void sleep() {
bot.sleep(2000);
}
}
Re: Problem executing SWTbot+Junit4 test [message #510914 is a reply to message #510729] Fri, 29 January 2010 07:22 Go to previous messageGo to next message
No real name is currently offline No real name
Messages: 3
Registered: January 2010
Junior Member
Are you using a target platform?
Re: Problem executing SWTbot+Junit4 test [message #510916 is a reply to message #510914] Fri, 29 January 2010 07:32 Go to previous messageGo to next message
Ivan Delibashev is currently offline Ivan Delibashev
Messages: 5
Registered: January 2010
Junior Member
What you mean by target platform?
Re: Problem executing SWTbot+Junit4 test [message #511141 is a reply to message #510729] Sat, 30 January 2010 11:49 Go to previous messageGo to next message
Dan Corneanu is currently offline Dan Corneanu
Messages: 10
Registered: July 2009
Junior Member
Hi,
in your run configuration check that:
- Project: really points to the project that is holding your test class
- Test class: really points to your test class
- Run in UI thread: is not checked
Make sure the run configuration is a "SWTBot Test" run configuration.

This may be a stupide question but, have you tried this:
- select your test class
- mouse right click
- Run as -> SWTBot Test

Best regards,
Dan.
Re: Problem executing SWTbot+Junit4 test [message #511324 is a reply to message #511141] Mon, 01 February 2010 09:40 Go to previous messageGo to next message
Ivan Delibashev is currently offline Ivan Delibashev
Messages: 5
Registered: January 2010
Junior Member
Thanks for pointers, but the error is the same
I am still no able to run test because above reason
Re: Problem executing SWTbot+Junit4 test [message #511371 is a reply to message #511324] Mon, 01 February 2010 08:16 Go to previous messageGo to next message
Dan Corneanu is currently offline Dan Corneanu
Messages: 10
Registered: July 2009
Junior Member
Ivan,
if your project is just a sample and contains no confidential data, then
maybe you can
- select your run configuration, go to tab Common and check "Shared
file" in the "Save as" section.
- save your project
- close eclipse
- make a zip and send it over to me and I'll have a look

corneanu_dan@yahoo.com

Best regards,
Dan.

On 2/1/2010 11:40 AM, Ivan Delibashev wrote:
> Thanks for pointers, but the error is the same
> I am still no able to run test because above reason
Re: Problem executing SWTbot+Junit4 test [message #511577 is a reply to message #511371] Tue, 02 February 2010 06:52 Go to previous messageGo to next message
Ivan Delibashev is currently offline Ivan Delibashev
Messages: 5
Registered: January 2010
Junior Member
Thanks Dan.
I am sending you the whole project.

Regards
Ivan
Re: Problem executing SWTbot+Junit4 test [message #524678 is a reply to message #511577] Thu, 01 April 2010 18:55 Go to previous messageGo to next message
No real name is currently offline No real name
Messages: 8
Registered: February 2010
Junior Member
I have the same issue.Here is a bit more info:

The example at http://wiki.eclipse.org/SWTBot/Ant

refers to http://github.com/ketan/swtbot/blob/master/org.eclipse.swtbo t.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/ AllTests.java

which defines AllTests.java as:
@RunWith(SWTBotJUnit4Suite.class)
@SuiteClasses( { QuickFixNotFoundExceptionTest.class, CommandFinderTest.class, SWTBotEclipseEditorTest.class, SWTBotViewTest.class })
public class AllTests {}

Note the @RunWith(SWTBotJUnit4Suite.class).
1) If I use SWTBotJUnit4Suite, my AllTests fails with the runtime error:
Custom runner class SWTBotJUnit4Suite should have a public constructor with signature SWTBotJUnit4Suite(Class testClass)
I do not understand why the example code had no such constructor.

2) I then experimented with @RunWith(SWTBotJunit4ClassRunner.class)

Running the test gives the "No runnable methods" error

Hmmmm.. Thoughts?


Re: Problem executing SWTbot+Junit4 test [message #822321 is a reply to message #510729] Fri, 16 March 2012 13:17 Go to previous message
Jon Buck is currently offline Jon Buck
Messages: 29
Registered: July 2009
Junior Member
Does anybody know the answer to this question, I am trying SWTBot for the first time and I am trying the simple example in the detailed user guides fails which fails with this error...

I am using SWTBot 2.0.5, eclipse 3.6.2.
Previous Topic:How accessing to context Menu of a SWTBotGefEditPart
Next Topic:source level debug of SWTBot code
Goto Forum:
  


Current Time: Thu Oct 23 12:35:08 GMT 2014

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

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