libasserest_interface 1.0.0 copy "libasserest_interface: ^1.0.0" to clipboard
libasserest_interface: ^1.0.0 copied to clipboard

Interface for implementing asserest's on different protocols.

Standard interface of Asserest execution #

Giving the minimal abstract object for constructing Asserest assertion handlers. Especially for proprietary protocol which prefer to uses with your own implementation or software.

Aims and comparison with existed methods #

Implementations #

This section is for developers who decide to implement from scratch. If you have third-parties implemenataion already, please refer to Execution directly.

To implements assertion with custom protocol, you need to create at least two objects before integrate with Asserest.

Define property

First, prepare a class which implemented with AsserestProperty that to specify properties which going to use.

AsserestProperty provides four default properties already that they must denoted with final keyword instead of a getter.


final class CustomProperty implements AsserestProperty {
  final Uri url;

  final bool accessible;

  final Duration timeout;

  final int? tryCount;

  // Your properties below


final class CustomProperty implements AsserestProperty {
  Uri get url;

  bool get accessible;

  Duration get timeout;

  int? get tryCount;

  // Your properties below

Create parse property processor (Optional)

Once your own property has been completed. If you prefer allowing user to parse assertion information via dart's map, you may need to create a parser which based on PropertyParseProcessor that all prefedined properties will be converted to corresponded type in Dart already along with unmodifiable map contains non-standarded properties.

There are two methods or getters to be overriden: createProperty for parsing map value into actual property object and supportedSchemes - A string set specifies which protocol is supported.

final class CustomPropertyParseProcessor
    extends PropertyParseProcessor<CustomProperty> {
  const CustomPropertyParseProcessor();

  CustomProperty createProperty(
      Uri url,
      Duration timeout,
      bool accessible,
      int? tryCount,
      UnmodifiableMapView<String, dynamic> additionalProperty) {
   // Create CustomProperty in object.

  Set<String> get supportedSchemes => const <String>{"foo"};

Test platform

Then, when the parser is ready to uses, you can work on implementing test form by extending AsserestTestPlatform.

It mainly override runTestProcess, a method corresponded to perform testing and generate assertion result of given URL.

final class CustomTestPlatform extends AsserestTestPlatform<CustomProperty> {
    Future<AsserestResult> runTestProcess() async {
        // Implement tester here

Execution #

When the testers are ready to use, there are few predecessor steps to do before perform assertion.

Attach with managers

Once you have been implemented tester, it must be registered into AsserestTestAssigner in case of applying tester from given tester, especially when performing parallel testing.

Optionally, you can register your own parse processor into AsserestPropertyParser that it will generated corresponded type of property depending on URL scheme.

      (property) => CustomTestPlatform(property as CustomProperty));

If third-parties implementation is planned to be used, please also attach parser and tester as mentioned above unless the developer specified.

Perform testing #

Each testers' property will generated an AsserestReport correspondedly which contains assertion result, expectation of URL access, actual result (denotedwith success, failure and error only) and duration of performing test if enabled counting features.

AsserestParallelTestPlatform is a class which handles multiple test property and prepare to generate tester in AsserestParallelExecutor - a container of testers which execute concurrently that the report will appeared in stream when tester finished it's testing process.

final testPlatform = AsserestParallelTestPlatform();

    // Properties that going to assigned to test.

final executor = testPlatform.buildExecutor(
    // Optional preferences
    name: "Sample test",
    thread: 6, // Default uses single thread
    logger: null

You can either using for-loop or attach StreamSubscription to handle stream, and don't forget call shutdown once the stream is completed:

Using for-loop:

await for (AsserestReport report in executor.invoke()) {
    // Perform the job here.

await executor.shutdown();

Using StreamSubscription:

void reportHandler(AsserestReport report) {
    // Perform the job here.

final Stream<AsserestReport> sr = executor.invoke();
    ..onDone(() async {
        await executor.shutdown();
    ..onError((err) async {
        await executor.shutdown();

License #


pub points



Interface for implementing asserest's on different protocols.

Repository (GitHub)
View/report issues


API reference




async_task, meta, yaml


Packages that depend on libasserest_interface