Recall & Review
beginner
What is the purpose of using @Suite in JUnit?
The @Suite annotation groups multiple test classes to run them together as one test suite, making it easier to organize and execute related tests.
Click to reveal answer
beginner
How do you specify which test classes belong to a test suite using @Suite?
You use the @Suite.SuiteClasses annotation with an array of test class names inside the test suite class.Click to reveal answer
beginner
Write a simple example of a JUnit test suite using @Suite.
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({TestClass1.class, TestClass2.class})
public class MyTestSuite {
}
This runs TestClass1 and TestClass2 together.Click to reveal answer
beginner
What annotation must be used on a class to make it a test suite in JUnit?The class must be annotated with @RunWith(Suite.class) to tell JUnit to run it as a suite.Click to reveal answer
beginner
Can a test suite class contain test methods?No, a test suite class only groups other test classes and does not contain test methods itself.Click to reveal answer
Which annotation is used to specify the classes included in a JUnit test suite?
✗ Incorrect
The @Suite.SuiteClasses annotation lists the test classes to include in the suite.
What annotation must be placed on a class to run it as a JUnit test suite?
✗ Incorrect
The @RunWith(Suite.class) annotation tells JUnit to run the class as a test suite.
Can a JUnit test suite class contain test methods?
✗ Incorrect
A test suite class only groups other test classes and does not contain test methods.
What is the main benefit of using a test suite with @Suite in JUnit?
✗ Incorrect
Test suites help run multiple test classes together in one go.
Which import is necessary to use @Suite in JUnit 4?
✗ Incorrect
The correct import for @Suite is org.junit.runners.Suite.
Explain how to create a test suite in JUnit using @Suite and what annotations are required.
Think about how you tell JUnit to run multiple classes together.
You got /3 concepts.
Describe the benefits of grouping tests into a suite with @Suite in JUnit.
Consider how running tests together helps in real projects.
You got /3 concepts.