jeudi 15 juin 2017

Disable TestNG BaseClass Reinitialization

I am trying to run multiple test classes inside a TestNG suite under Spring Context:

<!DOCTYPE suite SYSTEM "http://ift.tt/19x2mI9" >
<suite name="Integration Test Suite" >
<test name="Integration Test">

<classes>
    <class> someclass </class>
    <class> someclass2 </class>
</classes>

</test>
</suite>

Both classes extends a base class:

@TestPropertySource(properties...)
@ContextConfiguration(config classes...)
public class BaseTestContext extends AbstractTestNGSpringContextTests {
   ...logic...
}

I am doing time consuming prepare steps before the test classes and caching the result, so separate classes will run faster with the cached value of that preparation. However TestNG creates a new instance from BaseTestContext before every test class so the cache is empty.

Are there any solutions to disable new instance creation from a base class between test classes inside a suite? Is this a Spring or TestNG problem?

BR Zoltán

Aucun commentaire:

Enregistrer un commentaire