as we are upgrading to junit5 from junit4 for unit testing purpose, i couldn't able to find solution to creating a test suite in junit5 like in junit4 : below is the our junit4 suite class :
@RunWith(Suite.class)
@SuiteClasses({ 
    ClassA.class, 
    ClassB.class, 
    ClassC.class 
    } )
public class TestSuite {
}
The Code i tried after searching around is below :
@RunWith(JUnitPlatform.class)
@SelectClasses( { 
    OrderAnnotationAlphanumericExperiment.class, 
    orderAnnotationExperiment.class, 
    ParameterizedAnnotation.class 
    } )
public class TestSuite {
    
}
on searching for the solution, most of them were providing a solution of using the same test suite to run it using vintage api, but what am looking for is to create test suite in junit 5.
Few suggesting @ExtendsWith(SpringExtension.class), but there is also less documentation for it, couldn't able to find a solution to create a suite in junit 5
few blogs/question/sites i referred :
Create TestSuite in JUnit5 (Eclipse) Are test suites considered deprecated in JUnit5? https://howtodoinjava.com/junit5/junit5-test-suites-examples/
some one help me out to solve this problem.
It's actually pretty easy. The following will find all JUnit tests in directory foo.bar.tests as well as it's subdirectories:
import org.junit.platform.runner.JUnitPlatform;
import org.junit.platform.suite.api.SelectPackages;
import org.junit.platform.suite.api.SuiteDisplayName;
import org.junit.runner.RunWith;
@RunWith(JUnitPlatform.class)
@SuiteDisplayName("JUnit Platform Suite Demo")
@SelectPackages("foo.bar.test")
public class FullTestSuite 
}
See Sec 4.4.4 of the User's Guide.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With