com.github.aoreshin.junit5.extensions.allure.AllureHideParametersExtension Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of allure-junit5-extensions Show documentation
Show all versions of allure-junit5-extensions Show documentation
Project to ease pain of test automation
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();
}
}