TestController constructor

TestController({
  1. Map<String, PageRoute>? customRoutes,
  2. TestStepDelays delays = const TestStepDelays(),
  3. GoldenImageWriter goldenImageWriter = TestStore.goldenImageWriter,
  4. int maxCommonSearchDepth = 3,
  5. required GlobalKey<NavigatorState> navigatorKey,
  6. AsyncCallback? onReset,
  7. bool screenshotOnFail = false,
  8. String? selectedSuiteName,
  9. bool stopOnFirstFail = false,
  10. TestStepRegistry? registry,
  11. TestImageReader testImageReader = TestStore.testImageReader,
  12. TestReader testReader = TestStore.testReader,
  13. WidgetBuilder? testReportBuilder,
  14. Level testReportLogLevel = Level.INFO,
  15. TestReporter testReporter = TestStore.testReporter,
  16. WidgetBuilder? testSuiteReportBuilder,
  17. TestWriter testWriter = TestStore.testWriter,
  18. List<VariableResolver>? variableResolvers,
  19. Map<String, dynamic>? variables,
})

A controller for a TestRunner that can create, run, load, and save automated tests.

When a new test is about to start, this will fire an event on the resetStream. Applications can listen to those events to reset themselves to a "known good state".

The navigatorKey is required to be the same key attached to a MaterialApp or a WidgetsApp. This allows the navigation to the TestReportsPage.

The testReportBuilder allows the overriding of the page to display the report from a test run. If omitted, the built in TestReportPage will be used. If set then the TestReport will be passed via the ModalRoute's arguments.

The delays is used to determina the various wait times and timeouts for the various test steps.

The maxCommonSearchDepth informs the Testable how far it should walk down the descendant tree to find a widget it knows how to wrap. To disable this auto-search for supported widgets, set this value to zero.

The registry is used for finding the both available test steps for building tests as well as running test steps. In general, the default TestStepRegistry is sufficient.

If provided, the variableResolvers will be used to resolve all variables before the default internal resolver will be consulted.

The testImageReader will be used when golden images are requested from a data store. The default testImageReader is a no-op that will always return null for all image requests.

This expects a testReader to be able to load tests into the platform for editing and / or execution. The default testReader is a no-op that will never return any tests.

A testWriter is used to be able to save / export tests that were created within the application. The default testWriter is a no-op that will do nothing with the given test.

Finally, a testReporter is used to submit test reports from tests executed within the application. The default testReporter is a no-op that will do nothing with any given report. The testReportLogLevel defines the level to capture in the TestReports that are submitted.

See also:

Implementation

TestController({
  Map<String, PageRoute>? customRoutes,
  this.delays = const TestStepDelays(),
  this.goldenImageWriter = TestStore.goldenImageWriter,
  this.maxCommonSearchDepth = 3,
  required GlobalKey<NavigatorState> navigatorKey,
  this.onReset,
  this.screenshotOnFail = false,
  this.selectedSuiteName,
  this.stopOnFirstFail = false,
  TestStepRegistry? registry,
  this.testImageReader = TestStore.testImageReader,
  TestReader testReader = TestStore.testReader,
  WidgetBuilder? testReportBuilder,
  Level testReportLogLevel = Level.INFO,
  TestReporter testReporter = TestStore.testReporter,
  WidgetBuilder? testSuiteReportBuilder,
  TestWriter testWriter = TestStore.testWriter,
  List<VariableResolver>? variableResolvers,
  Map<String, dynamic>? variables,
})  : _navigatorKey = navigatorKey,
      _registry = registry ?? TestStepRegistry.instance,
      _testReader = testReader,
      _testReportBuilder = testReportBuilder,
      _testReportLogLevel = testReportLogLevel,
      _testReporter = testReporter,
      _testSuiteReportBuilder = testSuiteReportBuilder,
      _testWriter = testWriter,
      _variableResolvers = variableResolvers ?? <VariableResolver>[] {
  _customRoutes.addAll(customRoutes ?? {});
  _globalVariables.addAll(variables ?? {});
}