0
0
JUnittesting~5 mins

Gradle dependency setup in JUnit - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AcompileOnly
BtestImplementation
Cimplementation
DruntimeOnly
How do you specify the JUnit 5 dependency in Gradle?
AtestImplementation 'org.junit.jupiter:junit-jupiter:5.9.3'
Bimplementation 'junit:junit:4.12'
CcompileOnly 'org.junit.jupiter:junit-jupiter:5.9.3'
DruntimeOnly 'org.junit.jupiter:junit-jupiter:5.9.3'
What happens if you omit the version number when adding a dependency in Gradle?
AGradle uses a default version which may cause unexpected issues
BGradle will fail to build the project
CGradle picks the latest version automatically
DGradle ignores the dependency
Which command runs tests in a Gradle project?
A./gradlew clean
B./gradlew build
C./gradlew run
D./gradlew test
Where do you add dependencies in a Gradle project?
AIn the gradle.properties file
BIn the settings.gradle file
CInside the <code>dependencies</code> block in build.gradle
DIn the src folder
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.