Skip to content

Feature File: Status Code

Mahmoud A. Zaid edited this page Mar 15, 2019 · 4 revisions

Let's create a feature file and generate our first test case that tests the response status code, the main idea to test the API is defining the endpoint, then create the request, execute the request and finally check the response from the API

you can find the final feature file here

1. Right-Click on Features folder > Add > New Item > SpecFlow Feature File

2. Right-Click on StepDefentions folder > Add > New Item > SpecFlow Step Defention

3. Write the below Gherkin syntax in the feature file

Feature: GetSingleEmployeeApi
	This page will contain information about, how to access particular employee data using rest API/employee.

Scenario: Check Get Single employee status
Given Create Request "employee/{id}" with "GET" method
When Create URL segment for "id" with parameter "7337"
And Execute API
Then returned status code will be "200"

4. Right-Click inside feature file > Generate Step Definitions > Copy Methods to Clipboard

5. StepDefentions Folder > Open StepDefnetion File > in the class Paste the copied methods

Clone this wiki locally