minimal_test 0.0.3 copy "minimal_test: ^0.0.3" to clipboard
minimal_test: ^0.0.3 copied to clipboard

discontinued
outdated

Minimalist library for testing Dart VM scripts using null-safety features. Depends only on Dart SDK >=2.9.1.

Minimal Test #

Build Status

A library for writing simple tests. Aimed at testing Dart VM scripts using null-safety features. Has no dependencies other than Dart SDK >= 2.9.0.

For features like test-shuffling, restricting tests to certain platforms, stream-matchers, complex asynchronous tests, it is recommended to use the package test.

Note: In the context of this package, the functions group and test are merely used to organize and label tests and test-groups. Each call to expect is counted as a test. A test run will complete successfully if all expect-tests are passed and none of the test files exits abnormally.

Usage #

The library provides the functions:

  • group: Used to label a group of tests. The argument body, a function returning void or FutureOr<void>, usually contains one or several calls to test.
  • test: The body of this function usually contains one or several calls to expect.
  • setUpAll: A callback that is run before the body of test.
  • tearDownAll: A callback that is run after the body of test has finished.
  • expect: Compares two objects. An expect-test is considered passed if the two objects are equal.
import 'package:minimal_test/minimal_test.dart';

class A {
  A(this.msg);
  final String msg;

  @override
  String toString() {
    return 'A: $msg';
  }
}

late A a1;
late A a1_copy;
late A a2;

void main() {
  setUpAll(() {
    a1 = A('a1');
    a1_copy = a1;
    a2 = A('a2');
  });

  group('Group of tests', () {
    test('First Test', () {
      expect(a1, a1_copy);
    });
    test('Second Test', () {
      expect(a1, a2);
    });
  });
}

The script bin\minimal_test.dart attempts to find test-files specified by the user. If no path is provided, the progam will scan the folder test. It then attempts to run each test-file and generate a report by inspecting the process stdout, stderr, and exit codes.

To run the tests in the test folder, navigate to the package root and use:

$ dart --enable-experiment=non-nullable bin/minimal_test.dart

Limitations #

To keep the library as simple as possible, test files are not parsed and there is no provision to generate and inspect a node-structure of test-groups and tests. As such, shuffling of tests is not supported.

While it is possible to run asynchronous tests, it is recommended to await the completion of the objects being tested before issuing a call to group, test, and expect. Otherwise, the output of expect might not occur on the right line resulting in a confusing test-report. File async_test.dart shows how to test the result of a future calculation.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0
likes
0
points
10
downloads

Publisher

verified publishersimphotonics.com

Weekly Downloads

Minimalist library for testing Dart VM scripts using null-safety features. Depends only on Dart SDK >=2.9.1.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on minimal_test