What is integration testing in software development?
Integration testing checks if different parts of a program work together correctly. It tests combined modules to find issues in their interaction.
Click to reveal answer
beginner
Why is integration testing important for REST APIs?
It ensures that different API endpoints and services communicate and work together as expected, catching errors that unit tests might miss.
Click to reveal answer
intermediate
Name two common approaches to integration testing.
1. Top-down: Test from the top module downwards. 2. Bottom-up: Test from the bottom modules upwards.
Click to reveal answer
intermediate
What is a stub in integration testing?
A stub is a fake module that simulates the behavior of a called component to help test parts of the system before all components are ready.
Click to reveal answer
beginner
How does integration testing differ from unit testing?
Unit testing checks individual parts alone, while integration testing checks if those parts work well together.
Click to reveal answer
What does integration testing primarily focus on?
ATesting individual functions only
BTesting database performance
CTesting user interface design
DTesting how modules work together
✗ Incorrect
Integration testing checks the interaction between different modules or components.
Which of these is NOT a common integration testing approach?
ATop-down
BBottom-up
CSideways
DBig bang
✗ Incorrect
Sideways is not a recognized integration testing approach.
In REST API testing, integration tests often check:
AThe color scheme of the API docs
BIf endpoints return correct combined data
COnly the database schema
DThe speed of the internet connection
✗ Incorrect
Integration tests verify that API endpoints work together and return correct combined results.
What is a stub used for in integration testing?
ATo simulate a missing module
BTo speed up the internet
CTo test user input validation
DTo style the user interface
✗ Incorrect
A stub simulates a module that is not yet ready to help test other parts.
Which testing type comes after unit testing in the software testing process?
AIntegration testing
BSystem testing
CAcceptance testing
DPerformance testing
✗ Incorrect
Integration testing follows unit testing to check combined parts.
Explain in your own words what integration testing is and why it matters for REST APIs.
Think about how different API parts need to work together smoothly.
You got /3 concepts.
Describe two common approaches to integration testing and when you might use each.
Consider starting tests from the main module or from smaller parts.
You got /3 concepts.
Practice
(1/5)
1. What is the main goal of integration testing in REST API development?
easy
A. To measure the speed of the server hardware
B. To test the user interface design
C. To check if different parts of the application work together correctly
D. To write documentation for the API
Solution
Step 1: Understand integration testing purpose
Integration testing focuses on verifying that multiple components or services interact correctly.
Step 2: Compare options with integration testing goal
Only To check if different parts of the application work together correctly describes checking the cooperation of different parts, which matches integration testing.
Final Answer:
To check if different parts of the application work together correctly -> Option C
Quick Check:
Integration testing = check parts work together [OK]
Hint: Integration tests check connections between parts, not UI or speed [OK]
Common Mistakes:
Confusing integration testing with UI testing
Thinking integration tests measure performance
Believing integration tests are for documentation
2. Which of the following is the correct way to send a GET request in a Python integration test using the requests library?
easy
A. response = requests.get('http://api.example.com/data')
B. response = requests.post('http://api.example.com/data')
C. response = requests.fetch('http://api.example.com/data')
D. response = requests.send('http://api.example.com/data')
Solution
Step 1: Recall correct method for GET request in requests library
The method to send a GET request is requests.get().
Step 2: Check options for correct syntax
Only response = requests.get('http://api.example.com/data') uses requests.get() correctly with a URL string.
Final Answer:
response = requests.get('http://api.example.com/data') -> Option A
Quick Check:
GET request method = requests.get() [OK]
Hint: Use requests.get() for GET requests, not post, fetch, or send [OK]
Common Mistakes:
Using requests.post() instead of get() for GET requests
Using non-existent methods like fetch() or send()
Missing quotes around the URL string
3. Consider this Python integration test snippet using requests:
But the test fails with a KeyError on 'items'. What is the likely cause?
medium
A. The URL is incorrect and returns 404
B. The requests library is not imported
C. The status code is not 200
D. The response JSON does not contain the key 'items'
Solution
Step 1: Understand KeyError cause
A KeyError means the key 'items' is missing in the JSON response.
Step 2: Analyze test failure reason
Since status code is asserted as 200, the URL is likely correct and requests imported. The error is missing 'items' key in JSON.
Final Answer:
The response JSON does not contain the key 'items' -> Option D
Quick Check:
KeyError means missing key in JSON [OK]
Hint: KeyError means JSON key missing, not URL or import error [OK]
Common Mistakes:
Assuming URL is wrong without checking status code
Ignoring that status code 200 means request succeeded
Forgetting to import requests library
5. You want to write an integration test that verifies your REST API endpoint /users returns only active users. The API returns JSON like {"users": [{"id":1,"active":true}, {"id":2,"active":false}]}. Which test code snippet correctly checks this condition?
hard
A. response = requests.get('http://api.example.com/users')
users = response.json()['users']
assert any(user['active'] for user in users)
B. response = requests.get('http://api.example.com/users')
users = response.json()['users']
assert all(user['active'] for user in users)
D. response = requests.get('http://api.example.com/users')
assert response.status_code == 404
Solution
Step 1: Understand requirement to check all users are active
The test must confirm every user in the list has active set to true.
Step 2: Analyze code snippets for correctness
response = requests.get('http://api.example.com/users')
users = response.json()['users']
assert all(user['active'] for user in users) uses all() to check all users are active, which matches requirement. response = requests.get('http://api.example.com/users')
users = response.json()['users']
assert any(user['active'] for user in users) checks if any user is active (not enough). response = requests.get('http://api.example.com/users')
users = response.json()['users']
assert user['active'] == True references undefined variable user outside loop. response = requests.get('http://api.example.com/users')
assert response.status_code == 404 checks for 404 status, which is wrong.
Final Answer:
response = requests.get('http://api.example.com/users')
users = response.json()['users']
assert all(user['active'] for user in users) -> Option B
Quick Check:
Use all() to verify all users active [OK]
Hint: Use all() to confirm every user is active [OK]
Common Mistakes:
Using any() instead of all() to check all users
Referencing undefined variables in assertions
Checking wrong HTTP status code
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.