All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.aoreshin.junit5.extensions.allure.AllureHideParametersExtension Maven / Gradle / Ivy

There is a newer version: 83
Show newest version
package com.github.aoreshin.junit5.extensions.allure;

import static java.util.stream.Collectors.toList;

import io.qameta.allure.Allure;
import io.qameta.allure.model.StepResult;
import java.util.List;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

/**
 * Extension that is used to delete Allure's test step parameters to enhance readability of tests
 */
public class AllureHideParametersExtension implements AfterEachCallback {
  @Override
  public void afterEach(ExtensionContext context) {
    Allure.getLifecycle()
        .updateTestCase(
            update -> {
              List processed = processStepResult(update.getSteps());
              update.setSteps(processed);
            });
  }

  private List processStepResult(List stepResults) {
    if (stepResults.size() != 0) {
      return stepResults.stream()
          .peek(
              stepResult -> {
                stepResult.setParameters(List.of());
                stepResult.setSteps(processStepResult(stepResult.getSteps()));
              })
          .collect(toList());
    }

    return List.of();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy