TestController constructor
- Map<
String, PageRoute> ? customRoutes, - TestStepDelays delays = const TestStepDelays(),
- GoldenImageWriter goldenImageWriter = TestStore.goldenImageWriter,
- int maxCommonSearchDepth = 3,
- AsyncCallback? onReset,
- bool screenshotOnFail = false,
- String? selectedSuiteName,
- bool stopOnFirstFail = false,
- TestStepRegistry? registry,
- TestImageReader 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,
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 ?? {});
}