saveForClass method

Future<void> saveForClass({
  1. required ClassElement classElement,
  2. required ElementAnnotation annotation,
  3. required CompilationUnit compilationUnit,
  4. required ClassDeclaration classAstNode,
  5. required PubspecData pubspecData,
  6. required File classFile,
  7. required TestRunInfo testRunInfo,
})

Implementation

Future<void> saveForClass(
    {required ClassElement classElement,
    required ElementAnnotation annotation,
    required CompilationUnit compilationUnit,
    required ClassDeclaration classAstNode,
    required PubspecData pubspecData,
    required File classFile,
    required TestRunInfo testRunInfo}) async {
  final List<String> excludedMethods = annotation.excludeMethods;
  final fileImport =
      'package:${pubspecData.packageName}/${PathUtils.relatetiveLibFilePath(classFile.path)}';

  final methodAstNodes = await classElement.getMethodDeclarations;
  List<Future> saveFutures = [];
  for (int i = 0; i < methodAstNodes.entries.length; i++) {
    final method = methodAstNodes.entries.elementAt(i);
    saveFutures.add(_saveTestsForMethod(
        method: method,
        compilationUnit: compilationUnit,
        classAstNode: classAstNode,
        fileImport: fileImport,
        excludedMethods: excludedMethods,
        subjectFile: classFile,
        testRunInfo: testRunInfo,
        className: classElement.displayName,
        methodAstNodes: methodAstNodes));
  }
  await Future.wait(saveFutures);
}