testng - Running dependent and independent test methods in expected sequence -


i want execute test methods in sequence. have used classes in testng.xml preserve-order set true.

<test name="group-test" preserve-order="true" >     <classes>         <class name="com.dependency.classa">             <methods>                 <include name="create"/>                 <include name="enter"/>                 <include name="delete"/>             </methods>         </class>     </classes> </test> 

and test class is

public class classa {   @test() public void create() throws exception {     system.out.println("in method create");  }    @test(dependsonmethods= "create") public void enter() throws exception {     system.out.println("in method enter");  } @test() public void delete() throws exception {     system.out.println("in method delete");  } 

after executing test output is
in method create,
in method delete,
in method enter

but want first execute "create" "enter" "delete" method. here delete independent test method.

i read on google group question cedric beust mentions can either use dependency or explicitly include test methods in testng.xml. don't understand why enforcement? if want execute independent , dependent test methods in sequence want? have observed independent methods executed first , dependent methods.


ideally dependency should not preserving order skip test if previous method fails. kind of enforcement testng has causing lot of trouble!

i strugging same major (and must obvious) deficiency of testng. best solution have found far use priorities. eg @test(priority = 10), next test @test(priority = 20), etc. documentation , internet searches found far have said use @test(priority = 1), @test(priority = 2), run obvious future maintenance problem of having renumber tests every time add 1 in middle somewhere... solution of 10, 20, etc. better @ least allows add @test(priority = 11), 12, etc in between test1 , test2. work, i've verified. lucky testng not enforce 1,2,3 or we'd in trouble! oh , btw, if have group , method dependancies (which shouldn't use on tests unless required!) looks @test(priority = 10, groups = "login"), @test(priority = 20, groups = "login")etc. also, seems know, others maybe wondering, remember if dependancies used set test run ordering if 1 fails tests after skipped- not @ want. anyway, hope helps unstuck, @ least until better solution comes along. luck!


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -