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;
    }
  }
Ejemplo n.º 3
0
 boolean isAtSameLevelInTestClassHierarchy(@Nonnull TestedField another) {
   return getDeclaringTestClass() == another.getDeclaringTestClass();
 }