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.
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
expect-onload:
# When the module is loaded a tracking HTTP request is fired.
- PUT http://tracking.api/random-message-generator
use-cases:
- description: >
Trigger random message about terminator.
http-client:
https-only: true
messages:
# This event should trigger the module to publish a random message.
- package.v1.mTriggerMyEvent:
subject: terminator
expect:
# First the module requests a new random message.
- package.v1.mGetRandomMessage:
subject: terminator
module-responses:
# The module gets a random message from the random message API.
- GET http://generator.api/message/terminator.json
- package.v1.mRandomMessage:
message: I'll be back!
# A random message is now published as a result of the initial trigger.
- package.v1.mFinalMessage:
say: 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
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'));
}
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
Add this to your package's pubspec.yaml file:
dependencies:
omnitest: "^0.2.6+1"
You can install packages from the command line:
with pub:
$ pub get
with Flutter:
$ flutter packages get
Alternatively, your editor might support pub get
or packages get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:omnitest/omnitest.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.2.6+1 | Oct 17, 2016 |
|
|
0.2.6 | May 19, 2016 |
|
|
0.2.5 | May 9, 2016 |
|
|
0.2.4+2 | Apr 28, 2016 |
|
|
0.2.4+1 | Apr 27, 2016 |
|
|
0.2.4 | Apr 27, 2016 |
|
|
0.2.3 | Apr 20, 2016 |
|
|
0.2.2 | Apr 9, 2016 |
|
|
0.2.1 | Apr 7, 2016 |
|
|
0.2.0 | Apr 6, 2016 |
|
|
We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
0 | / 100 |
Health:
Code health derived from static analysis.
[more]
|
98 | / 100 |
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
38 | / 100 |
Overall score:
Weighted score of the above.
[more]
|
37 |
Detected platforms: Flutter, other
Primary library:
package:omnitest/omnitest.dart
with components:io
,isolate
.
Maintain CHANGELOG.md
.
Changelog entries help clients to follow the progress in your code.
Fix analysis and formatting issues.
Analysis or formatting checks reported 1 error 5 hints.
Strong-mode analysis of
lib/src/data/utils.dart
failed with the following error:line: 14 col: 28
The function expression type '(String) → bool' isn't of type '(dynamic) → bool'. This means its parameter or return type does not match what is expected. Consider changing parameter type(s) or the returned type(s).Strong-mode analysis of
lib/data.dart
gave the following hint:line: 7 col: 25
The library 'dart:core' doesn't export a member with the hidden name 'Resource'.Similar analysis of the following files failed:
lib/src/data/raw_messages.dart
(hint)lib/src/test/main.dart
(hint)
The description is too short.
Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.
Package is pre-v1 release.
While there is nothing inherently wrong with versions of
0.*.*
, it usually means that the author is still experimenting with the general direction API.
Maintain an example.
Create a short demo in the
example/
directory to show how to use this package. Common file name patterns include:main.dart
,example.dart
or you could also useomnitest.dart
.
Use analysis_options.yaml
.
Rename old
.analysis_options
file toanalysis_options.yaml
.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=1.14.0 <2.0.0 | ||
ansicolor | ^0.0.9 | 0.0.9 | 0.1.0 |
collection | ^1.5.1 | 1.14.9 | |
http | ^0.11.3+5 | 0.11.3+16 | |
mustache | ^0.2.5 | 0.2.5+1 | 1.0.0 |
omnibuild | ^0.5.2+1 | 0.5.2+2 | |
omnibus | ^0.15.3 | 0.15.3+1 | |
passive_data | ^0.7.1 | 0.7.1+1 | |
quiver | ^0.21.4 | 0.21.4 | 0.29.0+1 |
resource | ^1.1.0 | 1.1.0 | 2.1.2 |
test | ^0.12.7 | 0.12.35 | |
yaml | ^2.1.8 | 2.1.13 | |
Transitive dependencies | |||
analyzer | 0.29.11 | 0.31.1 | |
args | 0.13.7 | 1.4.2 | |
async | 2.0.6 | ||
barback | 0.15.2+15 | ||
boolean_selector | 1.0.3 | ||
charcode | 1.1.1 | ||
cli_util | 0.0.1+2 | 0.1.2+1 | |
convert | 2.0.1 | ||
crypto | 2.0.2+1 | ||
csslib | 0.14.1 | ||
dart_style | 0.2.16 | 1.0.10 | |
glob | 1.1.5 | ||
html | 0.13.3 | ||
http_multi_server | 2.0.4 | ||
http_parser | 3.1.1 | ||
io | 0.3.2+1 | ||
isolate | 1.1.0 | 2.0.0 | |
js | 0.6.1 | ||
logging | 0.11.3+1 | ||
matcher | 0.12.2 | ||
meta | 1.1.2 | ||
mime | 0.9.6 | ||
multi_server_socket | 1.0.1 | ||
node_preamble | 1.4.0 | ||
package_config | 1.0.3 | ||
package_resolver | 1.0.2 | ||
path | 1.5.1 | ||
plugin | 0.2.0+2 | ||
pool | 1.3.4 | ||
pub_semver | 1.3.7 | ||
shelf | 0.7.2 | ||
shelf_packages_handler | 1.0.3 | ||
shelf_static | 0.2.7 | ||
shelf_web_socket | 0.2.2 | ||
source_map_stack_trace | 1.1.4 | ||
source_maps | 0.10.4 | ||
source_span | 1.4.0 | ||
stack_trace | 1.9.2 | ||
stream_channel | 1.6.5 | ||
string_scanner | 1.0.2 | ||
term_glyph | 1.0.0 | ||
typed_data | 1.1.5 | ||
utf | 0.9.0+4 | ||
watcher | 0.9.7+7 | ||
web_socket_channel | 1.0.7 | ||
when | 0.2.0 | ||
which | 0.1.3 |