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 at 2:06 PM, super fan 911 <[email protected]>wrote:
>>
>>> First, I am not an Ant expert.  I am trying to create an ant task to
>>> run my tests.  Below is my ant task,
>>>
>>> <target name="run-test-testng" depends="compile-test">
>>>   <echo message="Running testng test..." />
>>>   <testng classpathref="run.classpath" groups="${testng.groups}"
>>> outputDir="${dir.build.report}" haltOnFailure="true" verbose="2"
>>> suiteName="${testng.suite.name}" testName="${testng.test.name}">
>>>          <classfileset dir="${dir.build.test}" includes="**/
>>> SampleTest.class" />
>>>          <classfileset dir="${dir.build.test}" includes="**/
>>> Sample2Test.class" />
>>>   </testng>
>>> </target>
>>>
>>> Here are my sample tests,
>>>
>>> public class SampleTest extends TelluriumTestNGTestCase {
>>>
>>>        @Test(enabled=true, groups=["regression"])
>>>        public void testXYZ() {
>>>                openUrl("http://www.yahoo.com";);
>>>                sleep 3000
>>>                System.out.println("hello world");
>>>        }
>>> }
>>>
>>>
>>> public class Sample2Test extends TelluriumTestNGTestCase {
>>>
>>>        @Test(enabled=true, groups=["regression"])
>>>        public void testXYZ() {
>>>                openUrl("http://www.google.com";);
>>>                sleep 3000
>>>                System.out.println("hello world 2");
>>>        }
>>> }
>>>
>>> I have set "runInternally = true" in Tellurium config file.
>>>
>>> Here is my stack trace,
>>>
>>> run-test-testng:
>>>     [echo] Running testng test...
>>>   [testng] [Parser] Running:
>>>   [testng]   Regression Testing
>>>   [testng]
>>>   [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] hello world
>>>   [testng] PASSED: testXYZ
>>>   [testng] PASSED: testXYZ
>>>   [testng]
>>>   [testng] ===============================================
>>>   [testng]     Functional
>>>   [testng]     Tests run: 2, Failures: 0, Skips: 0
>>>   [testng] ===============================================
>>>   [testng]
>>>   [testng]
>>>   [testng] ===============================================
>>>   [testng] Module Testing
>>>   [testng] Total tests run: 2, Failures: 0, Skips: 0
>>>   [testng] ===============================================
>>>   [testng]
>>>   [testng] [org.testng.internal.PoolService] Shutting down
>>> poolservice org.testng.internal.poolserv...@617e53c9 terminated:false
>>>
>>>
>>> First, if I only have one class file, everything works fine.  The
>>> problem only arise when I have 2+ test classes in the ant task.
>>>
>>> This is how I understood how things worked:
>>>
>>> - runInternally = true  will start the embedded selenium server for
>>> you
>>>
>>> - In TelluriumTestNGTestCase class, there is the annotated
>>> setUpForTest an tearDownForTest methods which will start the Tellurium
>>> server (embedded selenium server) and connects the test to it, and
>>> stop during tear down.
>>>
>>> - Looking at the execution window, I did see 2 separate browser
>>> sessions popup and go down which leads me to think that the setup and
>>> teardown methods did get call.  What i don't understand is where else
>>> is an attempt to start the selenium server happening...
>>>
>>>
>>> I saw this thread, but didn't find a solution there.
>>>
>>>
>>> http://groups.google.com/group/tellurium-users/browse_thread/thread/d265147501a92f12/7ff565bf7c85db5b?lnk=gst&q=selenium+server
>>>
>>> --
>>> 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.

Reply via email to