The ecFeed runner uses the JUnit5 testing framework, which is required to run tests. All function are controlled by annotations, described in detail in the following chapter. They are a part of the ecfeed.core library, which must be included in the classpath.
Although the ecFeed service was designed for Java, it might be used with other software (examples are described in a different tutorial).
Annotations that must be used to control the ecFeed testing process.
The most important annotation that must be used with every test method.
@EcFeedTest
void ecFeedTest(int arg1, String arg2) {
System.out.println("arg1 = [" + arg1 + "], arg2 = [" + arg2 + "]");
}
The annotation can be used with classes (also nested) and/or methods. Note, that the method-level annotation takes precedence over the class-level annotation.
To use the web-generator, its value should reflect the ID of the model, e.g.:
@EcFeedTest
@EcFeedModel("XXXX-XXXX-XXXX-XXXX-XXXX")
void ecFeedTest(int arg1, String arg2) {
System.out.println("arg1 = [" + arg1 + "], arg2 = [" + arg2 + "]");
}
To use the service locally, the @EcFeedModel annotation should provide the path to the exported ECT model:
@EcFeedTest
@EcFeedModel("resources/model.ect")
void ecFeedTest(int arg1, String arg2) {
System.out.println("arg1 = [" + arg1 + "], arg2 = [" + arg2 + "]");
}
Alternatively, to use the embedded generator, the @EcFeedModel annotation should not be used:
@EcFeedTest
void ecFeedTest(int arg1, String arg2) {
System.out.println("arg1 = [" + arg1 + "], arg2 = [" + arg2 + "]");
}
In the last case, default values for each type are as follows:
The annotation should be used when a local server, i.e. different than ecfeed.com, is preferred. It can be used with (nested) classes and/or methods.
@EcFeedTest
@EcFeedService("https://test-gen.ecfeed.com")
void ecFeedTest(int arg1, String arg2) {
System.out.println("arg1 = [" + arg1 + "], arg2 = [" + arg2 + "]");
}
The annotation, which provides the path to the downloaded keystore, is optional. It can be used with (nested) classes and/or methods.
@EcFeedTest
@EcFeedKeyStore("resources/security")
void ecFeedTest(int arg1, String arg2) {
System.out.println("arg1 = [" + arg1 + "], arg2 = [" + arg2 + "]");
}
If the @EcFeedKeyStore annotation is not present, the algorithm searches for the keystore in the following locations (in that order):
The annotation provides additional generation parameters. It is optional, and can be used with (nested) classes and/or methods. Its value resembles the JSON format, however, double quotes should be replaced with single quotes.
@EcFeedTest
@EcFeedInput("'dataSource':'genRandom', 'properties':{'length':'10', 'duplicates':'true'}")
void ecFeedTest(int arg1, String arg2) {
System.out.println("arg1 = [" + arg1 + "], arg2 = [" + arg2 + "]");
}
All parameters are separated by commas. Possible values are as follows:
If the @EcFeedInput annotation is missing, the following value is used as default: 'dataSource':'genCartesian'.
Note, that if you decide to use this annotation, all required parameters must be present. If one of them is missing, e.g. 'duplicates', the random generator will not have enough information to be initialized and an exception will be thrown. There are no default values for absent parameters.
This a meta, class-level annotation. It is optional, and can be used to group other annotations. It consists of four fields:
Note, that the default parameter, i.e. value, can be omitted, e,g,:
@EcFeed("XXXX-XXXX-XXXX-XXXX-XXXX")
public class EcFeedModelTest { ... }