Running test suites in parallel with different setup data

I’m working on a Maven project to develop the mobile test automation and I would like to run two test suites in parallel. So, using the TestNG running the test from the .xml file, it looks like this:

<suite name="Parallel Test" parallel="tests" thread-count="2">
    <test name="TestsAndroid 7">
        <parameter name="platform" value="Android 7.0" />
        <parameter name="deviceName" value="emulator-5554"/>
        <parameter name="port" value="4731"/>
            <class name="Runner.Test1" />
    <test name="TestsAndroid 8">
        <parameter name="platform" value="Android 8" />
        <parameter name="deviceName" value="emulator-5556"/>
        <parameter name="port" value="4733"/>
            <class name="Runner.Test2" />

Each runner, Test1 and Test2, has a @BeforeClass where the setup data is created, specifically for each test suite:

 @BeforeClass(alwaysRun = true)
 @Parameters({"platform", "deviceName", "port"})
  public void setUpClass(@Optional("") String platform, String deviceName, String port) throws Exception {
      setupData = new CreateSetupData("Test1");

And here is where my problem become. The CreateSetupData() method creates the required data and set the variable values in order to be used in further test steps.

private void CreateSetupData() {
    // Create user
    String userName = createUser();


public static void setUserName(String aUser) {
    userName = aUser;

When it starts creating data to run the Test2 overwritten the user and password values created for Test1.

I’m using Eclipse IDE, is it possible to create and set the data with same variable names but with different values for each thread-count ?

Leave a Reply

Notify of