Parameterization in TestNG using TestNG XML file

.
Parameterization in TestNG using TestNG XML file

Suite Level Parameterisation 

Inside Suite 

package testNGPackage;


import org.testng.annotations.Parameters;

import org.testng.annotations.Test;


import com.beust.jcommander.Parameter;


public class ParameterizationinTestNG {

@Parameters({"BaseURL"})

@Test

public void testmetnod( String url) {

System.out.println(url);

}



}


XML File



<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="User Login Details">

<parameter name="BaseURL" value="qaacharya.in"></parameter>


<test name="userSignup">

<classes>

<class name="testNGPackage.FirstTestngClass"/>

<class name="testNGPackage.SecondTestngClass"/>

<class name="testNGPackage.ParameterizationinTestNG"/>

</classes>

</test> <!-- Test -->

<test name="Vendorsignup">

<classes>

<class name="testNGPackage.TestNGAnnotaions"/>

<class name="testNGPackage.ThirdTestNGClass"/>

</classes>

</test> <!-- Test -->

</suite> <!-- Suite -->



Test Level Parameterisation 


InSide Test (outside Suite)

 


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="User Login Details">

<parameter name="BaseURL" value="qaacharya.in"></parameter>


<test name="userSignup">

<parameter name="URL" value="qasignup.com"></parameter>

<classes>

<class name="testNGPackage.FirstTestngClass"/>

<class name="testNGPackage.SecondTestngClass"/>

<class name="testNGPackage.ParameterizationinTestNG"/>

</classes>

</test> <!-- Test -->

<test name="Vendorsignup">

<parameter name="URL" value="Vendologin.com.com"></parameter>

<classes>

<class name="testNGPackage.TestNGAnnotaions"/>

<class name="testNGPackage.ThirdTestNGClass"/>

</classes>

</test> <!-- Test -->

</suite> <!-- Suite -->


Class=1


package testNGPackage;


import org.testng.annotations.Parameters;

import org.testng.annotations.Test;


import com.beust.jcommander.Parameter;


public class ParameterizationinTestNG {

@Parameters({"URL"})

@Test

public void testmetnod( String url) {

System.out.println(url);

}



}


Class=2


package testNGPackage;


import org.testng.annotations.Parameters;

import org.testng.annotations.Test;


public class ThirdTestNGClass {

@Parameters({"URL"})

@Test

public void managerlogin(String baseurl) {

System.out.println(baseurl);

}


}

Post a Comment

0 Comments