public void clearTestedFields() {
    injectionState.lifecycleMethods.executePreDestroyMethodsIfAny();

    for (TestedField testedField : testedFields) {
      testedField.clearIfAutomaticCreation();
    }
  }
  public void assignNewInstancesToTestedFields(@NotNull Object testClassInstance) {
    injectionState.buildListsOfInjectables(testClassInstance, injectableFields);

    TestedField previousField = null;

    for (TestedField testedField : testedFields) {
      if (previousField != null && !testedField.isAtSameLevelInTestClassHierarchy(previousField)) {
        injectionState.discardInjectablesFromLowerTestClassHierarchyLevels(
            testedField.getDeclaringTestClass());
      }

      testedField.instantiateWithInjectableValues(testClassInstance);
      injectionState.resetConsumedInjectables();
      previousField = testedField;
    }
  }
예제 #3
0
 boolean isAtSameLevelInTestClassHierarchy(@Nonnull TestedField another) {
   return getDeclaringTestClass() == another.getDeclaringTestClass();
 }