omnitest 0.2.2 copy "omnitest: ^0.2.2" to clipboard
omnitest: ^0.2.2 copied to clipboard

outdatedDart 1 only

Black-box testing framework for code that uses the Omnibus.

Omnitest #

Pub Package Build Status Coverage Status

To make testing Omnibus based programs easier, this package implements a function that can evaluate test files that contain a YAML representation of the tests that should be executed. Using this omnitest function you can greatly simplify your testing code.

Test configuration #

An Omnibus testing configuration file looks as follows:

description: >
  General description of the module you are testing and what you are testing.

message-spec:
- test/messages/messages.yaml
- package:messages/messages.yaml

use-cases:
- description: >
    Trigger random message about terminator.
  http-client:
    https-only: true
  messages:
  - package.v1.mTriggerMyEvent:
      subject: terminator
    expect:
    - package.v1.mFinalMessage:
        say: I'll be back!
    - package.v1.mGetRandomMessage:
        subject: terminator
      module-responses:
      - package.v1.mRandomMessage:
          message: I'll be back!

The messages used in this test are described in this omnibuild template:

messages:
- name: mFinalMessage
  type: event
  properties:
  - name: say
    note: Something to say
    type: String
- name: mTriggerMyEvent
  type: event
  properties:
  - name: subject
    note: Subject for a random message
    type: String
- name: mGetRandomMessage
  type: request
  properties:
  - name: subject
    note: The random message subject
    type: String
- name: mRandomMessage
  type: response
  properties:
  - name: message
    note: The random message
    type: String

Test code #

To run this test file, and use it form code coverage reports, you have to include it in your testing code. Omnitest is built to be used along with the test package. The test code with omnitest should look something like this:

library package.test.random_message_module_test;

import 'package:test/test.dart';
import 'package:omnitest/omnitest.dart';

import 'package:package/random_message_module.dart' as random_message_module;

void main() {
  test(
      'Test the random message module',
      omnitest(
          random_message_module.main, 'test/random_message_module_test.yaml'));
}

Enumerations #

To test messages with enumerations you have to put the enumeration indices in the test data. In general this is not preferable since it makes the test data much less readable. A simple way to overcome this issue is to use YAML anchors. A convention for this is included below.

enums:
- MyEnumeration:
  - option1: &MyEnumeration.option1 0
  - option2: &MyEnumeration.option2 1
  - option3: &MyEnumeration.option3 2

use-cases:
- messages:
  - package.v1.mMessageWithEnum:
      option: *MyEnumeration.option1
0
likes
0
points
6
downloads

Publisher

unverified uploader

Weekly Downloads

Black-box testing framework for code that uses the Omnibus.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

ansicolor, collection, http, mustache, omnibuild, omnibus, passive_data, quiver, resource, test, yaml

More

Packages that depend on omnitest