Recall & Review
beginner
What is an in-memory database in testing?
An in-memory database stores data in the computer's RAM instead of on disk. It is fast and used in tests to simulate real databases without slow disk access.
Click to reveal answer
beginner
Why use in-memory databases for unit tests?
They make tests faster and isolated by avoiding real database setup. This helps tests run quickly and reliably without external dependencies.
Click to reveal answer
beginner
Name a popular in-memory database used in Java JUnit tests.
H2 database is popular for Java JUnit tests because it supports SQL and runs fully in memory.
Click to reveal answer
intermediate
How do you ensure data isolation between tests using an in-memory database?
By resetting or recreating the in-memory database before each test, so tests do not share data and remain independent.
Click to reveal answer
beginner
What is a common JUnit annotation to run setup code before each test?
The @BeforeEach annotation runs setup code before every test method to prepare the test environment.
Click to reveal answer
What is the main advantage of using an in-memory database in tests?
✗ Incorrect
In-memory databases store data in RAM, making queries much faster and speeding up tests.
Which Java in-memory database is commonly used with JUnit?
✗ Incorrect
H2 is a lightweight in-memory database often used in Java tests.
How can you ensure tests do not affect each other when using an in-memory database?
✗ Incorrect
Resetting the database before each test keeps tests independent and data isolated.
Which JUnit annotation is used to run code before each test method?
✗ Incorrect
@BeforeEach runs setup code before every test method.
In-memory databases are best suited for which type of testing?
✗ Incorrect
In-memory databases are ideal for unit tests because they are fast and isolated.
Explain how to set up an in-memory database for JUnit tests and why it is useful.
Think about test speed and independence.
You got /4 concepts.
Describe how in-memory database testing helps maintain test isolation and reliability.
Focus on data isolation and test independence.
You got /4 concepts.