Challenge - 5 Problems
Maven JUnit Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
JUnit 5 Maven Dependency Output
What will happen if you run a JUnit 5 test with the following Maven dependency setup in your
pom.xml?JUnit
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>Attempts:
2 left
💡 Hint
Check if the dependency includes the correct groupId, artifactId, and version for JUnit 5.
✗ Incorrect
The dependency shown is the correct way to include JUnit 5 API for testing in Maven. The test means it is only used during testing and does not affect the main build. This setup allows tests to run with JUnit 5 features.
❓ assertion
intermediate2:00remaining
Correct Assertion for Maven Dependency Presence
Which assertion correctly verifies that the JUnit 5 dependency is included in the Maven project during a build?
Attempts:
2 left
💡 Hint
Look for an assertion that checks if any dependency has the correct artifactId.
✗ Incorrect
Option C correctly checks if any dependency in the project has the artifactId 'junit-jupiter-api'. Other options either check wrong fields or assert the opposite.
🔧 Debug
advanced2:00remaining
Debugging Missing JUnit 5 Dependency Error
You added the JUnit 5 dependency in your
pom.xml but Maven reports: Cannot find symbol: @Test when running tests. What is the most likely cause?Attempts:
2 left
💡 Hint
Check if the dependency is available during the test phase.
✗ Incorrect
If test is missing, Maven does not include the dependency during test compilation, causing the @Test annotation to be unknown.
🧠 Conceptual
advanced2:00remaining
Understanding Maven Dependency Scopes for Testing
Which Maven dependency scope is best suited for JUnit 5 dependencies and why?
Attempts:
2 left
💡 Hint
Think about when test dependencies are needed in the build lifecycle.
✗ Incorrect
The test means the dependency is only used during the test phase and is not included in the final packaged application. This is ideal for testing libraries like JUnit.
❓ framework
expert3:00remaining
Maven Surefire Plugin Configuration for JUnit 5
Which Maven Surefire plugin configuration snippet correctly enables running JUnit 5 tests?
JUnit
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<!-- Configuration here -->
</plugin>Attempts:
2 left
💡 Hint
JUnit 5 requires the Surefire plugin to use the junit-platform provider.
✗ Incorrect
Option A configures the Surefire plugin to use the junit-platform provider, which is necessary to run JUnit 5 tests. Other options do not enable JUnit 5 support explicitly.