0
0
JUnittesting~5 mins

JUnit 4 vs JUnit 5 (Jupiter) differences - Quick Revision & Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
What is the main architectural difference between JUnit 4 and JUnit 5?
JUnit 4 is a single monolithic framework, while JUnit 5 is modular with three sub-projects: Jupiter (new programming model), Vintage (to run JUnit 3 and 4 tests), and Platform (test engine).
Click to reveal answer
beginner
How do you write a test method in JUnit 5 compared to JUnit 4?
In JUnit 4, use @Test from org.junit.Test. In JUnit 5, use @Test from org.junit.jupiter.api.Test. JUnit 5 supports more flexible annotations and method signatures.
Click to reveal answer
beginner
Which annotation replaces @Before and @After in JUnit 5?
JUnit 5 replaces @Before with @BeforeEach and @After with @AfterEach for better clarity on when methods run.
Click to reveal answer
intermediate
What new features does JUnit 5 provide that JUnit 4 lacks?
JUnit 5 supports dynamic tests, nested tests, improved assertions, better extension model, and parameterized tests with more options.
Click to reveal answer
intermediate
Can JUnit 5 run JUnit 4 tests?
Yes, JUnit 5 includes the Vintage engine to run JUnit 3 and 4 tests, allowing gradual migration.
Click to reveal answer
Which JUnit version introduced the @BeforeEach annotation?
AJUnit 5
BJUnit 3
CJUnit 4
DJUnit 6
What is the purpose of the JUnit Vintage engine?
ATo run JUnit 5 tests
BTo run JUnit 3 and 4 tests
CTo run tests in parallel
DTo generate test reports
Which package contains the JUnit 5 @Test annotation?
Aorg.junit.Test
Borg.junit.platform.Test
Corg.junit4.api.Test
Dorg.junit.jupiter.api.Test
Which feature is new in JUnit 5 compared to JUnit 4?
ADynamic tests
BParameterized tests
CTest suites
DAssertions
How does JUnit 5 improve test lifecycle annotations?
ABy using XML configuration
BBy removing them
CBy renaming and adding more specific annotations like @BeforeEach
DBy requiring inheritance
Explain the modular architecture of JUnit 5 and how it differs from JUnit 4.
Think about how JUnit 5 separates concerns into different parts.
You got /4 concepts.
    Describe the key annotation changes from JUnit 4 to JUnit 5 and their benefits.
    Focus on lifecycle and test method annotations.
    You got /4 concepts.