Skip to content

refactor: include visibleForTesting annotation on test parameters #761

@alestiago

Description

@alestiago

Description

Throughout the codebase there are many instances where a class has optional parameters to allow dependency injection during testing, these should be annotated with visibleForTesting.

For example:

// lib/src/commands/create/commands/create_subcommand.dart
  CreateSubCommand({
    required Analytics analytics,
    required this.logger,
    required MasonGeneratorFromBundle? generatorFromBundle,
    required MasonGeneratorFromBrick? generatorFromBrick,
  })

We should intentionally and explicitly denote these as visibleForTesting as:

// lib/src/commands/create/commands/create_subcommand.dart
  CreateSubCommand({
    required Analytics analytics,
    required this.logger,
    @visibleForTesting required MasonGeneratorFromBundle? generatorFromBundle,
    @visibleForTesting required MasonGeneratorFromBrick? generatorFromBrick,
  })

Expected Behavior

  • To have all parameters that are used exclusively for testing purposes be annotated with visibleForTesting.

Additional Context

Metadata

Metadata

Assignees

Labels

good first issueGood for newcomersrefactorA code change that neither fixes a bug nor add a feature

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions