0
0
Testing Fundamentalstesting~10 mins

Why database testing ensures data integrity in Testing Fundamentals - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check if a database record exists.

Testing Fundamentals
record = db.query("SELECT * FROM users WHERE id = [1]")
Drag options to blanks, or click blank then click option'
Aemail
Busername
Cuser_id
Dpassword
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-unique fields like username or email can return multiple records.
2fill in blank
medium

Complete the code to assert that the retrieved data matches expected values.

Testing Fundamentals
assert user_data['email'] == [1]
Drag options to blanks, or click blank then click option'
A'user@example.com'
Bemail
Cuser@example.com
Duser_email
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around string literals in assertions.
3fill in blank
hard

Fix the error in the SQL query to ensure data integrity by checking for null values.

Testing Fundamentals
SELECT * FROM orders WHERE order_date IS [1]
Drag options to blanks, or click blank then click option'
ANULL
BNOT NULL
CEMPTY
DNONE
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'IS NULL' when you want to find records with valid dates.
4fill in blank
hard

Fill both blanks to create a test that verifies the number of records matches the expected count.

Testing Fundamentals
assert len(db.query("SELECT * FROM products WHERE category = '[1]'")) [2] expected_count
Drag options to blanks, or click blank then click option'
Aelectronics
B==
C>=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using comparison operators other than '==' when exact match is needed.
5fill in blank
hard

Fill all three blanks to write a test that filters records and checks a condition on a field.

Testing Fundamentals
results = db.query("SELECT * FROM sales WHERE region = '[1]'")
filtered = [r for r in results if r['amount'] [2] [3]]
assert len(filtered) > 0
Drag options to blanks, or click blank then click option'
Anorth
B>
C1000
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators or numeric values as strings.