mardi 31 mars 2015

TestNG not waiting till my Spring session initialised

I have some sort of following code and if I run it with single test tag xml it works fine. But, when I have multiple tests suites it's simply skips all tests and run last one.


I know that to init Spring takes much time , but how could I wait till my session get init in @BeforeSuite(alwaysRun=true) ?


Note :- Thread.sleep(); also not my solution :(



@BeforeSuite(alwaysRun=true)
public void contextSetup() throws Exception {
start = new Date();
spContext = createContext();
importStandardConfiguration(spContext);
}

@BeforeTest(alwaysRun=true)
@Parameters({"testConfigFile"})
public void testContextSetUp(String fileName) throws Exception{
loadTestContext(fileName);
_skippedTests = new ArrayList<String>();
}

@AfterTest
public void releaseContext() throws GeneralException{
testContext = null;
universalMap.clear();
}

@AfterSuite
public void releaseSpContext() throws GeneralException{
if(spContext!=null)SPFactory.releaseContext(spContext);
throw new GeneralException("Encountered leaked Context");
}

@Test(dataProvider="DataFile")
public void testConnectorImplementation(Map parameter) throws Exception { }


And my TestNG file look like this



<!DOCTYPE suite SYSTEM "http://ift.tt/1ue4P4h" >
<suite name="My Tests Suite" verbose="0">

<test name="First Test">
<parameter name="testConfigFile"
value="config/MyFirstTestConfig.xml" />
<classes>
<class name="com.testframework.ConnectorTests">
</class>
</classes>
</test>

<test name="Second Test">
<parameter name="testConfigFile"
value="config/MySecondTestConfig.xml" />
<classes>
<class name="com.testframework.ConnectorTests">
</class>
</classes>
</test>
</suite>

Aucun commentaire:

Enregistrer un commentaire