tracera_flutter

Tracera Autotest adapter for Flutter widget tests and integration_test.

Requires Dart ≥ 3.8 and Flutter ≥ 3.24.

flutter pub add dev:tracera_flutter

Call installTracera() once at the top of the main function, or in flutter_test_config.dart. Keep the stock flutter_test and integration_test imports; add only installTracera and the tracera calls:

import 'package:flutter_test/flutter_test.dart';
import 'package:tracera/tracera.dart' as tracera;
import 'package:tracera_flutter/tracera_flutter.dart';

void main() {
  installTracera();

  testWidgets('user can sign in', (tester) async {
    await tracera.step('pump login', () async {
      await tester.pumpWidget(/* … */);
    });
  }, tags: ['tracera-id-42']);
}

How-to: flutter. Shared env / run mode: Autotest adapters.

On a device or emulator (flutter test -d …), pass TRACERA_* with --dart-define=TRACERA_*=… — the device isolate does not see the host process environment. On an Android emulator, use 10.0.2.2 instead of localhost in TRACERA_BASE_URL when the API runs on the host.

Bind

Add the tag tracera-id-‹id› to a testWidgets, test, or group. Add tracera-name-‹name› to set autotestName. A name tag cannot contain spaces; to use spaces, bind inside the test with tracera.testCase(id, 'name'). If the name tag is omitted, autotestName takes the value of the Flutter test name.

To silence warnings about undefined tags, list the Tracera tags under tags: in dart_test.yaml.

Skip

Call markTestSkipped('reason') inside the test. The result is reported as Skipped, and the reason is added to the result as comment. The skip: argument on testWidgets or group is not reported.

Steps

Use tracera.step('…', () { … }). A setUp callback maps to Setup, the test body to Test, and a tearDown callback to Teardown. Steps inside setUpAll / tearDownAll are not reported.

Comments, errors, and attachments

tracera.comment, tracera.error, and attachments are added to the open step, or to the result when no step is open. tracera.attachmentFile takes a file path; tracera.attachmentBytes takes a name and bytes, with an optional mimeType. Shared placement rules and limits: Autotest adapters.

Screenshots

Screenshots are PNG attachments from a capture or from bytes you pass.

  • attachScreenshot(tester) captures a widget-test screenshot (optional finder).
  • attachScreenshotBytes(bytes) attaches PNG bytes you already have.
  • attachIntegrationScreenshot(name: 'checkout') (from package:tracera_flutter/integration.dart) takes a device screenshot in integration_test.

Parameterized

Create one testWidgets in a loop for each row. If the name is omitted, autotestName takes the value of the test name, so give each row a distinct title, or pass a name to tracera.testCase(id, 'name'). When a test is retried, only the final attempt is reported, and the Env tab includes FLUTTER_RETRY.

Libraries

integration
Device-screenshot helper for package:integration_test.
tracera_flutter
Tracera Autotest adapter for Flutter widget and integration tests.