Does that mean your testng ant task forked a separate process for each test class? Otherwise, it should run the tests in order. Wired. Also, the @BeforeTest method should only be called once for all test classes. However, I will go ahead to put your fix into trunk Tellurium core to see if that helps.
Thanks, Jian On Thu, Jun 10, 2010 at 11:38 PM, super fan 911 <[email protected]>wrote: > I think i found out why, and 'fixed' it by modifying the > TelluriumTestNGTestCase class. But, i'm not sure if this is the > proper place to fix it. The problem was the @BeforeClass was called > multiple times. And, since it's a static object, it was shared by all > my test classes that extended it. So, i 'fixed' it by adding a check > for null like so, > > @BeforeClass > public static void setUpForTest() { > if (tellurium == null) { > tellurium = TelluriumSupport.addSupport(); > tellurium.start(customConfig); > connector = (SeleniumConnector) tellurium.getConnector(); > } > } > > So, my guess is that if you use ant task to start your tests, it will > fire off your tests in non-sequential order? Basically, test 2 is not > going to wait until test 1 completes before starting? And, because > 'tellurium' is static, all my tests tried to start a selenium server. > > > > > On Jun 10, 2:46 pm, super fan 911 <[email protected]> wrote: > > This won't work because the "tellurium" object is protected and on a > > different package. My "YourTestNGTestCase" will be on its own > > package. Unless you're asking me to put my "YourTestNGTestCase" in > > the same package as "BaseTelluriumJavaTestCase" which I'll need to > > rebuild the tellurium source. The tests passed using JUnit w/o the > > error. The tests also passed with the error using TestNG. The > > problem is the error. > > > > public class YourTestNGTestCase extends BaseTelluriumJavaTestCase { > > > > @BeforeClass > > public static void setUpForTest() { > > tellurium = TelluriumSupport.addSupport(); > > tellurium.start(customConfig); > > connector = (SeleniumConnector) tellurium.getConnector(); > > } > > > > @AfterClass > > public static void tearDownForTest() { > > if(tellurium != null) > > tellurium.stop(); > > } > > > > } > > > > won't work because > > > > On Jun 10, 2:09 pm, Jian Fang <[email protected]> wrote: > > > > > I mean you can extend your class in the follow way. > > > > > public class YourTestNGTestCase extends BaseTelluriumJavaTestCase { > > > > > @BeforeClass > > > public static void setUpForTest() { > > > tellurium = TelluriumSupport.addSupport(); > > > tellurium.start(customConfig); > > > connector = (SeleniumConnector) tellurium.getConnector(); > > > } > > > > > @AfterClass > > > public static void tearDownForTest() { > > > if(tellurium != null) > > > tellurium.stop(); > > > } > > > > > } > > > > > Perhaps it took some time for the embedded selenium server to shutdown > for > > > the first test. But after some time, the embedded server > > > started up successfully and the second test went through? > > > > > BTW, are the tests failed or succeeded? > > > > > Thanks, > > > > > Jian > > > > > On Thu, Jun 10, 2010 at 4:56 PM, super fan 911 <[email protected] > >wrote: > > > > > > If my test cases extends BaseTelluriumJavaTestCase, it will fail > > > > because the selenium server hasn't been initialized and started. I > > > > can add the @BeforeTest and @AfterTest methods, > > > > but they won't be able to access the "tellurium" and "connector" > > > > objects because they are protected. > > > > > > I tried running multiple tests in Eclipse with the TestNG plug-in, i > > > > get the same result. > > > > > > If we look at the stack trace below, it looks like it's trying to > > > > configure the embedded selenium server 2x before starting the > > > > client...why? Is it trying to run the tests in parallel? > > > > > > [testng] Parse configuration file: TelluriumConfig.groovy from > > > > project root directory > > > > [testng] Configure UI Object Builders using configuration > > > > [testng] Configure widget modules using configuration > > > > [testng] Configure event handler using configuration > > > > [testng] Configure data accessor using configuration > > > > [testng] Configure dispatcher using configuration > > > > [testng] Configure Embedded Selenium Server using configuration > > > > [testng] Warning: No user-extensions.js > > > > [testng] Configure Selenium Client using configuration > > > > [testng] Configure Embedded Selenium Server using configuration > > > > [testng] Warning: No user-extensions.js > > > > [testng] java.net.BindException: Selenium is already running on > > > > port 4444. Or some other service is. > > > > [testng] at > > > > org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java: > > > > 378) > > > > [testng] at > > > > org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java: > > > > 224) > > > > [testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native > > > > Method) > > > > [testng] at > > > > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: > > > > 39) > > > > [testng] at > > > > > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: > > > > 25) > > > > [testng] at java.lang.reflect.Method.invoke(Method.java:597) > > > > [testng] at > > > > org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite > > > > $PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java: > > > > 229) > > > > [testng] at > > > > > > > org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java: > > > > 52) > > > > [testng] at > > > > > > > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java: > > > > 121) > > > > [testng] at > > > > > > > org.telluriumsource.server.SeleniumServerDaemon.run(SeleniumServerDaemon.groovy: > > > > 142) > > > > [testng] at org.telluriumsource.server.SeleniumServerDaemon > > > > $run.call(Unknown Source) > > > > [testng] at > > > > > > > org.telluriumsource.server.EmbeddedSeleniumServer.setUpSeleniumServer(EmbeddedSeleniumServer.groovy: > > > > 63) > > > > [testng] at org.telluriumsource.server.EmbeddedSeleniumServer > > > > $setUpSeleniumServer.callCurrent(Unknown Source) > > > > [testng] at > > > > > > > org.telluriumsource.server.EmbeddedSeleniumServer.runSeleniumServer(EmbeddedSeleniumServer.groovy: > > > > 74) > > > > [testng] at org.telluriumsource.server.EmbeddedSeleniumServer > > > > $runSeleniumServer.call(Unknown Source) > > > > [testng] at > > > > > > > org.telluriumsource.framework.TelluriumFramework.start(TelluriumFramework.groovy: > > > > 145) > > > > [testng] at org.telluriumsource.framework.TelluriumFramework > > > > $start.callCurrent(Unknown Source) > > > > [testng] at > > > > > > > org.telluriumsource.framework.TelluriumFramework.start(TelluriumFramework.groovy: > > > > 154) > > > > [testng] at > > > > > > > org.telluriumsource.test.java.TelluriumTestNGTestCase.setUpForTest(TelluriumTestNGTestCase.java: > > > > 23) > > > > [testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native > > > > Method) > > > > [testng] at > > > > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: > > > > 39) > > > > [testng] at > > > > > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: > > > > 25) > > > > [testng] at java.lang.reflect.Method.invoke(Method.java:597) > > > > [testng] at > > > > org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:644) > > > > [testng] at > > > > org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java: > > > > 443) > > > > [testng] at > > > > org.testng.internal.Invoker.invokeConfigurations(Invoker.java:160) > > > > [testng] at > > > > org.testng.internal.Invoker.invokeConfigurations(Invoker.java:90) > > > > [testng] at org.testng.TestRunner.beforeRun(TestRunner.java: > > > > 522) > > > > [testng] at org.testng.TestRunner.run(TestRunner.java:490) > > > > [testng] at org.testng.SuiteRunner.runTest(SuiteRunner.java: > > > > 329) > > > > [testng] at > > > > org.testng.SuiteRunner.runSequentially(SuiteRunner.java:324) > > > > [testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java: > > > > 296) > > > > [testng] at org.testng.SuiteRunner.run(SuiteRunner.java:201) > > > > [testng] at > > > > org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:915) > > > > [testng] at org.testng.TestNG.runSuitesLocally(TestNG.java:879) > > > > [testng] at org.testng.TestNG.run(TestNG.java:787) > > > > [testng] at org.testng.TestNG.privateMain(TestNG.java:952) > > > > [testng] at org.testng.TestNG.main(TestNG.java:925) > > > > [testng] Configure Selenium Client using configuration > > > > [testng] hello world 2 > > > > [testng] test passed. > > > > [testng] > > > > [testng] hello world > > > > [testng] test passed. > > > > [testng] PASSED: testXYZ > > > > [testng] PASSED: testXYZ > > > > [testng] > > > > [testng] =============================================== > > > > [testng] Functional > > > > [testng] Tests run: 2, Failures: 0, Skips: 0 > > > > [testng] =============================================== > > > > > > On Jun 10, 1:15 pm, Jian Fang <[email protected]> wrote: > > > > > FYI: comparison of JUnit and TestNG annotations. > > > > > > >http://www.mkyong.com/unittest/junit-4-vs-testng-comparison/ > > > > > > > On Thu, Jun 10, 2010 at 4:06 PM, Jian Fang < > [email protected]> > > > > wrote: > > > > > > Here is the code. > > > > > > > > public abstract class TelluriumTestNGTestCase extends > > > > > > BaseTelluriumJavaTestCase { > > > > > > > > @BeforeTest(alwaysRun = true) > > > > > > public static void setUpForTest() { > > > > > > tellurium = TelluriumSupport.addSupport(); > > > > > > tellurium.start(customConfig); > > > > > > connector = (SeleniumConnector) tellurium.getConnector(); > > > > > > } > > > > > > > > @AfterTest(alwaysRun = true) > > > > > > public static void tearDownForTest() { > > > > > > if(tellurium != null) > > > > > > tellurium.stop(); > > > > > > } > > > > > > } > > > > > > > > You can create a test case that extends > BaseTelluriumJavaTestCase. Then > > > > you > > > > > > use @BeforeClass and @AfterClass > > > > > > annotations to do setup and teardown in your test case. Let us > know if > > > > this > > > > > > works. > > > > > > > > BTW, Have you tried to run multiple Tellurium TestNG test cases > in an > > > > IDE? > > > > > > Just wonder if this problem is only ant related. > > > > > > > > Thanks, > > > > > > > > Jian > > > > > > > > On Thu, Jun 10, 2010 at 3:56 PM, Jian Fang < > [email protected] > > > > >wrote: > > > > > > > >> I am not sure if this is related to our changes in 0.7.0. We > have > > > > changed > > > > > >> the setup and teardown methods to use > > > > > >> @BeforeTest and @AfterTest annotations for > TelluriumTestNGTestCase so > > > > that > > > > > >> the embedded selenium server > > > > > >> will only be started once for multiple tests. Maybe the TestNG > ant > > > > task > > > > > >> does not handle that correctly? > > > > > > > >> If you change your file to use TelluriumJUnitTestCase, do you > have the > > > > > >> same problem? > > > > > > > >> The thread you mentioned was resolved because the ip in the > > > > configuration > > > > > >> file was not correct. > > > > > > > >> Thanks, > > > > > > > >> Jian > > > > > > > >> On Thu, Jun 10, 2010 > > > > ... > > > > read more ยป > > -- > You received this message because you are subscribed to the Google Groups > "tellurium-users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<tellurium-users%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/tellurium-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "tellurium-users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/tellurium-users?hl=en.
