• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

An Easier Way to Control Test Order in TestNG?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I've seen a few similar questions posted but none that quite answered my question directly...
I'm using Selenium Webdriver 2.0 with TestNg and Java and I'm looking for a better way to control the order in which tests are run.
Really all I want is the tests cases to run in the order they're written in the classes.
It's intuitive. Its easy. Its maintainable. And I'm really surprised it's not the default for testNg.
(Why apply some random ordering when it's not explicitly requested by the coder?)

Anyway, I know that I can add a list of methods to my testng xml, but I have 130 tests so far (and several hundred to come!) and such a method list will be far too much for future maintenance.
EG when I add ten test methods I'll have to remember to add all those methods to my xml file. And what happens if I miss adding one? I'll never notice that it was never run...

So this solution would be a maintenance nightmare:

<test name="BVTQA01">
<classes>
<class name="TestPackage.BVT">
<methods>
<include name="testLogin"></include>
<include name="testAddToCart"></include>
...
<include name="test999 etc"></include>
</methods>
</class>
</classes>
</test>

I've also tried preserve-order:

<test name="BVTQA01" preserve-order="true">
<classes>
<class name="TestPackage.TestBVT" />
</classes>
</test>

but it's apparently ignored if I don't add a list of methods and the maintenance nightmare of 'include name' lists...

So currently I'm just listing my test classes in the xml file (as above- TestBVT which has 20 methods, etc.), and controlling test run order with 'depends on' annotations on the tests themselves.
However this is not ideal as I am creating dependencies on every method. And I want to remove the dependencies where they are not really necessary.
I only want to use 'depends on' when there is a real dependency.

I've also searched for creating the xml automatically from my @Test annotated methods. But the solutions posted are not clear on how to actually implement.

Any feedback on how to just make testNg run through my test classes from top to bottom, in order written, without any random sorting- or maintenance heavy list generation would be wonderful.
Thanks in advance,

JR
 
I AM MIGHTY! Especially when I hold this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic