execute method

void execute(
  1. AFStateTestContext context, {
  2. bool shouldVerify = true,
  3. AFStateTestID? upTo,
  4. AFStateTestID? continueFrom,
})

Execute the test by kicking of its queries, then

Implementation

void execute(AFStateTestContext context, { bool shouldVerify = true,
  AFStateTestID? upTo,
  AFStateTestID? continueFrom }) {
  AFStateTestContext.currentTest = context;

  // first, execute all the predecessor definitons.
  final defs = extendedStatements.definitionStatements();
  for(final exec in defs) {
    exec.execute(context);
  }

  // then, execute all the current definitions, this may override some of the
  // previous definitions
  for(final exec in currentStatements.definitionStatements) {
    exec.execute(context);
  }

  // then, execute all the predecessor executions, but don't do any verification,
  // not just because it would be redundant, but because it may be inaccurate due
  // to overriden definitions that impact the results of queries.
  try {

    // don't validate the extended execution.
    context.disableValidation();
    final execs = extendedStatements.executionStatements(upTo: upTo, continueFrom: continueFrom);
    for(final exec in execs) {
      final result = exec.execute(context, verify: false);
      if(result == _AFStateTestExecutionNext.stop) {
        return;
      }
    }

    // don't validate the extended execution.
    context.enableValidation();
    if(upTo == null) {
      // basically, we need to go through an execute each query that they specified.
      for(final exec in currentStatements.executionStatements) {
        final result = exec.execute(context, verify: true);
        if(result == _AFStateTestExecutionNext.stop) {
          return;
        }
      }
    }
  } on AFExceptionStopHere {
    context.addError("Test contains an executeDebugStopHere() statement.", 0);
  }

}