Skip to content

Commit

Permalink
docs: add docs and example
Browse files Browse the repository at this point in the history
  • Loading branch information
rIIh committed Nov 6, 2024
1 parent 7c1800d commit 5420ec6
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions packages/test_reporter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.5

- **docs:** add example

## 1.1.4

- **docs:** update README
Expand Down
2 changes: 1 addition & 1 deletion packages/test_reporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions packages/test_reporter/example/README.md
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions packages/test_reporter/lib/basic_reporter.dart
Original file line number Diff line number Diff line change
@@ -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<String> args) {
return BasicReporter();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
5 changes: 5 additions & 0 deletions packages/test_reporter/lib/src/reporter/test_reporter.dart
Original file line number Diff line number Diff line change
@@ -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<void> onEvent(TestEvent event);
}
4 changes: 2 additions & 2 deletions packages/test_reporter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 5420ec6

Please sign in to comment.