Complete the code to declare a test suite class using @Suite annotation.
import org.junit.platform.suite.api.Suite; import org.junit.platform.suite.api.SelectClasses; @Suite @SelectClasses({TestClass1.class, TestClass2.class}) public class [1] { }
The class name for the test suite can be any valid Java class name. Here, MyTestSuite is a clear and common choice.
Complete the code to import the correct package for @Suite annotation.
import [1]; @Suite public class MyTestSuite { }
The @Suite annotation is part of the org.junit.platform.suite.api package in JUnit 5.
Fix the error in the test suite declaration by completing the missing annotation.
import org.junit.platform.suite.api.Suite; import org.junit.platform.suite.api.SelectClasses; @Suite [1] public class MyTestSuite { }
The @SelectClasses annotation specifies which test classes to include in the suite.
Fill both blanks to create a test suite that selects all tests in a package.
import org.junit.platform.suite.api.Suite; import org.junit.platform.suite.api.[1]; @Suite @[2]("com.example.tests") public class PackageTestSuite { }
To select all tests in a package, use @SelectPackages annotation.
Fill both blanks to create a suite that selects specific classes and tags.
import org.junit.platform.suite.api.Suite; import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.[1]; @Suite @SelectClasses({TestA.class, TestB.class}) @[2]({"fast", "unit"}) public class TaggedTestSuite { // Suite runs only tests with specified tags // and classes }
The @IncludeTags annotation filters tests by tags. It must be imported and used correctly.