0
0
JUnittesting~5 mins

In-memory database testing in JUnit - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AFaster test execution
BMore disk space usage
CSlower queries
DRequires network connection
Which Java in-memory database is commonly used with JUnit?
APostgreSQL
BMySQL
COracle
DH2
How can you ensure tests do not affect each other when using an in-memory database?
AReset the database before each test
BRun tests in parallel
CUse the same database instance for all tests
DIgnore test failures
Which JUnit annotation is used to run code before each test method?
A@Test
B@BeforeEach
C@AfterEach
D@BeforeAll
In-memory databases are best suited for which type of testing?
ALoad testing
BProduction deployment
CUnit testing
DManual testing
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.