0

My TestNG configuration below is not working:

<test verbose="2" name="JavaScript Layer Tests" preserve-order="true" parallel="false">
  <packages>
    <package name="com.bla.foo"/>
    <package name="com.bla.bar/>
  </packages>
</test>

I basically want to run the TestNG classes in those packages in order and with no parallelism. Each classes' methods use the @dependsOnMethods.

The reason here is that I am using Selenium and I need to have only one browser opened at a time.

If I switch TestNG's xml file to list all the classes then it works fine, but that makes adding new classes require changing the xml file.

Is there a way to get this to work for packages? I tried setting parallel to true and limiting to 1 thread but that too didn't work.

phs
  • 10,687
  • 4
  • 58
  • 84
user910046
  • 308
  • 4
  • 14
  • Would using a single browser as described in [this](http://stackoverflow.com/questions/8990683/use-same-web-driver-throughout-selenium-suite) post not work? – radimpe Jul 30 '13 at 18:05
  • I already am using one shared driver - the problem is that I am seeing TestA:Method1 being called, then TestB:Method1 being called and then TestA:Method2. But TestB:Method1 moved to a different page (its testing another html page) and thus TestA:Method2 is being run against the wrong page. – user910046 Jul 30 '13 at 18:43
  • Shouldn't you test the entire flow you intend in a single test? So TestA calls Method1 then Method2 and similarly TestB calls Method1 and then Method2. You can also modularise your Methods so they are reusable so if you have to visit the same page multiple times for the different tests, you simply call the same module all the time. – radimpe Jul 30 '13 at 19:09
  • That is the problem - the 2 test classes are running in parallel it seems and having a shared webdriver causes trouble. – user910046 Jul 30 '13 at 19:47

2 Answers2

0

Let me guess, you might run this TestNG file using Eclipse. No mater What your configurations in your xml, You must Check you run configurations in your IDE too. If your trying to run your tests in 'test'mode from your XML, But your IDE may run it in a 'class'mode or in 'methods'mode.please cross check it once.

update: I don't think that the parallel attribute takes values as false please refer the official documentations. Just remove that attribute and try as follows,

<test verbose="2" name="JavaScript Layer Tests" preserve-order="true">
  <packages>
    <package name="com.bla.foo"/>
  </packages>
  <packages>
    <package name="com.bla.bar/>
  </packages>
</test>

Note : Make sure each package has exactly one TestNG Class file.

Karthikeyan
  • 2,634
  • 5
  • 30
  • 51
0

We can specify the packages in the following manner. Hope this helps

<suite>
    <test name="Any logical name" preserve-order="true" verbose="2">
        <packages>
            <package name="Name of the package 1" />
        </packages>
    </test>

    <test name="Any logical name" preserve-order="true" verbose="2">
            <packages>
                <package name="Name of the package 2" />
            </packages>
        </test>
</suite>
Vinay
  • 648
  • 4
  • 12