Recall & Review
beginner
What is the purpose of using tags in JUnit tests?
Tags help group tests so you can run specific sets of tests based on their category or purpose, like 'fast' or 'database'.
Click to reveal answer
beginner
How do you tag a test method in JUnit 5?
Use the @Tag annotation above the test method, for example: <br>
@Tag("fast")<br>void testQuick() { ... }Click to reveal answer
intermediate
What is the difference between selecting tests by tags and by classes in JUnit?
Selecting by tags runs tests marked with specific tags anywhere in your code. Selecting by classes runs all tests inside specific test classes.
Click to reveal answer
intermediate
How can you run tests from a specific class using the JUnit Console Launcher?Use the option
--select-class=your.package.YourTestClass to run all tests in that class.Click to reveal answer
advanced
Why is it useful to combine tags and classes when selecting tests?
Combining tags and classes lets you run very specific tests, like only 'slow' tests in a certain class, saving time and focusing on relevant tests.
Click to reveal answer
Which annotation is used to tag tests in JUnit 5?
✗ Incorrect
JUnit 5 uses @Tag to mark tests with tags for selection.
How do you run tests with the tag 'integration' using the JUnit Console Launcher?
✗ Incorrect
The correct option is --include-tag to select tests by tag.
What happens if you select tests by class name in JUnit?
✗ Incorrect
Selecting by class runs all tests inside the specified class.
Can you combine multiple tags when selecting tests in JUnit?
✗ Incorrect
JUnit allows including multiple tags to run tests matching any of them.
Which command runs all tests in the class 'com.example.MyTests'?
✗ Incorrect
The correct syntax is --select-class followed by the full class name.
Explain how you would use tags and classes to run only a subset of tests in a large JUnit project.
Think about grouping tests by purpose and location.
You got /4 concepts.
Describe the benefits of selecting tests by tags compared to selecting by classes.
Consider how tests are organized and run.
You got /4 concepts.