Hi guys

   
  I  imported the jars from net.sf.swtbot-2.0.0.1051-dev

   wrote a test case::::


 import net.sf.swtbot.SWTBotTestCase;
import net.sf.swtbot.utils.SWTUtils;
import net.sf.swtbot.widgets.TimeoutException;
import net.sf.swtbot.widgets.WidgetNotFoundException;

import org.eclipse.swt.widgets.Display;

public class SwtUI_Test extends SWTBotTestCase {

        static { 
                       startApplicationInAnotherThread();
                System.out.println("RANNN");
                
        }
        
        
        

        protected void setUp() throws Exception {
                super.setUp();
                waitForDisplayToAppear(5000);
        
        }



        public void testSwtUI() throws WidgetNotFoundException, TimeoutException
        {
                
                bot.sleep(100);
                bot.shell("Widgets").activate();
                bot.sleep(1100);
                System.out.println("Test Passed");
          
        
                
        }
        
        
private void waitForDisplayToAppear(long timeOut) throws TimeoutException,
InterruptedException {
                long endTime = System.currentTimeMillis() + timeOut;
                while (System.currentTimeMillis() < endTime) { // wait until 
timeout
                        try {
                                Display display = SWTUtils.display();
                                if (display != null)
                                         return;
                        } catch (Exception e) {
                                e.printStackTrace();
                        }
                        Thread.sleep(100); // sleep for a while and try again
                }
                throw new TimeoutException("timed out");
        }

        private static void startApplicationInAnotherThread() {
                new Thread(new Runnable() {
                        public void run() {
                                try {
                                        new SwtUI().main(new String[] {});
                                } catch (Exception e) {
                                        System.out.println("1");
                                        e.printStackTrace();
                                }
                        }
                }).start();
        }

}//class ends




 i got this Exception:::

junit.framework.AssertionFailedError: Exception in constructor: testSwtUI
(java.lang.IllegalStateException: Could not find a display
        at net.sf.swtbot.utils.SWTUtils.display(SWTUtils.java:244)
        at net.sf.swtbot.finder.ControlFinder.<init>(ControlFinder.java:86)
        at net.sf.swtbot.finder.ControlFinder.<init>(ControlFinder.java:76)
        at net.sf.swtbot.SWTBotFactory.<init>(SWTBotFactory.java:73)
        at net.sf.swtbot.SWTBot.<init>(SWTBot.java:84)
        at net.sf.swtbot.SWTBotTestCase.<init>(SWTBotTestCase.java:43)
        at SwtUI_Test.<init>(SwtUI_Test.java:25)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at junit.framework.TestSuite.createTest(TestSuite.java:54)
        at junit.framework.TestSuite.addTestMethod(TestSuite.java:280)
        at junit.framework.TestSuite.<init>(TestSuite.java:140)
        at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.getTest(JUnit3TestLoader.java:102)
        at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.loadTests(JUnit3TestLoader.java:59)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
)
        at junit.framework.Assert.fail(Assert.java:47)
        at junit.framework.TestSuite$1.runTest(TestSuite.java:90)
        at junit.framework.TestCase.runBare(TestCase.java:130)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:120)
        at junit.framework.TestSuite.runTest(TestSuite.java:230)
        at junit.framework.TestSuite.run(TestSuite.java:225)
        at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
        at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

The same test ran well with Bot 1.2.0.921




Any help on This
Thanks

B Bye
Veneet

-- 
View this message in context: 
http://www.nabble.com/Stuck-with-SWTBot-2.0---tp19990110p19990110.html
Sent from the SWTBot Users List mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
SWTBot-users mailing list
SWTBot-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swtbot-users
http://swtbot.org/ - a functional testing tool for SWT/Eclipse

Reply via email to