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 that has several, each subset of the roles it only uses, 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 that has several, and each subset of the roles the role uses. 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).

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 {}})
Creates the harness for registry, generating apps described by context, and rendering them unless render is false, with the roleOptions of every case.

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

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.
casesOfModule(ModuleId id) → List<ContractCase>
The cases of the module id:
casesOfRole(Role<Object> role) → List<ContractCase>
The cases of role: each of its providers, with every provider of each role the provider requires that has several, and each subset of the roles the role uses.
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.
checkRendered(ContractResult result, RenderedApp app) → List<SmfIssue>
Checks app, the rendered app of result:
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 of result by path, runs the structural rules of its present roles with the data it collected and the texts, and checks the symbols of their interfaces.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

defaultContext → const ModuleContext
The context of the apps the harness builds.