setUp method

  1. @mustCallSuper
  2. @override
void setUp()

Implementation

@mustCallSuper
@override
void setUp() {
  // TODO(srawlins): In a major release, change this logic to just ensure that
  // `rule` has been set to an analysis rule instance other than
  // `_SentinelRule`.
  if (rule is _SentinelRule) {
    if (analysisRule == 'sentinel') {
      throw StateError('The `rule` field must be set in the `setUp` method.');
    }
    // The developer is using the deprecated `analysisRule` to set the
    // rule-under-test.
    _analysisRule = analysisRule;
  } else {
    _analysisRule = rule.name;
    Registry.ruleRegistry.registerLintRule(rule);
  }
  super.setUp();
  newAnalysisOptionsYamlFile(
    testPackageRootPath,
    analysisOptionsContent(experiments: experiments, rules: [_analysisRule]),
  );
}