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) {

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

时间: 2024-10-07 14:38:26

Data Driven testing - Using parameters in TestNG的相关文章

Spock - Document - 03 - Data Driven Testing

Data Driven Testing Peter Niederwieser, The Spock Framework TeamVersion 1.1 Oftentimes, it is useful to exercise the same test code multiple times, with varying inputs and expected results. Spock's data driven testing support makes this a first class

[转]Table-Driven and Data Driven Programming

What is Table-Driven and Data-Driven Programming? Data/Table-Driven programming is the technique of factoring repetitious programming constructs into data and a transformation pattern. This new data is often referred to by purists as meta-data when u

selenium docs

Note to the Reader - Docs Being Revised for Selenium 2.0! Introduction Test Automation for Web Applications To Automate or Not to Automate? Introducing Selenium Brief History of The Selenium Project Selenium’s Tool Suite Choosing Your Selenium Tool S

Selenium - WebDriver Advanced Usage

Explicit Waits # Python from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0 from selenium.webdriver.support import expected_conditions as EC # avai

Spock - Document -02 - Spock Primer

Spock Primer Peter Niederwieser, The Spock Framework TeamVersion 1.1 This chapter assumes that you have a basic knowledge of Groovy and unit testing. If you are a Java developer but haven't heard about Groovy, don't worry - Groovy will feel very fami

Domain Driven Design and Development In Practice--转载

原文地址:http://www.infoq.com/articles/ddd-in-practice Background Domain Driven Design (DDD) is about mapping business domain concepts into software artifacts. Most of the writings and articles on this topic have been based on Eric Evans' book "Domain Dr

单元测试框架TestNg使用总结

工欲善其事,必先利其器 单元测试的重要性是不言而喻的.但如果没有好的单元测试工具,是无法激起开发人员的欲望. Testng便是利器之一.TestNG是基于Annotation的测试框架的先驱,他拥有通过添加诸如灵活的装置.测试分类.参数测试和依赖方法等特性来克服JUnit3的一些不足之处.下面我将总结一些TestNg的重要特性. 关于testng.xml Testng.xml是以xml记录所有测试的文件.它描述了测试套件的运行时定义,也是testng中运行测试的最大工作单元.虽然没有testng

TestNG官方文档中文版(2)-annotation(转)

1. 介绍    TestNG是一个设计用来简化广泛的测试需求的测试框架,从单元测试(隔离测试一个类)到集成测试(测试由有多个类多个包甚至多个外部框架组成的整个系统,例如运用服务器). 编写一个测试的过程有三个典型步骤: * 编写测试的 业务逻辑并在代码中插入TestNG annotation    * 将测试信息添加到testng.xml文件或者build.xml中    * 运行TestNG 在欢迎页面上可以找到快速入门示例. 下面是这篇文档使用的概念: * suite由xml文件描述.它包

TestNG详解-深度好文

转自: https://blog.csdn.net/lykangjia/article/details/56485295 TestNG详解-深度好文 2017年02月22日 14:51:52 阅读数:8609 1. 介绍    TestNG是一个设计用来简化广泛的测试需求的测试框架,从单元测试(隔离测试一个类)到集成测试(测试由有多个类多个包甚至多个外部框架组成的整个系统,例如运用服务器). 编写一个测试的过程有三个典型步骤: * 编写测试的 业务逻辑并在代码中插入TestNG annotati