7.0+28.5
JUnit 5 Jupiter

In chapter 12 we described how to integrate JUnit tests into a QF-Test test suite, which creates a common run log combining the results from the unit tests with those from the other QF-Test test cases. With the help of the Java annotation @QFTest.Test it is possible to go the opposite way and include QF-Test test suites into a Junit 5 test case, integrating the results from the QF-Test test run into the JUnit test results. This simplifies the inclusion of QF-Test test runs into Maven or Gradle builds, as well as software development environments like Eclipse or IntelliJ IDEA.

To do so, extend the test class, which should include the execution of one or several QF-Test test suites, with a method annotated with de.qfs.apps.qftest.junit5.QFTest.Test. The method must return an object of the type de.qfs.apps.qftest.junit5.QFTest, which is created using the static method QFTest.runSuite(...) or QFTest.runSuites(...). If required, this object can be further configured e.g. to include QF-Test options or variables. The provided methods are documented in the file doc/javadoc/qftest-junit5.zip inside the QF-Test installation.

import de.qfs.apps.qftest.junit5.QFTest;
import java.io.File;

public class QFTestDemoTest
{
  @QFTest.Test
  QFTest demoTest() throws Exception {
    // Get location of demo testsuite
    final File qftestVerdir = QFTest.getVersionDir();
    final File demo = new File(qftestVerdir,
            "demo/carconfigSwing/carconfigSwing_en.qft");

    return QFTest.runSuite(demo)
                 .withVariable("buggyMode","True")
                 .withArgument("-verbose")
                 .withReportOpen();
  }
}
        
Example 28.3:  Example of a JUnit 5 test case including a QF-Test test suite.

To execute the test it is required to include the following libraries from the QF-Test installation into the classpath:

  • lib/truezip.jar
  • qflib/qflib.jar
  • qflib/qfshared.jar
  • qflib/qftest.jar
If the project is based on Gradle build, you can apply the de.qfs.qftest gradle plugin to automatically resolve those dependencies. For more information, refer to the plugin homepage.

plugins {
    id 'java'
    id 'de.qfs.qftest' version '1.1.0'
}

repositories {
    mavenCentral()
}

test {
    useJUnitPlatform()
}
        
Example 28.4:  Excerpt from a gradle.build file, which calls QF-Test during the JUnit test run.