Skip to content

mpkorstanje/junit-platform-suite-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JUnit Platform Suite Demo

Usage:

  • git clone https://github.com/mpkorstanje/junit-platform-suite-demo
  • Run RunSuiteTest in IDEA

Why?

The junit-platform-suite-engine is a test engine that uses the JUnit Platform Launcher to run suites of tests. This can be useful. For example when running Cucumber.

Where previously you would have to create and run the launcher manually:

public class RunCucumberTest {

    public static void main(String[] args) {
        Launcher launcher = LauncherFactory.create();

        LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
                .filters(EngineFilter.includeEngines("cucumber"))
                .selectors(DiscoverySelectors.selectClasspathResource("io/cucumber/skeleton"))
                .configurationParameter(GLUE_PROPERTY_NAME, "io.cucumber.skeleton")
                .build();

        launcher.execute(request);
    }
}

By using annotations the JUnit platform will execute the test for you:

@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("io/cucumber/skeleton")
@Configuration(key = GLUE_PROPERTY_NAME, value = "io.cucumber.skeleton")
public class RunCucumberTest {
}

Suites also work with multiple engines at the same time:

@Suite
@SelectClasses(JupiterTest.class) // This selector is picked up by Jupiter
@SelectClasspathResource("io/cucumber/skeleton") // This selector is picked up by Cucumber
public class RunSuiteTest {

}

About

Demo of junit-platform-suite and cucumber

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published