Recall & Review
beginner
What is the purpose of adding dependencies in a Gradle build file?
Dependencies tell Gradle which external libraries or tools your project needs to work correctly. They are like ingredients in a recipe that your project requires to run or test.
Click to reveal answer
beginner
How do you add JUnit 5 as a test dependency in a Gradle project?
You add the JUnit 5 dependency inside the
dependencies block in your build.gradle file like this:<br>testImplementation 'org.junit.jupiter:junit-jupiter:5.9.3'
Click to reveal answer
beginner
What does the
testImplementation configuration mean in Gradle?It means the dependency is only needed when running tests. It won't be included in the final app or production code, just during testing.
Click to reveal answer
beginner
Why is it important to specify the version number when adding a dependency?
Specifying the version ensures your project uses a known, stable version of the library. Without it, Gradle might pick an unexpected version, causing errors or inconsistent behavior.
Click to reveal answer
beginner
What Gradle task do you run to execute tests after setting up JUnit dependency?
You run
./gradlew test in your terminal. This runs all tests using the dependencies you set up, like JUnit.Click to reveal answer
Which Gradle configuration is used to add dependencies needed only for testing?
✗ Incorrect
The
testImplementation configuration is specifically for dependencies used only during testing.How do you specify the JUnit 5 dependency in Gradle?
✗ Incorrect
JUnit 5 is added with
testImplementation and the correct group and version.What happens if you omit the version number when adding a dependency in Gradle?
✗ Incorrect
Without a version, Gradle may use a default or unexpected version, leading to inconsistent builds.
Which command runs tests in a Gradle project?
✗ Incorrect
The
test task runs all tests using the configured test dependencies.Where do you add dependencies in a Gradle project?
✗ Incorrect
Dependencies are declared inside the
dependencies block in the build.gradle file.Explain how to add JUnit 5 as a test dependency in a Gradle project and why it is important.
Think about the build.gradle file and the role of test dependencies.
You got /4 concepts.
Describe the difference between implementation and testImplementation in Gradle dependencies.
Consider when each dependency is needed during the project lifecycle.
You got /4 concepts.