Setup a KF Test Suite
A KF test suite can be executed when building a Foundation Library or an Add-On library, and usually extends the tests written for the default library test suite to verify the behavior of this library when its APIs are exposed by a Kernel.
A KF test suite is composed of a set of KF tests, each KF test itself is a minimal Multi-Sandbox Executable composed of a Kernel and zero or more Features.
Enable the Test Suite
In an existing library project:
Create the
src/test/resources/projectsdirectory.Follow the instructions to setup a testsuite on the Simulator.
In the build script file, replace the line:
microej.useMicroejTestEngine(this)
by:
microej.useMicroejTestEngine(this, TestTarget.EMB, TestMode.PROJECT)
Add the
importstatements at the beginning of the file:import com.microej.gradle.plugins.TestMode import com.microej.gradle.plugins.TestTarget
Add the required properties as follows:
val test by getting(JvmTestSuite::class) { microej.useMicroejTestEngine(this, TestTarget.EMB, TestMode.PROJECT) targets { all { testTask.configure { doFirst { systemProperties = mapOf( "microej.testsuite.properties.microejtool.deploy.name" to "deployToolBSPRun", // Configure the TCP/IP address and port if the VEE Port Run script does not redirect execution traces "microej.testsuite.properties.testsuite.trace.ip" to "localhost", "microej.testsuite.properties.testsuite.trace.port" to "5555", // Tell the testsuite engine that the VEE Port Run script redirects execution traces. // Uncomment this line and comment the 2 lines above if the VEE Port supports it. //"microej.testsuite.properties.launch.test.trace.file" to "true" ) } } } } }
Create the
src/test/projectsdirectory,Edit the
module.ivyand insert the following line within the<ea:build>XML element:<ea:plugin organisation="com.is2t.easyant.plugins" module="microej-kf-testsuite" revision="+" />
Configure the option
artifacts.resolverto the name of the resolver used to import KF test dependencies. The name must be one of the resolver names defined in your settings file. If you are using the default settings file, set the option toMicroEJChainResolver. This option is usually set as a global MMM option.
Add a KF Test
A KF test is a structured directory placed in the src/test/resources/projects directory in SDK 6, or in the src/test/projects directory in SDK 5.
The creation of a KF is done as follows:
In the
src/test/resources/projectsdirectory, create a new directorynewTestfor the KF test.In the
src/test/javafolder, create a new Interface with the following content:
import org.junit.Test;
public interface MyTest {
@Test
void newTest();
}
Note
The name of a KF test is free. For each KF test, a method with the same name and annotated with @Test must be defined in the Java Interface.
Within the
newTestdirectory, create the sub-projects:Create a new
kerneldirectory and create a Kernel. The Kernel must depend on your Library project:
implementation("org.example:myLibrary")
Note
The Library project is used as an included build when running one of its KF tests. Therefore, it is not mandatory to specify the dependency version here.
Create a new
appdirectory and create an Application.Create a
settings.gradle.ktsfile and add the following content:
include("kernel", "app")
Each KF test must contain a Kernel project named kernel. If the KF Test also contains one or more Feature projects, their names must be prefixed by app.
The KF Test Suite structure shall be similar to the following figure:
KF Test Suite Overall Structure
Create a new directory for the KF test
Within this directory, create the sub-projects:
Create a new directory for the Kernel project and initialize it using the
microej-javalibskeleton,Create a new directory for the Feature project and initialize it using the
applicationskeleton,Create a new directory for the Firmware project and initialize it using the
firmware-multiappskeleton.
The names of the project directories are free, however MicroEJ suggests the following naming convention, assuming the KF test directory is [TestName]:
[TestName]-kernelfor the Kernel project,[TestName]-app[1..N]for Feature projects,[TestName]-firmwarefor the Firmware project.
The KF Test Suite structure shall be similar to the following figure:
KF Test Suite Overall Structure
All the projects will be built automatically in the right order based on their dependencies.
KF Test Suite Options (SDK 5 only)
It is possible to configure the same options defined by Test Suite Options for the KF test suite,
by using the prefix microej.kf.testsuite.properties instead of microej.testsuite.properties.
