![]() ![]() Table of Contents 1 - Installationģ.5 - Specifying listeners and other settingsįollow the instructions to install the plug-in. It has its own project repository called testng-eclipse. Uses an HTTP request template and a single record housed in a RecordHandler object to * generate and perform an HTTP requests.The TestNG Eclipse plug-in allows you to run your TestNG tests from EclipseĪnd easily monitor their execution and their output. Package .utils import static .given import java.io.BufferedReader import java.io.InputStream import java.io.InputStreamReader import import import .IOUtils import import import .Response import .RequestSpecification /** * Wrapper for RestAssured. 测试方法,由DataProvider提供数据,首先根据ID去取myInputData里的RecordHandler, 由它和template 去生成request, 然后执行request 返回response,这些工作都是由HTTPReqGen.java这个类完成的,借助, 返回的response是一个JSON体,通过 与Baseline中事先填好的期望结果(同样也是JSON格式)进行比较, 根据结果是Pass还是Fail, .rest_api_test import java.io.FileInputStream import java.io.FileNotFoundException import java.io.FileOutputStream import java.io.IOException import java.io.InputStream import import import import import import import import .IOUtils import .usermodel.XSSFSheet import .usermodel.XSSFWorkbook import import import import import import import import import import import import import .utils.DataReader import .utils.DataWriter import .utils.HTTPReqGen import .utils.RecordHandler import .utils.SheetUtils import .utils.Utils import .Response public class HTTPReqGenTest implements ITest TestNG的DataProvider, 首先用DataReader构造函数,读取Excel中Input的数据,放入HashMap, Map的key值就是test case的ID,value是RecordHandler对象,此对象中一个重要的成员属性就是input sheet里面 column和value 的键值对,遍历Map将test case ID 与 test case的value 即input sheet前两列的值放入List ,最后返回List的迭代器iterator (dataProvider = "WorkBookData", description = "ReqGenTest") 读取http_request_template.txt (name = "WorkBookData") 核心就一个测试类HTTPReqGenTest.java 读取Excel (WorkBook) 的 ‘Input’ 和 ‘Baseline’ sheet ![]() ![]() 接口自动化测试 – Java+TestNG 测试 Restful Web Service ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |