Professional Documents
Culture Documents
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.
It’s a test case that is possible to automate, could be happy path test, smoke testing, functional
testing, regression testing, sanity testing
Title: Verify that the get endpoint receive the correct data
Pre-conditions:
Steps:
Expected Results:
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.
Title: The endpoint does responds with a 500 status code when an invalid request is sent
Pre-conditions:
Steps:
Expected Results:
class TestWordPressEndpoint(unittest.TestCase):
def setUp(self):
self.base_url = 'https://wordspress.com'
self.post_id = 1
def test_valid_request_returns_data(self):
url = f'{self.base_url}/posts/{self.post_id}'
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
def test_valid_request_returns_data(self):
url = f'{self.base_url}/posts/{self.post_id}'
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}'
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)