diff --git a/README.md b/README.md index 9e0a6d1..e2ab016 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ TestReporter create() { } ``` -2. Run test_reporter command with your tests +3. Run test_reporter command with your tests ```bash dart run test_reporter -- dart test diff --git a/packages/test_reporter/CHANGELOG.md b/packages/test_reporter/CHANGELOG.md index 43ab922..078790b 100644 --- a/packages/test_reporter/CHANGELOG.md +++ b/packages/test_reporter/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.5 + +- **docs:** add example + ## 1.1.4 - **docs:** update README diff --git a/packages/test_reporter/README.md b/packages/test_reporter/README.md index a49e451..7a2e239 100644 --- a/packages/test_reporter/README.md +++ b/packages/test_reporter/README.md @@ -48,7 +48,7 @@ TestReporter create() { } ``` -2. Run test_reporter command with your tests +3. Run test_reporter command with your tests ```bash dart run test_reporter -- dart test diff --git a/packages/test_reporter/example/README.md b/packages/test_reporter/example/README.md new file mode 100644 index 0000000..6959ff8 --- /dev/null +++ b/packages/test_reporter/example/README.md @@ -0,0 +1,40 @@ +# Test Reporter - Usage example + +## Example with Allure Report Adapter + +1. Add `allure_report` and `test_reporter` to your dependencies. + +```yaml +dev_dependencies: + # reporter + allure_report: ^1.0.0 + test_reporter: ^1.0.0 +``` + + +2. Create `reporter.dart` in `test` directory. If no file created, **Basic Console Reporter** will be used. + +```dart +import 'package:allure_report/allure_report.dart'; +import 'package:test_reporter/test_reporter.dart'; + +TestReporter create() { + return AllureReporter(); +} +``` + +3. Run test_reporter command with your tests + +```bash +dart run test_reporter -- dart test +``` + +```bash +dart run test_reporter -- flutter test +``` + +### Output + +Allure results are placed in `allure-results` folder in project root folder. + +Proceed to [Allure / How to view a report](https://allurereport.org/docs/gettingstarted-view-report/#start-a-local-web-server) diff --git a/packages/test_reporter/lib/basic_reporter.dart b/packages/test_reporter/lib/basic_reporter.dart index 4a36ee0..832bb0e 100644 --- a/packages/test_reporter/lib/basic_reporter.dart +++ b/packages/test_reporter/lib/basic_reporter.dart @@ -1,6 +1,7 @@ import 'package:test_reporter/src/reporter/basic_reporter.dart'; import 'package:test_reporter/test_reporter.dart'; +/// Entrypoint to create test reporter when `--reporter` arg used. TestReporter createReporter(List args) { return BasicReporter(); } diff --git a/packages/test_reporter/lib/src/reporter/basic_reporter.dart b/packages/test_reporter/lib/src/reporter/basic_reporter.dart index 1f93d63..30f71e6 100644 --- a/packages/test_reporter/lib/src/reporter/basic_reporter.dart +++ b/packages/test_reporter/lib/src/reporter/basic_reporter.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:test_reporter/test_reporter.dart'; +/// Basic test reporter. Redirects test events from test process to stdout. class BasicReporter implements TestReporter { const BasicReporter(); diff --git a/packages/test_reporter/lib/src/reporter/test_reporter.dart b/packages/test_reporter/lib/src/reporter/test_reporter.dart index 7b59154..16b02ac 100644 --- a/packages/test_reporter/lib/src/reporter/test_reporter.dart +++ b/packages/test_reporter/lib/src/reporter/test_reporter.dart @@ -1,7 +1,12 @@ import 'dart:async'; import 'package:test_reporter/src/model/models.dart'; +import 'package:test_reporter/src/reporter/basic_reporter.dart'; +/// Special reporter class to implement test report formats. +/// +/// See [BasicReporter] for example or [AllureReporter] from `allure_report` package. abstract interface class TestReporter { + /// This method will be called for every test event from `dart test`/`flutter test` process. FutureOr onEvent(TestEvent event); } diff --git a/packages/test_reporter/pubspec.yaml b/packages/test_reporter/pubspec.yaml index 2dd7f09..4b34c07 100644 --- a/packages/test_reporter/pubspec.yaml +++ b/packages/test_reporter/pubspec.yaml @@ -1,6 +1,6 @@ name: test_reporter -description: CLI Utility to wrap dart tests with reporter plugins -version: 1.1.4 +description: CLI Utility to wrap dart tests with reporter plugins. Extend to any report formats with special TestReporter class. +version: 1.1.5 repository: https://github.com/rIIh/dart_test_reporter issue_tracker: https://github.com/rIIh/dart_test_reporter/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+%5Btest_reporter%5D