apiTest<T extends ApiService> method
void
apiTest<T extends ApiService>(})
Wrapper for defining api test bodies.
Wrapping the test body function with this method ensures that the test is run in a service zone which provides access to the ServiceResolver required by the resolve function.
This method additionally provides access to a client connected to the selected ApiService of the host.
Implementation
void apiTest<T extends ApiService>(
String name,
FutureOr<void> Function(RestClient client) body, {
dartTest.Timeout? timeout,
Object? tags,
Map<String, dynamic>? onPlatform,
int? retry,
Object? skip,
String? testOn,
}) {
test(
name,
() async {
final api = resolve<T>();
final client = RestClient.connectHttp2(
Uri(
scheme: 'http',
host: InternetAddress.loopbackIPv4.host,
port: api.port,
path: api.basePath,
),
);
try {
await body(client);
} finally {
await client.close();
}
},
timeout: timeout,
tags: tags,
onPlatform: onPlatform,
retry: retry,
skip: skip,
testOn: testOn,
);
}