Testing
The binary-array-ld-test
module contains various utilities which assist with testing the BALD conversion process.
It contains a testing framework which lets you quickly test an implementation
against the requirements in the BALD specification.
Specification
The requirements that comprise the specification are represented by a YAML resource in the
binary-array-ld-test
module.
The YAML file is located at src/main/resources/spec/spec.yaml.
The root object is a spec definition containing a set of requirement definitions. The object structure is described below.
Spec Definition
The spec definition represents the whole specification. Its main purpose is to be a container for the set of requirements.
Property | Definition |
---|---|
tests | The list of requirement definitions. |
Requirement Definition
The requirement definition represents a single requirement in the specification. Each requirement will generate a single JUnit test, although each test may check multiple aspects of the implementation.
Property | Definition |
---|---|
name | The name of the requirement. |
comment | A description of the requirement (optional). |
root | The root path which the input and output resource paths should be resolved against (optional). |
input | A nested object containing the input definition. |
output | The path to the resource containing the expected RDF output. |
Input Definition
The input definition represents the set of parameters to supply to the converter implementation.
Property | Definition |
---|---|
file | The path to the NetCDF binary array resource to convert. |
uri | The URI of the binary array, if it has one (optional). |
alias | The path, or list of paths, to resources containing alias definitions (optional). |
context | The path, or list of paths, to resources containing JSON-LD contexts (optional). |
Test an Implementation
To test a new converter implementation, simply define a test class which extends BaseSpecTest
.
The new class must implement the abstract field converter
of type Converter
(this represents the implementation you want to test).
Your test class will inherit the tests that are automatically generated by BaseSpecTest
,
so you can run it immediately without writing any additional test code.
See below, or BinaryArrayConvertSpecTest
in the binary-array-ld-cli
module for examples.
Example
class MySpecTest: BaseSpecTest() {
override val converter: Converter = MyTestConverter()
}
class MyTestConverter(): Converter {
override fun convert(
input: URI,
uri: String?,
contexts: List<URI>?,
aliases: List<URI>?,
downloadUrl: String?
): Model {
TODO("My implementation here")
}
}