testmate 1.0.1
testmate: ^1.0.1 copied to clipboard
A smart test logger for Dart & Flutter with CSV/JSON reporting.
TestMate #
TestMate is a developer-first test logger library for Dart and Flutter projects that helps you generate rich test execution reports with minimal setup.
It captures detailed results from your unit and integration tests including:
- Pass/fail status
- Start & end timestamps
- Exception and stack trace info
- Output values of test results
- Optional CSV, JSON, or plain-text logs
Features #
- Plug-and-play usage with
package:test - Auto-captures test success/failure
- Built-in exception and stack trace logging
- Generates logs in
.json,.csv, or.txt - Auto-names report files using test suite and datetime
- Supports generic result types with custom serializers
Getting Started #
1. Add the dependency #
dependencies:
testmate: ^1.0.1
### 2. Import in your test file
```dart
import 'package:testmate/testmate.dart';
3. Example Usage #
final logger = TestLogger();
test('returns valid data', () async {
final start = DateTime.now();
try {
final result = await myService.getData();
expect(result.isSuccess, isTrue);
logger.logSuccess(
testName: 'returns valid data',
startTime: start,
result: result,
resultSerializer: (r) => r.toString(),
);
} catch (e, st) {
logger.logFailure(
testName: 'returns valid data',
startTime: start,
exception: e,
stackTrace: st,
);
rethrow;
}
});
tearDownAll(() async {
await logger.save('test_output/my_test_log.json');
});
### 4. Output Example
```json
{
"testName": "returns valid data",
"startTime": "2025-05-28T18:17:56.123Z",
"endTime": "2025-05-28T18:17:56.123Z",
"status": "passed",
"message": "Test passed.",
"result": "result",
"exception": null,
"stackTrace": null
}
Csv Example
Test Name,Start Time,End Time,Status,Message,Result,Exception,Stack Trace
returns valid data,2025-05-28T18:17:56.123Z,2025-05-28T18:17:56.123Z,passed,Test passed.,result,null,null