valenty_test 0.1.0 copy "valenty_test: ^0.1.0" to clipboard
valenty_test: ^0.1.0 copied to clipboard

Compile-time safe component testing DSL for Flutter apps with phantom types and typed fluent builders.

example/valenty_test_example.dart

// ignore_for_file: avoid_print
import 'package:valenty_test/valenty_test.dart';

/// Example: Using Valenty's typed builder DSL for compile-time safe testing.
///
/// For Flutter UI-first testing, use valentyTest() with SystemDsl and BackendStubDsl.
/// See the full documentation at https://github.com/valenty-dev/valenty
void main() {
  // The typed builder DSL enforces Given → When → Then ordering at compile time.
  // This example shows the pattern — in real usage, you'd have feature-specific
  // builders generated by AI.

  // Create a TestEnvironment for infrastructure setup/teardown.
  final env = TestEnvironment()
      .setup(() => print('  [setup] Overriding singleton factories...'))
      .teardown(() => print('  [teardown] Restoring original factories...'));

  print('TestEnvironment created (isEmpty: ${env.isEmpty})');
  print('');

  // Create a ScenarioBuilder with phantom-type state tracking.
  // The type parameter enforces Given -> When -> Then ordering.
  final scenario = ScenarioBuilder.create('example scenario');
  print('ScenarioBuilder created: "${scenario.description}"');
  print('');

  // Create a TestContext for sharing data between steps.
  final ctx = TestContext();
  ctx.set('product_price', 20.0);
  ctx.set('quantity', 5);
  print('TestContext stores typed values:');
  print('  product_price = ${ctx.get<double>("product_price")}');
  print('  quantity = ${ctx.get<int>("quantity")}');
  print('');

  print('Valenty DSL provides:');
  print('  - valentyTest() for UI-first component testing');
  print('  - Typed builders for compile-time safe acceptance tests');
  print('  - SystemDsl / BackendStubDsl / UiDriver base classes');
  print('  - TestEnvironment for infrastructure setup');
  print('  - ScenarioRunner for test execution');
  print('');
  print('See examples/ in the repository for complete working projects.');
}
0
likes
0
points
245
downloads

Publisher

unverified uploader

Weekly Downloads

Compile-time safe component testing DSL for Flutter apps with phantom types and typed fluent builders.

Repository (GitHub)
View/report issues

Topics

#testing #component-testing #flutter #dsl #clean-architecture

License

unknown (license)

Dependencies

meta, test

More

Packages that depend on valenty_test