Contains SPI of test module.

Interfaces
ArgumentListProviderSource Codeshared ArgumentListProvider

Represents a contract for annotations, which serves as argument lists provider for parametrized tests. These annotations are used on function and are resolved during execution. Basic implementation is annotation parameters(), but custom implementation can be very easily implemented, see example below.

Example:

shared annotation DataFileAnnotation dataFile(String fileName) => DataFileAnnotation(fileName);

shared final annotation class DataFileAnnotation(String fileName)
         satisfies OptionalAnnotation<DataFileAnnotation,FunctionDeclaration> & ArgumentListProvider {

    shared actual {Anything[]*} argumentLists(ArgumentProviderContext context)
         => CsvFileParser(fileName).parse();         

}

test
dataFile("people.csv")
shared void shouldProcessPerson(String firstname, String surname, Integer age) {
    ...
}
ArgumentListResolverSource Codeshared ArgumentListResolver

Represents a strategy how to resolve argument lists for parameterized test. Its responsibility is discover annotation, which satisfy ArgumentListProvider or ArgumentProvider interface, collect values from them and prepare all possible combination.

ArgumentProviderSource Codeshared ArgumentProvider

Represents a contract for annotations, which serves as arguments provider for parametrized tests. These annotations are used on parameters and are resolved during execution of parameterized tests. Basic implementation is annotation parameters(), but custom implementation can be very easily implemented, see example below.

Example (random annotation is custom implementation of ArgumentProvider, which returns random number for every test):

shared annotation RandomAnnotation random() => RandomAnnotation();

shared final annotation class RandomAnnotation()
         satisfies OptionalAnnotation<RandomAnnotation,FunctionOrValueDeclaration> & ArgumentProvider {

    shared actual {Anything*} arguments(ArgumentProviderContext context)
         => randomGenerator.nextInteger();

}

test
shared void shouldGuessNumber(random Integer num) {
    assert(magician.guessNumber() == num);
}
TestConditionSource Codeshared TestCondition

Represents a contract for annotation, which serves as condition, that has to be fullfiled to execute test, in other case the test execution is TestState.skipped. The ignore() annotation is one simple implementation of this mechanism.

The example below shows bug annotation, which allow to skip test, until the reported issue is resolved.

shared annotation BugAnnotation bug(String id) => BugAnnotation(id);

shared final annotation class BugAnnotation(String id)
         satisfies OptionalAnnotation<BugAnnotation,FunctionDeclaration> & TestCondition {

    shared actual Result evaluate(TestDescription description) {
        // check if the issue is already resolved
    }

} 

test
bug("1205")
shared void shouldTestSomethingButThereIsBug() {
}
TestExecutorSource Codeshared TestExecutor

Represent a strategy how to run test. During test execution notifies test mechanism about significant events via given TestExecutionContext.

Custom implementation can be specify via testExecutor() annotation. It should accept two parameters:

  • the first parameter is own test function, represented like FunctionDeclaration
  • the second parameter is class containg this test function, if exists, represented like ClassDeclaration?
TestExtensionSource Codeshared TestExtension

Represents a marker interface for all test extensions.

TestExtensionResolverSource Codeshared TestExtensionResolver

Represents a strategy how to resolve test extension.

TestInstancePostProcessorSource Codeshared TestInstancePostProcessor

Represents a strategy for post-processing test instances.

TestInstanceProviderSource Codeshared TestInstanceProvider

Represents a strategy for creating new instance of test class.

TestVariantProviderSource Codeshared TestVariantProvider

Represents a strategy that can resolve test variant description by provided arguments, see TestDescription.variant.

Classes
ArgumentProviderContextSource Codeshared ArgumentProviderContext

Represents a context given to ArgumentProvider or ArgumentListProvider when arguments values are collected.

TestExecutionContextSource Codeshared TestExecutionContext

Represents a context in which a test is executed, it's used by TestExecutor.