java - @BeforeClass and inheritance - order of execution -
I have an abstract base class, which I use as the basis of my unit test (TestGroup 5.10). In this class, I start the whole environment for my tests, setting up database mapping etc. This abstract class has a way to do an @ beer class
annotation that initially does.
After this, I extend that square with specific classes in which I have the @Test
method and @BeforeClass
methods. These methods do the class-specific initial methods of the environment (for example, put some records in the database).
How do I apply special order of annotated methods to @BeforeClass
? I need people from an abstraction base to execute before the extended class people.
Example:
Abstract class A {@BeforeClass doInitialization () {. ..}} Expanding class B {@BeforeClass doSpecificInitialization () {...} @Test doTests () {...}}
Expected order:
A.Do Introductory B.doSpecificInitialization B.doTests
Actual order:
predictable initialization // & lt; - Crash, Init is inaccessible as a base (AOD.examplorer // & amp; lt; --- Executioned Bidotestes) // & lt; - /
It seems that testNG is in - try this one. @BeforeClass
to summary < Do not enter on the / code> class. Call it with each subclass.
Abstract class A {void doInitialization () {}} Expand square b A {@BeforeClass void doSpecificInitialization () {super.doInitialization (); } @ Test Wide Dots () {}}
Comments
Post a Comment