{"id":26897463,"url":"https://github.com/szktty/kiri-check","last_synced_at":"2025-07-08T01:09:47.201Z","repository":{"id":238791500,"uuid":"796370033","full_name":"szktty/kiri-check","owner":"szktty","description":"A testing library for property-based testing in Dart, enabling custom test data generation, testing stateful systems, and integrating seamlessly with package:test.","archived":false,"fork":false,"pushed_at":"2024-09-13T06:23:18.000Z","size":245,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2024-09-13T17:03:13.529Z","etag":null,"topics":["dart","property-based-testing","testing"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/kiri_check","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/szktty.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-05T18:30:42.000Z","updated_at":"2024-09-13T06:23:21.000Z","dependencies_parsed_at":"2024-09-13T15:48:15.770Z","dependency_job_id":null,"html_url":"https://github.com/szktty/kiri-check","commit_stats":null,"previous_names":["szktty/kiri-check"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szktty%2Fkiri-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szktty%2Fkiri-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szktty%2Fkiri-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szktty%2Fkiri-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/szktty","download_url":"https://codeload.github.com/szktty/kiri-check/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246586069,"owners_count":20801026,"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","property-based-testing","testing"],"created_at":"2025-04-01T04:42:35.974Z","updated_at":"2025-07-08T01:09:47.196Z","avatar_url":"https://github.com/szktty.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kiri-check\n\nkiri-check is a property-based testing library for Dart.\n\n## Features\n\n- Integrated with [package:test](https://pub.dev/packages/test), it can be used in the same way as regular tests.\n  Additionally, property-based tests can be added without modifying existing test code.\n- Customization of the exploration method is easy. You can specify data ranges, increase or decrease the number of\n  trials, and prioritize edge cases.\n- Supports stateful testing. You can test the behavior of a system that changes state over time.\n\n## Install\n\nInstall the library from [pub.dev](https://pub.dev/packages/kiri_check) using the following command:\n\nWith Dart:\n\n```shell\ndart pub add dev:kiri_check\n```\n\nWith Flutter:\n\n```shell\nflutter pub add dev:kiri_check\n```\n\nAlternatively, add the library to your `pubspec.yaml` and run `dart pub get` or `flutter pub get`.\n\n```yaml\ndev_dependencies:\n  kiri_check: ^1.3.0\n```\n\n## Documentation\n\nPlease refer to the [Documentation](https://szktty.github.io/kiri-check/).\n\n## Basic usage\n\nProperties can be implemented as tests using `package:test`. Assertions use functions from `package:test`.\n\n1. Import the `kiri-check` library.\n   ```dart\n   import 'package:kiri_check/kiri_check.dart';\n   ```\n2. Implement properties using the `property` function. This function takes the title of the test and the function to\n   execute the test as arguments.\n3. Implement the test to validate test data using the `forAll`\n   function. This function takes an arbitrary that generates random test data as an argument.\n\nExample:\n\n```dart\nimport 'package:kiri_check/kiri_check.dart';\n\ndynamic fizzbuzz(int n) {\n  // Implement me!\n}\n\nvoid main() {\n  property('FizzBuzz', () {\n    forAll(\n      integer(min: 0, max: 100),\n          (n) {\n        final result = fizzbuzz(n);\n        if (n % 15 == 0) {\n          expect(result, 'FizzBuzz');\n        } else if (n % 3 == 0) {\n          expect(result, 'Fizz');\n        } else if (n % 5 == 0) {\n          expect(result, 'Buzz');\n        } else {\n          expect(result, n.toString());\n        }\n      },\n    );\n  });\n}\n```\n\n## Stateful testing\n\nStateful testing allows you to test the behavior of a system that changes state over time.\nThis is particularly useful for testing stateful systems like databases,\nuser interfaces, or any system with a complex state machine.\n\nTo perform stateful testing, in addition to importing `kiri_check/kiri_check.dart`, you need to\nimport `kiri_check/stateful_test.dart`.\n\nExample:\n\n```dart\nimport 'package:kiri_check/kiri_check.dart';\nimport 'package:kiri_check/stateful_test.dart';\n\n// Abstract model representing accurate specifications\n// with concise implementation.\nfinal class CounterModel {\n  int count = 0;\n\n  void reset() {\n    count = 0;\n  }\n\n  void increment() {\n    count++;\n  }\n\n  void decrement() {\n    count--;\n  }\n}\n\n// Real system compared with the behavior of the model.\nfinal class CounterSystem {\n  // Assume that it is operated in JSON object.\n  Map\u003cString, int\u003e data = {'count': 0};\n\n  int get count =\u003e data['count']!;\n\n  set count(int value) {\n    data['count'] = value;\n  }\n\n  void reset() {\n    data['count'] = 0;\n  }\n\n  void increment() {\n    data['count'] = data['count']! + 1;\n  }\n\n  void decrement() {\n    data['count'] = data['count']! - 1;\n  }\n}\n\n// Definition of stateful test content.\nfinal class CounterBehavior extends Behavior\u003cCounterModel, CounterSystem\u003e {\n  @override\n  CounterModel initialState() {\n    return CounterModel();\n  }\n\n  @override\n  CounterSystem createSystem(CounterModel s) {\n    return CounterSystem();\n  }\n\n  @override\n  List\u003cCommand\u003cCounterModel, CounterSystem\u003e\u003e generateCommands(CounterModel s) {\n    return [\n      Action0(\n        'reset',\n        nextState: (s) =\u003e s.reset(),\n        run: (system) {\n          system.reset();\n          return system.count;\n        },\n        postcondition: (s, count) =\u003e count == 0,\n      ),\n      Action0(\n        'increment',\n        nextState: (s) =\u003e s.increment(),\n        run: (system) {\n          system.increment();\n          return system.count;\n        },\n        postcondition: (s, count) =\u003e s.count + 1 == count,\n      ),\n      Action0(\n        'decrement',\n        nextState: (s) =\u003e s.decrement(),\n        run: (system) {\n          system.decrement();\n          return system.count;\n        },\n        postcondition: (s, count) =\u003e s.count - 1 == count,\n      ),\n    ];\n  }\n\n  @override\n  void destroySystem(CounterSystem system) {}\n}\n\nvoid main() {\n  property('counter', () {\n    // Run a stateful test.\n    runBehavior(CounterBehavior());\n  });\n}\n```\n\nFor more detailed information on stateful testing, including advanced usage and customization options, please refer\nto [Stateful Testing](https://szktty.github.io/kiri-check/stateful-testing.html).\n\n## Known issues\n\n- [#13](https://github.com/szktty/kiri-check/issues/13) Test results in IntelliJ IDEA do not reflect `tearDownAll`\n\n## TODO\n\n- Example database\n\n## Author\n\n[SUZUKI Tetsuya](https://github.com/szktty) (tetsuya.suzuki@gmail.com)\n\n## License\n\nApache License, Version 2.0","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszktty%2Fkiri-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fszktty%2Fkiri-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszktty%2Fkiri-check/lists"}