Data Driven testing - Using parameters in TestNG
Posted amy2012
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Data Driven testing - Using parameters in TestNG相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章
Data Driven testing - Using parameters in TestNG
软件工程 - Test-Driven Development (TDD),测试驱动开发
测试驱动开发(Test-Driven Development)