TestController class

Controller that allows for the creation, loading, saving, and running of automated tests.


TestController({Map<String, PageRoute> customRoutes, TestStepDelays delays = const TestStepDelays(), GoldenImageWriter goldenImageWriter = TestStore.goldenImageWriter, int maxCommonSearchDepth = 3, @required GlobalKey<NavigatorState> navigatorKey, @required 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, Map<String, dynamic> variables})
A controller for a TestRunner that can create, run, load, and save automated tests. [...]


currentTest Test
Returns the current from the controller. This will never be null.
read / write
customRoutes Map<String, PageRoute>
Returns the custom routes, sorted by the display name.
delays TestStepDelays
The delays that tests should wait for.
goldenImageWriter GoldenImageWriter
Writer that saves golden images for a particular device.
hashCode int
The hash code for this object. [...]
read-only, inherited
maxCommonSearchDepth int
Defines how far down a widget tree a Testable widget should look for a supported widget for the purposes of getting or setting values and errors.
onReset AsyncCallback
Callback function that the application must register with the controller so that when a reset is requested by a test, the application properly resets to the initial state.
registry TestStepRegistry
Returns the registry that is being used by the controller.
runningTest bool
Returns whether or not the controller is actively running a test now or not.
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
screencapStream Stream<CaptureContext>
Returns the stream that will fire screep capture requests on.
screenshotOnFail bool
Defines whether the framework should take a screenshot automatically whenever a failure is detected or not.
selectedSuiteName String
The currently selected test suite name.
read / write
sleep ProgressValue
Informs the controller that a sleep status update has happened.
sleepStream Stream<ProgressValue>
Returns the stream that will fire updates as a test is sleeping / waiting.
state TestControllerState
Returns the current state for the test controller.
status String
Informs the controller that a test status update has happened.
statusStream Stream<String>
Returns the stream that will fire updates when a test status changes.
step ProgressValue
Informs the controller that a test step update has happened.
stepStream Stream<ProgressValue>
Returns the stream that will fire updates when a test moves from step to step.
stopOnFirstFail bool
Defines whether or not the framework should stop on the first failed step or keep going and executing subsequent steps.
testImageReader TestImageReader
The image reader to read images for golden image comparisons.
variables Map<String, dynamic>
Returns an unmodifiable map of all the currently set variables.


cancelRunningTests([Duration timeout = const Duration(minutes: 5)]) Future<void>
Canceles any currently running test. The current step will be the last to execute, but this may still take a while as the current second could be a long running step. [...]
clearCustomRoutes() → void
Clears all the custom routes.
clearVariables() → void
Clears all the variables.
dispose() → void
Disposes the controller. Once disposed, a controller can not be reused.
execute({String name, TestReport report, bool reset = true, Duration stepTimeout, List<TestStep> steps, bool submitReport = true, String suiteName, TestSuiteReport testSuiteReport, Duration testTimeout, int version}) Future<TestReport>
Executes a series of tests steps. This accepts the name of the test which may be null or empty. The reset defines if the controller should ask the application to perform a full reset before running or if it should attempt to run for the current state. [...]
executeStep({CancelToken cancelToken, TestReport report, TestStep step, bool subStep = true}) Future<bool>
Executes a single step and attaches the execution information to the testReport. The cancelToken allows the step to be cancelled. Whenever a step has a loop or a long running task, it should listen to the stream from the token or read the flag from the token.
executeTest({Test test, TestReport report}) Future<TestReport>
Executes a single test. This will reset the application and submit the report. If the report is set it will be used, otherwise a net-new TestReport will be created and returned.
exportCurrentTest({bool clear = true, BuildContext context}) Future<bool>
Attempts to export the current test via the testWriter value. This will return true if and only if the current testWriter both returns true and no exceptions were thrown along the way. [...]
getVariable(String variableName) → dynamic
Returns the variable from the controller. This will return null if the variable is not currently set on the controller.
loadTests(BuildContext context, {String suiteName}) Future<List<PendingTest>>
Loads the list of tests from the assigned TestReader. This accepts the BuildContext to allow the reader to provide visual feedback to the user in case the load takes a while.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
registerCustomRoute(String display, PageRoute route) → void
Registers a custom route with the framework. These routes will be displayed on the TestStepsDialog and TestStepsPage. The display is the string to display in a ListTile's title to trigger navigation to the route. If the route is null, this will remove any route registered to the display. If the display is already registered, it will be replaced with the new route
removeVariable({String variableName}) → void
Removes the variable with the given variableName from the controller.
reset() Future<void>
Requests the application to perform a reset.
resolveVariable(dynamic input) → dynamic
Resolves the given input with any potential variable on the controller. Variable values use the mustache format and must begin with {{ and end with }}. If the input is not marked as a variable or there is no variable with the matching key registered then the input will be return unaltered.
runPendingTests(List<PendingTest> tests, [Duration waitTimeout = _kSuiteStartTimeout]) Future<TestSuiteReport>
Runs a series of tests. For full runs, this is more memory efficient as it will only load the tests as needed.
runTests(List<Test> tests, {Duration stepTimeout, Duration waitTimeout = _kSuiteStartTimeout}) Future<TestSuiteReport>
Runs a series of tests. This is useful for smaller numbers of in-memory tests but the runPendingTests should be prefered for full application runs or for CI/CD pipelines as that only loads the bare minimum data up front and then loads the full test data on an as needed basis.
screencap() Future<Uint8List>
Executes a screen capture for the application. As a note, depending on the device this may take several seconds. The screenshot call is fully async so this will wait until up to TestStepDelays.screenshot for the response. [...]
setVariable({dynamic value, String variableName}) → void
Sets the variable with the variableName to the value.
submitReport(TestReport report) Future<bool>
Submits the test report through the TestReporter.
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]

Static Methods

of(BuildContext context) TestController
Returns the TestController provided by the widget tree. This will never throw an exception but may return null if no controller is available on the widget tree.