ContractHarness class final
The contract test harness: checks that the modules and roles of a registry follow the rules of the module model, the way the pipeline would generate them in every combination that matters.
For a module it builds an app for every provider of the role of its
variants, every provider of each role it requires, each subset of the
roles it only uses with every provider of each of them, and every
provider of a role whose package it contributes. For a role it builds an
app for each of its providers, with every provider of each role the
provider requires, and each subset of the roles the role uses with every
provider of each of them. It leaves out a combination of providers that
would give an app two providers of a role that takes one, unless every
combination would, so that the cases report why. uncheckedProviders
lists each provider of a role of a module that none of the apps of the
module has. For a role with a mode option (see RoleOption.mode), it
builds one more app of each provider of the role for each value of the
option after the first, and casesOfModes has the apps with every
module once more for those values.
Each app goes through the stages 3 to 5 of the pipeline, in a run
without a terminal that skips external setup, as the Flutter job
generates apps; stage 5 includes checkTemplateTags, and the
harness adds missingTemplateTags and reports templates with {{
that mason would copy as they are. Unless render is off, the harness
then makes the roles' choices (stage 7) with the options of the case,
renders the app in memory (stage 8) and checks the rendered code with
checkRendered. A question of a role that the options leave open, such
as the start screen of an app with several, gets the answer of a user
who presses Enter: the default, or the first choice. The result has the
options that make the same choice without asking
(ContractResult.answers). A mode option needs no answer. Its role
chooses the first value without it, in a terminal and in a run without
one, and the value that a case gives it otherwise: the harness reports
a role that does not (see check).
It depends on no test framework, so the tests of any package can use it.
Constructors
-
ContractHarness(ModuleRegistry registry, {ModuleContext context = defaultContext, bool render = true, Map<
String, String?> roleOptions = const {}, SetupLink? setupLink}) -
Creates the harness for
registry, generating apps described bycontext, and rendering them unlessrenderisfalse, with theroleOptionsof every case and thesetupLinkof a front end.
Properties
- context → ModuleContext
-
The context of the apps the harness builds.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- registry → ModuleRegistry
-
The modules and roles to check.
final
- render → bool
-
Whether the harness renders the app of every case that has no errors
and checks the rendered code.
final
-
roleOptions
→ Map<
String, String?> -
Values of role options by name for every case; the options of a case
override them.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- setupLink → SetupLink?
-
Names the page that guides the developer through the steps by hand of
an app, as the front end of the pipeline does (see SetupLink), for
the apps of every case: their render hooks and structural rules get
the link as a run of that front end gives it (see
ContractResult.setupLink).
final
Methods
-
casesOfAll(
) → List< ContractCase> - The cases of the apps with as many modules as one app can have, one for every combination of providers of the roles that take at most one and have several.
-
casesOfModes(
) → List< ContractCase> -
The cases of the apps with every module for the other values of the
mode options (see
RoleOption.mode): each case of casesOfAll once more for every combination of the values of the mode options of the roles of its app, but the combination of the first value of each, which is the app of casesOfAll itself. -
casesOfModule(
ModuleId id) → List< ContractCase> -
The cases of the module
id: -
casesOfRole(
Role< Object> role) → List<ContractCase> -
The cases of
role: for each of its providers and each subset of the roles the role uses, the largest first, one case for each combination of a provider of each role the provider requires and of each role of the subset, named as the cases of casesOfModule are, such asanalytics by firebase_analytics (get_it) with di. As for a module, a combination whose providers cannot be in one app with the provider is left out, such as another provider of a role that the provider provides too, unless no combination of the subset can. -
check(
ContractCase contractCase) → Future< ContractResult> -
Runs the stages 3 to 5 of the pipeline and missingTemplateTags for
contractCase, then, if render is on and they found no error, the stages 7 and 8 and checkRendered. -
checkAll(
) → Future< List< ContractResult> > - Checks every case of every module and every role of the registry, and returns the results of the cases whose app no case before built. A case with a value of a role option builds an app of its own, as the cases of the mode options do (see casesOfRole).
-
checkRendered(
ContractResult result, RenderedApp app) → List< SmfIssue> -
Checks
app, the rendered app ofresult, the files that its render hooks generated like those of its bricks: -
checkStructure(
ContractResult result, {required Map< String, String> files, required Map<String, ContributionOrigin> owners}) → List<SmfIssue> -
Indexes the Dart files among
files, the text files of the rendered app ofresultby path, runs the structural rules of its present roles with the data it collected, the steps by hand that stage 5 planned with their link (see ContractResult.manualSteps and ContractResult.setupLink) and the texts, and checks the symbols of their interfaces: those that the app needs, by the choices of its roles, are declared, and the app has no file of one that it does not need (seeRoleInterface.checkSymbols). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
uncheckedProviders(
) → Future< List< String> > - The providers that the harness checks no module with, though the module requires or uses their role, one line for each: a provider of a role that a module of the registry requires or uses, which can be in an app with the module (see casesOfModule) but provides the role in no app of the cases of the module. Either no case asks for the provider, or the apps of those that do fail to resolve, such as when no module of the registry provides a role that the provider requires.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- defaultContext → const ModuleContext
- The context of the apps the harness builds, with the platforms that the pipeline gives every app.