You are on page 1of 3

Evaluation:

1. What is API Testing?.

API testing focuses on test the functionality of the software based on the comparation of the
results got with the documentation of the software In API testing we test the business logic of
the application. At the end it is important to report what test cases passed and what failed.

2. What is an Automation Test Case?.

It’s a test case that is possible to automate, could be happy path test, smoke testing, functional
testing, regression testing, sanity testing

3. Write a Test Case For a WordPress Endpoint.

Title: Verify that the get endpoint receive the correct data

Pre-conditions:

• A valid WordPress site with the REST API enabled.


• A testing tool or programming language capable of sending HTTP requests.

Steps:

• Send a GET request to the WordPress endpoint.


• Verify that the HTTP response code is 200 (OK).
• Verify that the response data contains the expected data, such as post titles or
categories.
• Verify that the response data is in the expected format, such as JSON or XML.

Expected Results:

• The HTTP response code should be 200 (OK).


• The response data should contain the expected data.

4. For the same endpoint selected. Identify test suites.

Positive:

• Verify that the endpoint returns a valid response when a valid request is sent.
• Verify that the response contains the expected data, such as post titles or categories.
• Verify that the response data is in the expected format, such as JSON or XML.

Negative:

• Verify that the endpoint returns an error message when an invalid request is sent,
such as an incorrect URL or missing parameters.
• Verify that the endpoint returns a 404 error message when a non-existent resource is
requested.
• Verify that the endpoint returns an error message when authentication fails or is
missing.

5. Write a Bug for endpoint selected.

Title: The endpoint does responds with a 500 status code when an invalid request is sent

Pre-conditions:

• A valid WordPress site with the REST API enabled.


• A testing tool or programming language capable of sending HTTP requests.

Steps:

• Send a GET request to the WordPress endpoint with a missing parameter.


• Verify that the HTTP response code is 500.
• Verify that the response data is in the expected format, such as JSON or XML.

Expected Results:

• The HTTP response code should be 400.

6. Write the automated code for the test case.

class TestWordPressEndpoint(unittest.TestCase):

def setUp(self):

self.base_url = 'https://wordspress.com'

self.post_id = 1

self.headers = {'Content-Type': 'application/json'}

def test_valid_request_returns_data(self):

url = f'{self.base_url}/posts/{self.post_id}'

response = requests.get(url, headers=self.headers)

self.assertEqual(response.status_code, 200)

data = response.json()

self.assertEqual(data['id'], self.post_id)

self.assertTrue('title' in data)

self.assertTrue('content' in data)
7. Write a method that Sort a numeric array.

def sort_numeric_array(arr):

arr.sort()

return arr

8. Write 2 assertions, one pass and the other fails

def test_valid_request_returns_data(self):

url = f'{self.base_url}/posts/{self.post_id}'

response = requests.get(url, headers=self.headers)

self.assertEqual(response.status_code, 200)

data = response.json()

self.assertEqual(data['id'], self.post_id)

self.assertTrue('title' in data)

self.assertTrue('content' in data)

def test_valid_request_returns_data(self):

url = f'{self.base_url}/posts/{self.post_id}'

response = requests.get(url, headers=self.headers)

self.assertEqual(response.status_code, 400)

data = response.json()

self.assertEqual(data['id'], self.post_id)

self.assertTrue('title' in data)

self.assertTrue('content' in data)

You might also like