码迷,mamicode.com
首页 > 其他好文 > 详细

Data Driven testing - Using parameters in TestNG

时间:2019-10-05 10:21:18      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:rem   aes   stat   ota   ase   user   first   java   level   

e.g. for the login case,  originally it‘s hard coded in the script. now using parameters in TestNG.xml

//private static String username = "user01;
//private static String password = "password";

This is a test level parameter:

step 1: add parameter in testng.xml

<suite name="Suite">
<test name="firstTest">
<parameter name="username" value="user01" />
<parameter name="password" value="password" />

step2:  add @Parameter annotation in the caes and pass paremeter to the method

@Parameters({ "username", "password" })
public void firstTest(String username, String password) {

SecurePage securepage = LoginPage.logIn(username, password);

step3: change the method invoked from other class, uncomment the hard coded lines, e.g code in LoginPage.java

public static SecurePage logIn(String username, String password) {

 

Data Driven testing - Using parameters in TestNG

标签:rem   aes   stat   ota   ase   user   first   java   level   

原文地址:https://www.cnblogs.com/amy2012/p/11623922.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!