Oder of method execution as follows. Running TestSuite BeforeMethod G1 test1() test2() AfterMethod G1
BeforeMethod G2 test1() test2() BeforeMethod G2 Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.593 sec On Thu, Apr 23, 2015 at 11:38 AM, Krishantha Samaraweera < [email protected]> wrote: > Hi Sinthuja, > > As mentioned by Saneth you can use ServerConfigurationManager class to > configure server. > > To execute same set of tests with different configuration you can use > TestNG groups. Please see the example code below. You need to define two > test blocks in testng.xml and execute each group separately. > > > public class MainGroupClass { > > @BeforeTest(groups = {"g1"}, alwaysRun = false) > public void setUpG1() { > //configuration goes here > sleep(); > System.out.println("BeforeMethod G1"); > } > > @AfterTest(groups = {"g1"}, alwaysRun = false) > public void tearDownG1() { > //revert configuration > sleep(); > System.out.println("AfterMethod G1"); > } > > @BeforeTest(groups = {"g2"}, alwaysRun = false) > public void setUpG2() { > //configuration goes here > sleep(); > System.out.println("BeforeMethod G2"); > } > > @AfterTest(groups = {"g2"}, alwaysRun = false) > public void tearDownG2() { > //revert Configuration > sleep(); > System.out.println("BeforeMethod G2"); > } > > private void sleep() { > try { > Thread.sleep(500); > } catch (InterruptedException e) { > e.printStackTrace(); > } > } > > } > > > ======== > > public class BeforeTestGroups { > > @Test(groups = {"g1", "g2"}) > public void test1(){ > sleep(); > System.out.println("test1()"); > } > > @Test(groups = {"g1", "g2"}) > public void test2(){ > sleep(); > System.out.println("test2()"); > } > > private void sleep(){ > try { > Thread.sleep(500); > } catch (InterruptedException ignored) { > > } > } > } > > > =========== > > <suite name="Suite1" verbose="1" > > > <test name="TestG1"> > <groups> > <run> > <include name="g1"/> > </run> > </groups> > > <classes> > <class name="org.wso2.carbon.tests.BeforeTestGroups"/> > <class name="org.wso2.carbon.tests.MainGroupClass"/> > </classes> > </test> > > <test name="TestG2"> > <groups> > <run> > <include name="g2"/> > </run> > </groups> > > <classes> > <class name="org.wso2.carbon.tests.BeforeTestGroups"/> > <class name="org.wso2.carbon.tests.MainGroupClass"/> > </classes> > </test> > > </suite> > > =============== > > > Thanks, > Krishantha. > > > On Thu, Apr 23, 2015 at 8:03 AM, Saneth Dharmakeerthi <[email protected]> > wrote: > >> Hi Sinthuja, >> >> a)You can change the configuration by using >> applyConfigurationWithoutRestart() methods in >> org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager.java. >> For sample usage of ServerConfigurationManager [1] . You have to restart >> the server like in the sample [1] to get the configaration to apply. >> >> b) I am not clear about your 2nd requirement, Do you want to run the same >> test case with 2 different configarations? >> >> [1] >> https://github.com/wso2/product-apim/blob/master/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerConfigurationChangeTest.java >> >> >> Thanks and Best Regards, >> >> Saneth Dharmakeerthi >> Senior Software Engineer >> WSO2, Inc. >> Mobile: +94772325511 >> >> On Wed, Apr 22, 2015 at 7:32 PM, Sinthuja Ragendran <[email protected]> >> wrote: >> >>> Hi QAA team, >>> >>> I have a requirement in DAS integration test to change a configuration >>> file and run the whole integration tests again. >>> >>> Basically in DAS we have a core API which can run in LOCAL mode by using >>> osgi services, and REMOTE mode by connecting to a remote services in a >>> distributed setup. By default this configuration is LOCAL, and hence it >>> just uses the osgi services. But I need to tests the REMOTE functionality >>> as well by changing the configuration to REMOTE and point to localhost. And >>> currently the file is loaded only in the server start up, therefore >>> configuration fi. And I would prefer all the tests to be executed in both >>> modes to make sure functionality. >>> >>> How can I achieve my requirement? Please advice. >>> >>> Thanks, >>> Sinthuja. >>> >>> -- >>> *Sinthuja Rajendran* >>> Senior Software Engineer <http://wso2.com/> >>> WSO2, Inc.:http://wso2.com >>> >>> Blog: http://sinthu-rajan.blogspot.com/ >>> Mobile: +94774273955 >>> >>> >>> >>> _______________________________________________ >>> Dev mailing list >>> [email protected] >>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>> >>> >> > > > -- > Krishantha Samaraweera > Senior Technical Lead - Test Automation > Mobile: +94 77 7759918 > WSO2, Inc.; http://wso2.com/ > lean . enterprise . middlewear. > -- Krishantha Samaraweera Senior Technical Lead - Test Automation Mobile: +94 77 7759918 WSO2, Inc.; http://wso2.com/ lean . enterprise . middlewear.
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
