Choose the best description of what data integrity checks aim to ensure during software testing.
Think about what 'integrity' means in everyday life, like keeping your personal records correct and unchanged.
Data integrity checks focus on making sure data stays correct and consistent throughout its lifecycle, preventing accidental or malicious changes.
Consider this Python code that checks if a list of user IDs contains duplicates. What will it print?
user_ids = [101, 202, 303, 101, 404] unique_ids = set(user_ids) if len(user_ids) == len(unique_ids): print('No duplicates found') else: print('Duplicates detected')
Check if the list has repeated values and how sets handle duplicates.
The list contains the value 101 twice, so the set will have fewer items. The code prints 'Duplicates detected'.
You updated a user's email in the database. Which assertion best confirms the update was successful and data integrity is maintained?
The assertion should confirm the email matches the new value exactly.
Option A checks that the email field equals the new email, confirming the update and data integrity.
Find the bug in this Python code that verifies if all records have a non-empty 'name' field.
records = [{'name': 'Alice'}, {'name': 'Bob'}, {'name': ''}]
for record in records:
assert record['name'], 'Name field is empty!'
print('All records have names')Look for any record with an empty or missing 'name' value.
The third record has an empty string for 'name', so the assertion fails and raises an AssertionError.
When designing automated tests for data integrity, which feature of a test framework is most helpful?
Think about how to ensure tests start with known good data and clean up after themselves.
Fixtures help prepare a stable environment and data for tests, which is crucial for reliable data integrity checks.