test_track_test_support 0.1.4 copy "test_track_test_support: ^0.1.4" to clipboard
test_track_test_support: ^0.1.4 copied to clipboard

Test utilities for working with package:test_track, including a FakeTestTrack allowing you to test your integration with TestTrack with predetermined behavior.

example/main.dart

import 'package:test/test.dart';
import 'package:test_track_test_support/test_track_test_support.dart';

void main() {
  test('FakeTestTrack allows you to configure deterministic behavior', () {
    final fakeTestTrack = FakeTestTrack(
      visitor: VisitorFactory.build().withId('abc123'),
      ab: (splitName, context, trueVariant) => splitName == 'test_enabled',
      vary: (splitName, defaultVariant, context) =>
          splitName == 'test_experiment' ? 'treatment' : 'control',
    );

    expect(fakeTestTrack.visitor.id, 'abc123');
    expect(
      fakeTestTrack.ab(splitName: 'test_enabled', context: 'whatever'),
      true,
    );
    expect(
      fakeTestTrack.ab(splitName: 'other_enabled', context: 'whatever'),
      false,
    );
    expect(
      fakeTestTrack.vary(
        splitName: 'test_experiment',
        defaultVariant: 'control',
        context: 'whatever',
      ),
      'treatment',
    );
    expect(
      fakeTestTrack.vary(
        splitName: 'other_experiment',
        defaultVariant: 'control',
        context: 'whatever',
      ),
      'control',
    );
  });
}
2
likes
140
pub points
18%
popularity

Publisher

verified publisherbetterment.dev

Test utilities for working with package:test_track, including a FakeTestTrack allowing you to test your integration with TestTrack with predetermined behavior.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (LICENSE)

Dependencies

equatable, meta, random_string, test_track

More

Packages that depend on test_track_test_support