我有一个健身房的模拟个人资料页面,我可以编写测试用例,用小黄瓜语言编辑该个人资料页面。我没有小黄蜂测试用例格式。有人可以帮我这个吗?
答案 0 :(得分:0)
编写小黄瓜测试没有硬性规定。但是,建议您按照建议的程序编写它们,以使其易于理解。小黄瓜的主要目的是为了除了你的团队以外的人,了解整个测试过程。
有三种主要的条件,你必须满足写小黄瓜。
使用预定义语句开始测试,例如Given
Then
和When
。您的功能文件应该包含如下所示的步骤:
Given I land on homepage
When I click on the signup button
Then I see the error
还有其他关键字:
And - Connect more than two steps
有关详细信息,请参阅此文档:
答案 1 :(得分:0)
我认为,这个问题没有范围;但是,我会尽力回答。小黄瓜是一种没有技术障碍的语言。它迫使整个团队根据创造性的协作而不是技术细节来编写明确的基于需求的测试规范。小黄瓜的基本成分已在第一个答案中进行了解释。因此,我宁愿按照问题中的要求给出一个可行的示例,以清楚地了解Given
,When
,Then
的用法。
Feature: Google Book Searching from https://www.googleapis.com/books/v1/volumes?q={ID}
Scenario Outline: Verify that the response status code is 200 and content type is JSON.
Given webService endpoint is up
When user sends a get request to webService endpoint using following details
| ID | <ID> |
Then verify <statusCode> and <contentType> from webService endpoint response
Examples:
| ID | statusCode | contentType |
| 1 | 200 | "application/json; charset=UTF-8" |
| 9546 | 200 | "application/json; charset=UTF-8" |
| 9 | 200 | "application/json; charset=UTF-8" |
// for **Given** - as it has to ensure that the required webservice end-point is up:
@Given("webService endpoint is up")
public void webserviceEndpointIsUp() {
requestSpecification = new RequestSpecBuilder().
setBaseUri(prop.getProperty(BASE_URL)).
build();
}
// for **When** - as this is for the part when user sends the request to the webservice end-point and receives the response
@When("user sends a get request to webService endpoint using following details")
public void userSendsAGetRequestToWebServiceEndpointUsingID(Map<String, String> data) {
String ID = data.get("ID");
System.out.println("The current ID is: " + ID);
String pathParameters = "?q" + "=" + ID;
response = given().
spec(requestSpecification).
when().
get(pathParameters);
}
// for **Then** - finally, here is the then part. When we're verifying the actual stuff mentioned in the Scenario
@Then("verify {int} and {string} from webService endpoint response")
public void verifyResponseStatusCodeAndContentTypeFromWebServiceEndpointResponse(int statusCode, String contentType) {
Assert.assertEquals(statusCode, response.getStatusCode());
Assert.assertEquals(contentType, response.getContentType());
}
这只是用Gherkin编写测试的一个例子,要编写这样的脚本还有很多东西要学习。因此,我建议从以下链接开始: