is multiple @BeforeClass methods allowed? Is it possible to order the execution of multiple @BeforeClass methods?

1,973 views
Skip to first unread message

TInaTinaTian L

unread,
Aug 26, 2014, 4:26:04 PM8/26/14
to testng...@googlegroups.com
@BeforeClass
public static void method1(){}

@BeforeClass
public static void method2(){}

@BeforeClass
public static void method3(){}

Is it possible to order the execution of these @BeforeClass methods? My understanding is that @BeforeClass are used for configurations so it doesn't support this kind of format. 
I have tried with dependsOnMethods = {"method3"} but it seems to ignore this and still execute by alphabetic order of the method names.

Mark Derricutt

unread,
Aug 26, 2014, 6:04:46 PM8/26/14
to testng...@googlegroups.com

Why not just use the simplest method possible:

@BeforeClass
public static void method1() {
  ...
  method2();
  method3();
}

Mark

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

CreeTar

unread,
Aug 27, 2014, 11:28:28 AM8/27/14
to testng...@googlegroups.com
Looks like you have a flaw in your design. This does not seem effective ;) what are you trying to achieve?
if method1... has each a own @BeforeClass why not add the stuff into the test?
Reply all
Reply to author
Forward
0 new messages