What is the main purpose of integration testing in software development?
Think about what happens after individual parts are tested separately.
Integration testing focuses on checking if different parts of the software interact correctly, ensuring combined functionality works as intended.
Given the following integration test code snippet, what will be the output after running the test?
def service_a(): return 5 def service_b(x): return x * 2 result = service_b(service_a()) print(result)
Calculate the output step-by-step: service_a returns a value, then service_b uses it.
service_a returns 5, service_b multiplies input by 2, so 5 * 2 = 10.
Which assertion correctly verifies that two integrated components return the expected combined result?
def component_x(): return 'Hello' def component_y(): return 'World' combined = component_x() + ' ' + component_y()
Check the exact string value stored in combined.
The combined string includes a space between 'Hello' and 'World', so the assertion must match 'Hello World'.
Find the bug in this integration test code that causes the test to fail unexpectedly.
def api_call(): return {'status': 200, 'data': [1, 2, 3]} def process_data(): response = api_call() return response['data'][3] result = process_data()
Check the length of the list and the index accessed.
The list has indices 0,1,2. Accessing index 3 causes an IndexError.
In integration testing, which approach best ensures tests do not affect each other when accessing shared resources like databases?
Think about how to keep tests independent and repeatable.
Using mocks and resetting database state before each test keeps tests isolated and reliable.