{"id":18521809,"url":"https://github.com/simphotonics/minimal_test","last_synced_at":"2025-05-14T18:09:22.965Z","repository":{"id":56834716,"uuid":"289334528","full_name":"simphotonics/minimal_test","owner":"simphotonics","description":"A minimalist library for writing tests. Aimed at testing Dart scripts with null-safety enabled. Has no dependencies other than Dart SDK \u003e= 2.9.0.","archived":false,"fork":false,"pushed_at":"2021-01-17T21:51:35.000Z","size":341,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-19T18:48:50.751Z","etag":null,"topics":["dart","non-nullable","null-safety","test","test-group","testing"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/minimal_test","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simphotonics.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-21T18:06:45.000Z","updated_at":"2021-01-17T21:51:37.000Z","dependencies_parsed_at":"2022-09-02T03:40:24.853Z","dependency_job_id":null,"html_url":"https://github.com/simphotonics/minimal_test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simphotonics%2Fminimal_test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simphotonics%2Fminimal_test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simphotonics%2Fminimal_test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simphotonics%2Fminimal_test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simphotonics","download_url":"https://codeload.github.com/simphotonics/minimal_test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198510,"owners_count":22030966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","non-nullable","null-safety","test","test-group","testing"],"created_at":"2024-11-06T17:27:42.706Z","updated_at":"2025-05-14T18:09:17.939Z","avatar_url":"https://github.com/simphotonics.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Minimal Test\n[![Build Status](https://travis-ci.com/simphotonics/minimal_test.svg?branch=master)](https://travis-ci.com/simphotonics/minimal_test)\n\n## Introduction\n\nA minimalist library for writing simple tests.\nUsing this package introduces no further dependencies other than Dart SDK \u003e= 2.12.0-0.\nAimed at testing Dart VM scripts using null-safety features.\n\nFor features like test-shuffling, restricting tests to certain platforms, stream-matchers, complex asynchronous tests, it is\nrecommended to use the [official package test].\n\nNote: In the context of this package, the functions [`group`][group] and [`test`][test_function] are merely used to organize and label tests and test-groups.\nEach call to [`expect`][expect] is counted as a test.\nA test run will complete successfully if all *expect-tests* are passed and none of the test files\nexits abnormally.\n\n## Usage\n\n#### 1. Include [`minimal_test`][minimal_test] as a `dev_dependency` in your `pubspec.yaml` file.\n\n#### 2. Write unit tests using the functions:\n * [`group`][group]: Used to label a group of tests. The argument `body`, a function returning `void` or `FutureOr\u003cvoid\u003e`, usually contains\n     one or several calls to `test`.\n * [`test`][test_function]: The body of this function usually contains one or several calls to [`expect`][expect].\n * [`setUpAll`][setUpAll]: A callback that is run before the `body` of [`test`][test_function].\n * [`tearDownAll`][tearDownAll]: A callback that is run after the `body` of [`test`][test_function] has finished.\n * [`expect`][expect]: Compares two objects. An expect-test is considered passed if the two objects match.\n (Matching should be understood as a form of *lax* equality test.\n For example, two lists match if their entries match, however two empty list with different\n runtime types do not match. For more information see [`matcher_test.dart`][matcher_test.dart]).\n\n  \u003cdetails\u003e\u003csummary\u003e Show test file content. \u003c/summary\u003e\n\n  ```Dart\n  import 'package:minimal_test/minimal_test.dart';\n\n  /// Custom object\n  class A {\n    A(this.msg);\n    final String msg;\n\n    @override\n    String toString() {\n      return 'A: $msg';\n    }\n  }\n\n  /// Custom matcher for class A.\n  bool isMatchingA(left, right){\n    if (left is! A || right is! A) return false;\n    return left.msg == right.msg;\n  }\n\n  void main() {\n    final a1 = A('a1');\n    final a1_copy = a1;\n    final a2 = A('a2');\n    final a3 = A('a1');\n\n    group('Group of tests', () {\n      test('Comparing copies', () {\n        expect(a1, a1_copy); // Pass.\n      });\n      test('Comparing different objects', () {\n        expect(a1, a2, 'Expected to fail.'); // Fail.\n      });\n      test('Using custom matcher function', () {\n        expect(a1, a3, isMatching: isMatching); // Pass.\n      });\n\n    });\n  }\n  ```\n  \u003c/details\u003e\n\n  \u003cdetails\u003e \u003csummary\u003e Show console output (test report). \u003c/summary\u003e\n\n  ![Console Output](https://raw.githubusercontent.com/simphotonics/minimal_test/master/images/console_output.svg?sanitize=true)\n\n  \u003c/details\u003e\n\n\n\n#### 3. Run the tests in the package `test` folder by navigating to the package root and issuing the command:\n\n```Console\n$ pub run minimal_test:minimal_test.dart\n```\nAlternatively, the path to a test file or test directory may be specified:\n```Console\n$ pub run minimal_test:minimal_test.dart example/bin/example_test.dart\n```\n\n## Features\n\n* The function `expect()` has the optional parameter `precision` enabling approximate\nmatching of objects of type `num`. The default value of `precision` is `1.0e-12`.\n ```Dart\n   // Returns true.\n   match(1, 0.999999999999);\n   // Test passed.\n   expect(1, 0.999999999999);\n\n   // Returns false.\n   match(1.0, 0.9999);\n   // Test failed.\n   expect(1.0, 0.9999);\n\n   // Returns true.\n   match(1.0. 0.9999, precision: 1e-3);\n   // Test passed.\n   expect(1.0, 0.9999, precision: 1e-3);\n\n ```\n\n * Iterables and maps are matched in a recursive fashion. The types of the two objects have to match. For example\n   a `Set` does not match a `List` even if they have identical entries.\n\n  ```Dart\n    // Test passed.\n    expect([1.0, 2.0, 3.0], [1.0 - 1.0e-14, 2.0, 3.0]);\n\n    // Test failed\n    expect(\u003cint\u003e[1, 2], \u003cdouble\u003e[1.0, 2.0])\n\n    // Test passed.\n    expect({ 1: [10, 11], 2: [12, 13]},\n           { 1: [10, 11], 2: [12, 13]},\n          );\n  ```\n\n## Limitations\n\nTo keep the library as simple as possible, test files are not parsed\nand there is no provision to generate and inspect a node-structure of\ntest-groups and tests. As such, shuffling of tests is currently not supported.\n\nWhile it is possible to run **asynchronous** tests, it is recommended\nto await the completion of the objects being tested before issuing a call to\n[`group`][group], [`test`][test_function], and [`expect`][expect].\nOtherwise, the output printed by the method [`expect`][expect] might not\noccur on the right line making it difficult to read the test output.\nHowever, the total number of failed/passed tests\nis reported correctly.\n\nFile [`async_test.dart`][async_test.dart] shows how to test\nthe result of a future calculation.\n\n\n## Features and bugs\n\nPlease file feature requests and bugs at the [issue tracker][tracker].\n\n[tracker]: https://github.com/simphotonics/minimal_test/issues\n\n[official package test]: https://pub.dev/packages/test\n\n[async_test.dart]: https://github.com/simphotonics/minimal_test/blob/master/example/async_test.dart\n\n[expect]: https://pub.dev/documentation/minimal_test/doc/api/minimal_test/group.html\n\n[group]: https://pub.dev/documentation/minimal_test/doc/api/minimal_test/group.html\n\n[matcher_test.dart]: https://github.com/simphotonics/minimal_test/blob/master/test/matcher_test.dart\n\n[minimal_test]: https://pub.dev/packages/minimal_test\n\n[setUpAll]: https://pub.dev/documentation/minimal_test/doc/api/minimal_test/setUpAll.html\n\n[test_function]: https://pub.dev/documentation/minimal_test/doc/api/minimal_test/test.html\n\n[tearDownAll]: https://pub.dev/documentation/minimal_test/doc/api/minimal_test/tearDownAll.html","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimphotonics%2Fminimal_test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimphotonics%2Fminimal_test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimphotonics%2Fminimal_test/lists"}