0
0
JUnittesting~5 mins

Gradle test task in JUnit - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the Gradle test task?
The Gradle test task runs the unit tests in a project, typically using frameworks like JUnit. It compiles the test code and executes tests to check if the code works as expected.
Click to reveal answer
intermediate
How do you run only tests with a specific name pattern using the Gradle test task?
You can configure the test task in build.gradle with filter { includeTestsMatching 'pattern' } to run only tests matching that pattern.
Click to reveal answer
beginner
What file does Gradle use to configure the test task?
Gradle uses the build.gradle file to configure the test task and other build settings.
Click to reveal answer
beginner
How can you generate a test report after running the Gradle test task?
Gradle automatically generates a test report in build/reports/tests/test/index.html after running the test task. You can open this file in a browser to see test results.
Click to reveal answer
intermediate
What is the default testing framework used by Gradle's test task when using JUnit?
Gradle supports JUnit 4 and JUnit 5 by default. You need to add the correct dependencies in build.gradle to use the desired JUnit version.
Click to reveal answer
What command runs the tests in a Gradle project?
Agradle test
Bgradle build
Cgradle run
Dgradle clean
Where does Gradle place the test reports by default?
Areports/tests/index.html
Bsrc/test/reports/index.html
Cbuild/test-results/index.html
Dbuild/reports/tests/test/index.html
How can you include only tests matching a pattern in Gradle?
Afilter { includeTestsMatching 'pattern' }
BincludeTests('pattern')
CtestPattern('pattern')
DonlyTests('pattern')
Which file configures the Gradle test task?
Atest.gradle
Bbuild.gradle
Cgradle.properties
Dsettings.gradle
To use JUnit 5 in Gradle, what must you do?
AUse a special Gradle plugin
BNothing, JUnit 5 is included by default
CAdd JUnit 5 dependencies in build.gradle
DRename test files to end with J5
Explain how the Gradle test task works and how you can customize which tests run.
Think about running tests and filtering them.
You got /4 concepts.
    Describe where Gradle stores test reports and how you can view them.
    Reports are saved as HTML files.
    You got /3 concepts.