TestNG parameterization application

1. New ParameterDemo04 class

Share pictures< /p>

2. Path to copy class

Share picture

3. Testng.xml configuration class address and parameters

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

<suite name="Suite" parallel="false">
<test name="Test">
<classes >

<class name="cn.xiaobing.testng.ParameterDemo04"/>
classes>

<parameter name="browserType" value="chrome">parameter>
test>
suite>

[email protected](value= {“browserType”})//The variable name is consistent with the xml configuration name

package cn.xiaobing.testng;


import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class ParameterDemo04 {
@Test
@Parameters(value
= {"browserType"})//variable The name is consistent with the xml configuration name
public void test(String bt) {
System.out.println(
"The browser currently used for testing is:"+bt);
}
}

5. Run (step on the pit)

share picture

share picture

The reason for the error: Because of the configuration parameters in testng.xml, to get the browserType parameter, you must run testng.xml

6. Run testng.xml and right click

Share a picture

Share a picture

7. Summary of learning, follow-up supplement of deficiencies!

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

<suite name="Suite" parallel="false">
<test name="Test">
<classes >

<class name="cn.xiaobing.testng.ParameterDemo04"/>
classes>

<parameter name="browserType" value="chrome">parameter>
test>
suite>

package cn.xiaobing.testng;


import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class ParameterDemo04 {
@Test
@Parameters(value
= {"browserType"})//variable The name is consistent with the xml configuration name
public void test(String bt) {
System.out.println(
"The browser currently used for testing is:"+bt);
}
}

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2232 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.