Annotation Interface RequiresTm1Engine
RequiresTm1.
Tests are skipped, not failed, when Docker isn't available or no
Tm1EngineSource is configured, so a build without IBM software stays green. A
source that is configured but wrong fails instead.
One engine serves the whole test JVM (Tm1EngineContainer.shared()), and each
test class gets a database of its own, created when the class first asks for it and
dropped when the class is done. So classes don't see each other's objects. Declare a
Tm1Database parameter on a test method, constructor or lifecycle method to get
it; a Tm1EngineContainer parameter gets the engine.
@RequiresTm1Engine
static class CubeTest {
// A database of this class's own, dropped when the class is done
@Test
void listsCubes(Tm1Database db) throws Exception {
HttpRequest request = db.login()
.authorize(HttpRequest.newBuilder(URI.create(db.getRestUrl() + "Cubes?$select=Name")))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
assertEquals(200, response.statusCode());
}
}
A database takes about 13 seconds to create and 5 to drop. shareDatabase() gives
a class the engine's one shared database instead, at no cost: its tests then need
uniquely named objects, and to delete them afterwards:
// The engine's one shared database instead: nothing to create, but give what you
// make a unique name
@RequiresTm1Engine(shareDatabase = true)
static class ServerNameTest {
@Test
void readsTheServersName(Tm1Database db) throws Exception {
HttpRequest request = db.login()
.authorize(HttpRequest.newBuilder(URI.create(db.getRestUrl() + "Configuration/ServerName/$value")))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
assertEquals(200, response.statusCode());
}
}
"A test class" is the unit each language's test framework shares set-up over: a JUnit class here (with its nested classes), a module in pytest, a class in xUnit, and a file in vitest.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringWhy tests skip when no source is configured, and what to set. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe oldest TM1 the tests apply to, such as12.6; they're skipped on an older engine.booleanWhether the class uses the engine's shared database,tm1, rather than one of its own.
-
Field Details
-
NO_SOURCE_MESSAGE
Why tests skip when no source is configured, and what to set.- See Also:
-
-
Element Details
-
minVersion
String minVersionThe oldest TM1 the tests apply to, such as12.6; they're skipped on an older engine. Checking it starts the engine.- Returns:
- the version, or empty for any
- Default:
""