-2
目前我正在進行放心API測試。我的示例網址是http://eampleUrl/register/device?s=123&m=23ewre&d=123 此處參數s =設備密碼,m是mac地址,d是設備ID。 我想知道如何編寫上面的url中的參數,代碼以及如何使用dataprovider註釋。以及如何檢查斷言命令?放心使用testng
{ 「味精」: 「REG_DEV_01」, 「水平」: 「信息」, 「元」:{}}這是 成功響應
package com.qber.test;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static com.jayway.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.equalTo;
/**
* Created by naveen on 14/12/16.
*/
public class testDemo {
@Test(dataProvider = "circuitLocations")
public void circuitLocationTest(String circuitId, String location) {
given().
pathParameters("circuitId",circuitId).
when().
get("http://ergast.com/api/f1/circuits/{circuitId}.json").
then().
assertThat().
body("MRData.CircuitTable.Circuits[0].Location.country",equalTo(location));
}
@DataProvider(name = "circuitLocations")
public static Object[][] createCircuitTestData() {
return new Object[][] {{"[email protected]", "xtxtxt"}, {"[email protected]", "xtxtxt"}};
}
}
不清楚你在問什麼:如何用'DataProvider'傳遞參數或如何在RA中聲明?請先編輯您的問題並閱讀文檔。 – RocketRaccoon