diff --git a/allure-generator/build.gradle b/allure-generator/build.gradle index f6ad7e342..282b8bdd2 100644 --- a/allure-generator/build.gradle +++ b/allure-generator/build.gradle @@ -54,6 +54,7 @@ dependencies { compile('com.fasterxml.jackson.dataformat:jackson-dataformat-yaml') compile('commons-io:commons-io') compile('io.qameta.allure:allure2-model-api') + compile('io.qameta.allure:allure-model') compile('org.allurefw:allure1-model') compile('org.apache.httpcomponents:httpclient') compile('org.apache.tika:tika-core') diff --git a/allure-generator/src/main/java/io/qameta/allure/ConfigurationBuilder.java b/allure-generator/src/main/java/io/qameta/allure/ConfigurationBuilder.java index 34667b651..6483d71b2 100644 --- a/allure-generator/src/main/java/io/qameta/allure/ConfigurationBuilder.java +++ b/allure-generator/src/main/java/io/qameta/allure/ConfigurationBuilder.java @@ -2,6 +2,7 @@ import io.qameta.allure.allure1.Allure1Plugin; import io.qameta.allure.allure2.Allure2Plugin; +import io.qameta.allure.allure3.Allure3Plugin; import io.qameta.allure.category.CategoriesPlugin; import io.qameta.allure.category.CategoriesTrendPlugin; import io.qameta.allure.context.FreemarkerContext; @@ -86,6 +87,7 @@ public ConfigurationBuilder useDefault() { new Allure1Plugin(), new Allure1EnvironmentPlugin(), new Allure2Plugin(), + new Allure3Plugin(), new GaPlugin() )); return this; diff --git a/allure-generator/src/main/java/io/qameta/allure/DummyReportGenerator.java b/allure-generator/src/main/java/io/qameta/allure/DummyReportGenerator.java index eb68d12e5..38f3b859a 100644 --- a/allure-generator/src/main/java/io/qameta/allure/DummyReportGenerator.java +++ b/allure-generator/src/main/java/io/qameta/allure/DummyReportGenerator.java @@ -2,6 +2,7 @@ import io.qameta.allure.allure1.Allure1Plugin; import io.qameta.allure.allure2.Allure2Plugin; +import io.qameta.allure.allure3.Allure3Plugin; import io.qameta.allure.category.CategoriesPlugin; import io.qameta.allure.category.CategoriesTrendPlugin; import io.qameta.allure.context.FreemarkerContext; @@ -88,6 +89,7 @@ public final class DummyReportGenerator { new Allure1Plugin(), new Allure1EnvironmentPlugin(), new Allure2Plugin(), + new Allure3Plugin(), new ReportWebPlugin() { @Override public void aggregate(final Configuration configuration, diff --git a/allure-generator/src/main/java/io/qameta/allure/allure3/Allure3Plugin.java b/allure-generator/src/main/java/io/qameta/allure/allure3/Allure3Plugin.java new file mode 100644 index 000000000..9bb58d3e2 --- /dev/null +++ b/allure-generator/src/main/java/io/qameta/allure/allure3/Allure3Plugin.java @@ -0,0 +1,326 @@ +package io.qameta.allure.allure3; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.qameta.allure.ReadError; +import io.qameta.allure.Reader; +import io.qameta.allure.context.RandomUidContext; +import io.qameta.allure.core.Configuration; +import io.qameta.allure.core.ResultsVisitor; +import io.qameta.allure.entity.Attachment; +import io.qameta.allure.entity.Label; +import io.qameta.allure.entity.Link; +import io.qameta.allure.entity.Parameter; +import io.qameta.allure.entity.StageResult; +import io.qameta.allure.entity.Status; +import io.qameta.allure.entity.Step; +import io.qameta.allure.entity.Time; +import io.qameta.allure.model3.StepResult; +import io.qameta.allure.model3.TestResult; +import io.qameta.allure.model3.TestResultType; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.TreeSet; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +import static io.qameta.allure.entity.LabelName.RESULT_FORMAT; +import static java.nio.file.Files.newDirectoryStream; +import static java.util.Comparator.comparing; +import static java.util.Comparator.naturalOrder; +import static java.util.Comparator.nullsFirst; +import static java.util.Objects.nonNull; + +/** + * Plugin that reads results from Allure 3 data format. + * + * @since 3.0 + */ +@SuppressWarnings("PMD.ExcessiveImports") +public class Allure3Plugin implements Reader { + + public static final String ALLURE3_RESULTS_FORMAT = "allure3"; + + public static final String TEST_RESULT_FILE_SUFFIX = "-allure.json"; + + private static final String TEST_RESULT_FILE_GLOB = "*-allure.json"; + + private final ObjectMapper mapper; + + private final List errors = new ArrayList<>(); + + private static final Comparator BY_START = comparing( + StageResult::getTime, + nullsFirst(comparing(Time::getStart, nullsFirst(naturalOrder()))) + ); + + public Allure3Plugin() { + this.mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL); + } + + @Override + public void readResults(final Configuration configuration, + final ResultsVisitor visitor, + final Path resultsDirectory) { + final RandomUidContext context = configuration.requireContext(RandomUidContext.class); + List allResults = readTestResults(resultsDirectory).collect(Collectors.toList()); + List fixtures = allResults.stream() + .filter(result -> TestResultType.SET_UP.equals(result.getType()) + || TestResultType.TEAR_DOWN.equals(result.getType())).collect(Collectors.toList()); + allResults.stream().filter(result -> TestResultType.TEST.equals(result.getType())).forEach( + result -> convert(context.getValue(), resultsDirectory, visitor, fixtures, result) + ); + } + + private Stream readTestResults(final Path resultsDirectory) { + return listFiles(resultsDirectory) + .map(this::readTestResult) + .filter(Optional::isPresent) + .map(Optional::get); + } + + private Optional readTestResult(final Path file) { + try (InputStream is = Files.newInputStream(file)) { + return Optional.ofNullable(mapper.readValue(is, TestResult.class)); + } catch (IOException e) { + errors.add(new ReadError(e, "Could not read result container file {}", file)); + return Optional.empty(); + } + } + + public List getErrors() { + return errors; + } + + private Stream listFiles(final Path directory) { + try (DirectoryStream directoryStream = newDirectoryStream(directory, TEST_RESULT_FILE_GLOB)) { + return StreamSupport.stream(directoryStream.spliterator(), false) + .filter(Files::isRegularFile) + .collect(Collectors.toList()) + .stream(); + } catch (IOException e) { + errors.add(new ReadError(e, "Could not list files in directory {}", directory)); + return Stream.empty(); + } + } + + private void convert(final Supplier uidGenerator, + final Path resultsDirectory, + final ResultsVisitor visitor, + final List fixtures, + final TestResult result) { + final io.qameta.allure.entity.TestResult dest = new io.qameta.allure.entity.TestResult(); + dest.setUid(uidGenerator.get()); + dest.setHistoryId(result.getHistoryId()); + dest.setFullName(result.getFullName()); + dest.setName(firstNonNull(result.getName(), result.getFullName(), "Unknown test")); + dest.setTime(Time.create(result.getStart(), result.getStop())); + dest.setDescription(result.getDescription()); + dest.setDescriptionHtml(result.getDescriptionHtml()); + dest.setStatus(convert(result.getStatus())); + dest.setStatusMessage(result.getStatusMessage()); + dest.setStatusTrace(result.getStatusTrace()); + dest.setLinks(convert(result.getLinks(), this::convert)); + dest.setLabels(convert(result.getLabels(), this::convert)); + dest.setParameters(getParameters(result)); + + dest.addLabelIfNotExists(RESULT_FORMAT, ALLURE3_RESULTS_FORMAT); + + if (hasTestStage(result)) { + dest.setTestStage(getTestStage(resultsDirectory, visitor, result)); + } + + final List testFixtures = findAllFixtures(fixtures, result.getUuid(), new HashSet<>()); + dest.getBeforeStages().addAll(getBefore(resultsDirectory, visitor, testFixtures)); + dest.getAfterStages().addAll(getAfter(resultsDirectory, visitor, testFixtures)); + visitor.visitTestResult(dest); + } + + private List convert(final Collection source, final Function converter) { + return Objects.isNull(source) ? Collections.emptyList() : source.stream() + .map(converter) + .collect(Collectors.toList()); + } + + private StageResult convert(final Path source, + final ResultsVisitor visitor, + final TestResult result) { + return new StageResult() + .setName(result.getName()) + .setTime(convert(result.getStart(), result.getStop())) + .setStatus(convert(result.getStatus())) + .setSteps(convert(result.getSteps(), step -> convert(source, visitor, step))) + .setAttachments(convert(result.getAttachments(), attach -> convert(source, visitor, attach))) + .setParameters(convert(result.getParameters(), this::convert)) + .setStatusMessage(result.getStatusMessage()) + .setStatusTrace(result.getStatusTrace()); + } + + private Link convert(final io.qameta.allure.model3.Link link) { + return new Link() + .setName(link.getName()) + .setType(link.getType()) + .setUrl(link.getUrl()); + } + + private Label convert(final io.qameta.allure.model3.Label label) { + return new Label() + .setName(label.getName()) + .setValue(label.getValue()); + } + + private Parameter convert(final io.qameta.allure.model3.Parameter parameter) { + return new Parameter() + .setName(parameter.getName()) + .setValue(parameter.getValue()); + } + + private Attachment convert(final Path source, + final ResultsVisitor visitor, + final io.qameta.allure.model3.Attachment attachment) { + final Path attachmentFile = source.resolve(attachment.getSource()); + if (Files.isRegularFile(attachmentFile)) { + final Attachment found = visitor.visitAttachmentFile(attachmentFile); + if (nonNull(attachment.getContentType())) { + found.setType(attachment.getContentType()); + } + if (nonNull(attachment.getName())) { + found.setName(attachment.getName()); + } + return found; + } else { + visitor.error("Could not find attachment " + attachment.getSource() + " in directory " + source); + return new Attachment() + .setType(attachment.getContentType()) + .setName(attachment.getName()) + .setSize(0L); + } + } + + private Step convert(final Path source, + final ResultsVisitor visitor, + final StepResult step) { + final Step result = new Step(); + result.setName(step.getName()); + result.setStatus(convert(step.getStatus())); + result.setTime(convert(step.getStart(), step.getStop())); + result.setParameters(convert(step.getParameters(), this::convert)); + result.setAttachments(convert(step.getAttachments(), attachment -> convert(source, visitor, attachment))); + result.setSteps(convert(step.getSteps(), s -> convert(source, visitor, s))); + result.setStatusMessage(step.getStatusMessage()); + result.setStatusTrace(step.getStatusTrace()); + return result; + } + + private Status convert(final io.qameta.allure.model3.Status status) { + if (Objects.isNull(status)) { + return Status.UNKNOWN; + } + return Stream.of(Status.values()) + .filter(item -> item.value().equalsIgnoreCase(status.value())) + .findAny() + .orElse(Status.UNKNOWN); + } + + private Time convert(final Long start, final Long stop) { + return new Time() + .setStart(start) + .setStop(stop) + .setDuration(nonNull(start) && nonNull(stop) ? stop - start : null); + } + + private List getParameters(final TestResult result) { + final TreeSet parametersSet = new TreeSet<>( + comparing(Parameter::getName, nullsFirst(naturalOrder())) + .thenComparing(Parameter::getValue, nullsFirst(naturalOrder())) + ); + parametersSet.addAll(convert(result.getParameters(), this::convert)); + return new ArrayList<>(parametersSet); + } + + private StageResult getTestStage(final Path source, + final ResultsVisitor visitor, + final TestResult result) { + StageResult testStage = new StageResult(); + testStage.setSteps(convert(result.getSteps(), step -> convert(source, visitor, step))); + testStage.setAttachments(convert(result.getAttachments(), attachment -> convert(source, visitor, attachment))); + testStage.setStatus(convert(result.getStatus())); + + testStage.setStatusMessage(result.getStatusMessage()); + testStage.setStatusTrace(result.getStatusTrace()); + return testStage; + } + + private boolean hasTestStage(final TestResult result) { + return !result.getSteps().isEmpty() || !result.getAttachments().isEmpty(); + } + + private List getBefore(final Path source, + final ResultsVisitor visitor, + final List testFixtures) { + return convert( + testFixtures.stream().filter( + fixture -> TestResultType.SET_UP.equals(fixture.getType()) + ).collect(Collectors.toList()), + fixture -> convert(source, visitor, fixture) + ).stream().sorted(BY_START).collect(Collectors.toList()); + } + + private List getAfter(final Path source, + final ResultsVisitor visitor, + final List testFixtures) { + return convert( + testFixtures.stream().filter( + fixture -> TestResultType.TEAR_DOWN.equals(fixture.getType()) + ).collect(Collectors.toList()), + fixture -> convert(source, visitor, fixture) + ).stream().sorted(BY_START).collect(Collectors.toList()); + } + + private List findAllFixtures(final List fixtures, + final String id, + final Set seen) { + final List result = new ArrayList<>(); + final List resultFixtures = findFixteres(fixtures, id, seen); + result.addAll(resultFixtures); + for (TestResult fixture : resultFixtures) { + result.addAll(findAllFixtures(fixtures, fixture.getUuid(), seen)); + } + return result; + } + + private List findFixteres(final List fixtures, + final String id, + final Set seen) { + return fixtures.stream() + .filter(fixture -> fixture.getChildren().contains(id)) + .filter(fixture -> !seen.contains(fixture.getUuid())) + .collect(Collectors.toList()); + } + + @SafeVarargs + private static T firstNonNull(final T... items) { + return Stream.of(items) + .filter(Objects::nonNull) + .findFirst() + .orElseThrow(() -> new IllegalStateException( + "firstNonNull method should have at least one non null parameter" + )); + } +} diff --git a/allure-generator/src/test/java/io/qameta/allure/allure3/Allure3PluginTest.java b/allure-generator/src/test/java/io/qameta/allure/allure3/Allure3PluginTest.java new file mode 100644 index 000000000..f231b002f --- /dev/null +++ b/allure-generator/src/test/java/io/qameta/allure/allure3/Allure3PluginTest.java @@ -0,0 +1,228 @@ +package io.qameta.allure.allure3; + +import io.qameta.allure.ConfigurationBuilder; +import io.qameta.allure.DefaultResultsVisitor; +import io.qameta.allure.core.Configuration; +import io.qameta.allure.core.LaunchResults; +import io.qameta.allure.entity.Attachment; +import io.qameta.allure.entity.LabelName; +import io.qameta.allure.entity.Parameter; +import io.qameta.allure.entity.StageResult; +import io.qameta.allure.entity.Step; +import io.qameta.allure.entity.TestResult; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Iterator; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; + +import static io.qameta.allure.entity.Status.UNKNOWN; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class Allure3PluginTest { + + @Rule + public TemporaryFolder folder = new TemporaryFolder(); + + @Test + public void shouldReadBefores() throws Exception { + Set testResults = process( + "allure3/before-fixture-1-allure.json", generateTestResultName(), + "allure3/before-fixture-2-allure.json", generateTestResultName(), + "allure3/simple-testcase-allure.json", generateTestResultName(), + "allure3/after-fixture-1-allure.json", generateTestResultName(), + "allure3/after-fixture-2-allure.json", generateTestResultName() + ).getResults(); + + assertThat(testResults) + .hasSize(1) + .flatExtracting(TestResult::getBeforeStages) + .hasSize(2) + .extracting(StageResult::getName) + .containsExactlyInAnyOrder("Configure TestNG engine 1", "Configure TestNG engine 2"); + } + + @Test + public void shouldReadAftersFromGroups() throws Exception { + Set testResults = process( + "allure3/before-fixture-1-allure.json", generateTestResultName(), + "allure3/before-fixture-2-allure.json", generateTestResultName(), + "allure3/simple-testcase-allure.json", generateTestResultName(), + "allure3/after-fixture-1-allure.json", generateTestResultName(), + "allure3/after-fixture-2-allure.json", generateTestResultName() + ).getResults(); + + assertThat(testResults) + .hasSize(1) + .flatExtracting(TestResult::getAfterStages) + .hasSize(2) + .extracting(StageResult::getName) + .containsExactlyInAnyOrder("tearDown1", "tearDown2"); + } + + @Test + public void shouldExcludeDuplicatedParams() throws Exception { + Set testResults = process( + "allure3/duplicated-params-allure.json", generateTestResultName() + ).getResults(); + + assertThat(testResults) + .hasSize(1) + .flatExtracting(TestResult::getParameters) + .hasSize(4) + .extracting(Parameter::getName, Parameter::getValue) + .containsExactlyInAnyOrder( + tuple("name", "value"), + tuple("name2", "value"), + tuple("name", "value2"), + tuple("name2", "value2") + ); + } + + @Test + public void shouldPickUpAttachmentsForTestCase() throws IOException { + Set testResults = process( + "allure3/before-fixture-1-allure.json", generateTestResultName(), + "allure3/before-fixture-2-allure.json", generateTestResultName(), + "allure3/simple-testcase-allure.json", generateTestResultName(), + "allure3/after-fixture-1-allure.json", generateTestResultName(), + "allure3/after-fixture-2-allure.json", generateTestResultName(), + "allure3/test-sample-attachment.txt", "test-sample-attachment.txt" + ).getResults(); + + assertThat(testResults) + .describedAs("Test case is not found") + .hasSize(1) + .extracting(TestResult::getTestStage) + .flatExtracting(StageResult::getSteps) + .describedAs("Test case should have one step") + .hasSize(1) + .flatExtracting(Step::getAttachments) + .describedAs("Step should have an attachment") + .hasSize(1) + .extracting(Attachment::getName) + .containsExactly("String attachment in test"); + } + + @Test + public void shouldPickUpAttachmentsForAfters() throws IOException { + Set testResults = process( + "allure3/before-fixture-1-allure.json", generateTestResultName(), + "allure3/before-fixture-2-allure.json", generateTestResultName(), + "allure3/simple-testcase-allure.json", generateTestResultName(), + "allure3/after-fixture-1-allure.json", generateTestResultName(), + "allure3/after-fixture-2-allure.json", generateTestResultName(), + "allure2/after-sample-attachment.txt", "after-sample-attachment.txt" + ).getResults(); + + assertThat(testResults) + .describedAs("Test case is not found") + .hasSize(1) + .flatExtracting(TestResult::getAfterStages) + .describedAs("Test case should have afters") + .hasSize(2) + .flatExtracting(StageResult::getAttachments) + .describedAs("Second after method should have an attachment") + .hasSize(1) + .extracting(Attachment::getName) + .describedAs("Attachment's name is unexpected") + .containsExactly("String attachment in after"); + } + + @Test + public void shouldDoNotOverrideAttachmentsForGroups() throws IOException { + Set testResults = process( + "allure3/other-testcase-allure.json", generateTestResultName(), + "allure3/other-testcase-allure.json", generateTestResultName(), + "allure3/after-fixture-2-allure.json", generateTestResultName(), + "allure2/after-sample-attachment.txt", "after-sample-attachment.txt" + ).getResults(); + + assertThat(testResults) + .describedAs("Test cases is not found") + .hasSize(2); + + testResults.forEach(testResult -> assertThat(testResult.getAfterStages()) + .hasSize(1) + .flatExtracting(StageResult::getAttachments) + .hasSize(1) + .extracting(Attachment::getName) + .containsExactly("String attachment in after")); + + } + + @Test + public void shouldProcessEmptyStatus() throws Exception { + Set testResults = process( + "allure3/no-status-allure.json", generateTestResultName() + ).getResults(); + + assertThat(testResults) + .hasSize(1) + .extracting(TestResult::getStatus) + .containsExactly(UNKNOWN); + } + + @Test + public void shouldProcessNullStatus() throws Exception { + Set testResults = process( + "allure3/null-status-allure.json", generateTestResultName() + ).getResults(); + + assertThat(testResults) + .hasSize(1) + .extracting(TestResult::getStatus) + .containsExactly(UNKNOWN); + } + + @Test + public void shouldAddTestResultFormatLabel() throws Exception { + Set testResults = process( + "allure3/before-fixture-1-allure.json", generateTestResultName(), + "allure3/before-fixture-2-allure.json", generateTestResultName(), + "allure3/simple-testcase-allure.json", generateTestResultName(), + "allure3/after-fixture-1-allure.json", generateTestResultName(), + "allure3/after-fixture-2-allure.json", generateTestResultName() + ).getResults(); + + assertThat(testResults) + .extracting(result -> result.findOneLabel(LabelName.RESULT_FORMAT)) + .extracting(Optional::get) + .containsOnly(Allure3Plugin.ALLURE3_RESULTS_FORMAT); + } + + + public static String generateTestResultName() { + return UUID.randomUUID().toString() + Allure3Plugin.TEST_RESULT_FILE_SUFFIX; + } + + private LaunchResults process(String... strings) throws IOException { + Path resultsDirectory = folder.newFolder().toPath(); + Iterator iterator = Arrays.asList(strings).iterator(); + while (iterator.hasNext()) { + String first = iterator.next(); + String second = iterator.next(); + copyFile(resultsDirectory, first, second); + } + Allure3Plugin reader = new Allure3Plugin(); + final Configuration configuration = new ConfigurationBuilder().useDefault().build(); + final DefaultResultsVisitor resultsVisitor = new DefaultResultsVisitor(configuration); + reader.readResults(configuration, resultsVisitor, resultsDirectory); + return resultsVisitor.getLaunchResults(); + } + + private void copyFile(Path dir, String resourceName, String fileName) throws IOException { + try (InputStream is = getClass().getClassLoader().getResourceAsStream(resourceName)) { + Files.copy(is, dir.resolve(fileName)); + } + } +} diff --git a/allure-generator/src/test/resources/allure3/after-fixture-1-allure.json b/allure-generator/src/test/resources/allure3/after-fixture-1-allure.json new file mode 100644 index 000000000..c39a2c944 --- /dev/null +++ b/allure-generator/src/test/resources/allure3/after-fixture-1-allure.json @@ -0,0 +1,60 @@ +{ + "type": "tearDown", + "uuid": "2c9da56d-879e-4446-b706-674a3fe4edfd", + "name": "tearDown1", + "fullName": "io.qameta.allure.test.Test.tearDown1", + "historyId": "bd56949bc637e11769b2ddac95b1e548", + "start": 1518966399039, + "stop": 1518966399039, + "description": "", + "stage": "finished", + "status": "passed", + "flaky": false, + "muted": false, + "known": false, + "steps": [], + "attachments": [], + "parameters": [], + "labels": [ + { + "name": "package", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "tag", + "value": "All" + }, + { + "name": "host", + "value": "host" + }, + { + "name": "suite", + "value": "My suite" + }, + { + "name": "epic", + "value": "TestNG integration" + }, + { + "name": "testClass", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "subSuite", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "thread", + "value": "6795@host.Test worker(11)" + }, + { + "name": "testMethod", + "value": "tearDown" + } + ], + "links": [], + "children": [ + "0c135085-9c26-4b2e-9064-b25a881f49e4" + ] +} \ No newline at end of file diff --git a/allure-generator/src/test/resources/allure3/after-fixture-2-allure.json b/allure-generator/src/test/resources/allure3/after-fixture-2-allure.json new file mode 100644 index 000000000..8a8baa5d3 --- /dev/null +++ b/allure-generator/src/test/resources/allure3/after-fixture-2-allure.json @@ -0,0 +1,66 @@ +{ + "type": "tearDown", + "uuid": "3e63d110-ba12-42f5-8aad-13dbd22aa473", + "name": "tearDown2", + "fullName": "io.qameta.allure.test.Test.tearDown2", + "historyId": "bd56949bc637e11769b2ddac95b1e548", + "start": 1518966398864, + "stop": 1518966398864, + "description": "", + "stage": "finished", + "status": "passed", + "flaky": false, + "muted": false, + "known": false, + "steps": [], + "attachments": [ + { + "name": "String attachment in after", + "source": "after-sample-attachment.txt", + "contentType": "text/plain" + } + ], + "parameters": [], + "labels": [ + { + "name": "package", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "tag", + "value": "All" + }, + { + "name": "host", + "value": "host" + }, + { + "name": "suite", + "value": "My suite" + }, + { + "name": "epic", + "value": "TestNG integration" + }, + { + "name": "testClass", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "subSuite", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "thread", + "value": "6795@host.Test worker(11)" + }, + { + "name": "testMethod", + "value": "tearDown" + } + ], + "links": [], + "children": [ + "0c135085-9c26-4b2e-9064-b25a881f49e4" + ] +} \ No newline at end of file diff --git a/allure-generator/src/test/resources/allure3/after-sample-attachment.txt b/allure-generator/src/test/resources/allure3/after-sample-attachment.txt new file mode 100644 index 000000000..7850d1107 --- /dev/null +++ b/allure-generator/src/test/resources/allure3/after-sample-attachment.txt @@ -0,0 +1 @@ +After sample attachment \ No newline at end of file diff --git a/allure-generator/src/test/resources/allure3/before-fixture-1-allure.json b/allure-generator/src/test/resources/allure3/before-fixture-1-allure.json new file mode 100644 index 000000000..a765106d3 --- /dev/null +++ b/allure-generator/src/test/resources/allure3/before-fixture-1-allure.json @@ -0,0 +1,60 @@ +{ + "type": "setUp", + "uuid": "0f596612-e5be-41ba-9fcb-416c3686b09a", + "name": "Configure TestNG engine 1", + "fullName": "io.qameta.allure.test.Test.prepare1", + "historyId": "bd56949bc637e11769b2ddac95b1e548", + "start": 1518966397437, + "stop": 1518966397437, + "description": "Configure TestNG engine", + "stage": "finished", + "status": "passed", + "flaky": false, + "muted": false, + "known": false, + "steps": [], + "attachments": [], + "parameters": [], + "labels": [ + { + "name": "package", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "tag", + "value": "All" + }, + { + "name": "host", + "value": "host" + }, + { + "name": "suite", + "value": "My suite" + }, + { + "name": "epic", + "value": "TestNG integration" + }, + { + "name": "testClass", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "subSuite", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "thread", + "value": "6795@host.Test worker(11)" + }, + { + "name": "testMethod", + "value": "prepare" + } + ], + "links": [], + "children": [ + "0c135085-9c26-4b2e-9064-b25a881f49e4" + ] +} \ No newline at end of file diff --git a/allure-generator/src/test/resources/allure3/before-fixture-2-allure.json b/allure-generator/src/test/resources/allure3/before-fixture-2-allure.json new file mode 100644 index 000000000..24374d948 --- /dev/null +++ b/allure-generator/src/test/resources/allure3/before-fixture-2-allure.json @@ -0,0 +1,60 @@ +{ + "type": "setUp", + "uuid": "1a5d1912-bcdc-432c-a727-68d20de37deb", + "name": "Configure TestNG engine 2", + "fullName": "io.qameta.allure.test.Test.prepare2", + "historyId": "bd56949bc637e11769b2ddac95b1e548", + "start": 1518966399004, + "stop": 1518966399004, + "description": "Configure TestNG engine", + "stage": "finished", + "status": "passed", + "flaky": false, + "muted": false, + "known": false, + "steps": [], + "attachments": [], + "parameters": [], + "labels": [ + { + "name": "package", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "tag", + "value": "All" + }, + { + "name": "host", + "value": "host" + }, + { + "name": "suite", + "value": "My suite" + }, + { + "name": "epic", + "value": "TestNG integration" + }, + { + "name": "testClass", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "subSuite", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "thread", + "value": "thread" + }, + { + "name": "testMethod", + "value": "prepare2" + } + ], + "links": [], + "children": [ + "0c135085-9c26-4b2e-9064-b25a881f49e4" + ] +} \ No newline at end of file diff --git a/allure-generator/src/test/resources/allure3/duplicated-params-allure.json b/allure-generator/src/test/resources/allure3/duplicated-params-allure.json new file mode 100644 index 000000000..996d5c2f7 --- /dev/null +++ b/allure-generator/src/test/resources/allure3/duplicated-params-allure.json @@ -0,0 +1,93 @@ +{ + "type": "test", + "uuid": "0c135085-9c26-4b2e-9064-b25a881f49e4", + "name": "Before test fixtures tests", + "fullName": "io.qameta.allure.test.Test.beforeTestFixtures", + "historyId": "bd56949bc637e11769b2ddac95b1e548", + "start": 1518966397467, + "stop": 1518966397490, + "description": "Before test fixtures tests", + "stage": "finished", + "status": "passed", + "flaky": false, + "muted": false, + "known": false, + "steps" : [ { + "status" : "passed", + "name" : "someSimpleStep", + "start" : 1518966397468, + "stop" : 1518966397487, + "attachments" : [ { + "name" : "String attachment in test", + "source" : "test-sample-attachment.txt", + "contentType" : "text/plain" + }] + }], + "attachments": [], + "parameters": [{ + "name": "name", + "value": "value" + },{ + "name": "name", + "value": "value" + },{ + "name": "name", + "value": "value2" + },{ + "name": "name2", + "value": "value" + },{ + "name": "name2", + "value": "value2" + }], + "labels": [ + { + "name": "package", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "tag", + "value": "All" + }, + { + "name": "host", + "value": "host" + }, + { + "name": "testMethod", + "value": "beforeTestFixtures" + }, + { + "name": "suite", + "value": "My suite" + }, + { + "name": "epic", + "value": "TestNG integration" + }, + { + "name": "testClass", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "subSuite", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "thread", + "value": "6795@host.Test worker(11)" + }, + { + "name": "feature", + "value": "Basic framework support" + } + ], + "links": [ + { + "name": "67", + "url": "https://github.com/allure-framework/allure-java/issues/67", + "type": "issue" + } + ], + "children": [] +} \ No newline at end of file diff --git a/allure-generator/src/test/resources/allure3/invalid-status-allure.json b/allure-generator/src/test/resources/allure3/invalid-status-allure.json new file mode 100644 index 000000000..efb983bd4 --- /dev/null +++ b/allure-generator/src/test/resources/allure3/invalid-status-allure.json @@ -0,0 +1,8 @@ +{ + "type": "test", + "uuid": "93542b02b4f3b5c69033c3643e0428ed", + "status": "some-invalid-string", + "name": "shouldCreate", + "start": 1479552611395, + "stop": 1479552611399 +} \ No newline at end of file diff --git a/allure-generator/src/test/resources/allure3/no-status-allure.json b/allure-generator/src/test/resources/allure3/no-status-allure.json new file mode 100644 index 000000000..398b8a381 --- /dev/null +++ b/allure-generator/src/test/resources/allure3/no-status-allure.json @@ -0,0 +1,7 @@ +{ + "type": "test", + "uuid": "93542b02b4f3b5c69033c3643e0428ed", + "name": "shouldCreate", + "start": 1479552611395, + "stop": 1479552611399 +} \ No newline at end of file diff --git a/allure-generator/src/test/resources/allure3/null-status-allure.json b/allure-generator/src/test/resources/allure3/null-status-allure.json new file mode 100644 index 000000000..5a806a8bb --- /dev/null +++ b/allure-generator/src/test/resources/allure3/null-status-allure.json @@ -0,0 +1,8 @@ +{ + "type": "test", + "uuid": "93542b02b4f3b5c69033c3643e0428ed", + "status": null, + "name": "shouldCreate", + "start": 1479552611395, + "stop": 1479552611399 +} \ No newline at end of file diff --git a/allure-generator/src/test/resources/allure3/other-testcase-allure.json b/allure-generator/src/test/resources/allure3/other-testcase-allure.json new file mode 100644 index 000000000..6781fb58e --- /dev/null +++ b/allure-generator/src/test/resources/allure3/other-testcase-allure.json @@ -0,0 +1,15 @@ +{ + "type": "test", + "uuid": "0c135085-9c26-4b2e-9064-b25a881f49e4", + "name": "Before test fixtures tests", + "fullName": "io.qameta.allure.test.Test.beforeTestFixtures", + "historyId": "bd56949bc637e11769b2ddac95b1e548", + "start": 1518966397467, + "stop": 1518966397490, + "description": "Before test fixtures tests", + "stage": "finished", + "status": "passed", + "flaky": false, + "muted": false, + "known": false +} \ No newline at end of file diff --git a/allure-generator/src/test/resources/allure3/simple-testcase-allure.json b/allure-generator/src/test/resources/allure3/simple-testcase-allure.json new file mode 100644 index 000000000..06371869d --- /dev/null +++ b/allure-generator/src/test/resources/allure3/simple-testcase-allure.json @@ -0,0 +1,78 @@ +{ + "type": "test", + "uuid": "0c135085-9c26-4b2e-9064-b25a881f49e4", + "name": "Before test fixtures tests", + "fullName": "io.qameta.allure.test.Test.beforeTestFixtures", + "historyId": "bd56949bc637e11769b2ddac95b1e548", + "start": 1518966397467, + "stop": 1518966397490, + "description": "Before test fixtures tests", + "stage": "finished", + "status": "passed", + "flaky": false, + "muted": false, + "known": false, + "steps" : [ { + "status" : "passed", + "name" : "someSimpleStep", + "start" : 1518966397468, + "stop" : 1518966397487, + "attachments" : [ { + "name" : "String attachment in test", + "source" : "test-sample-attachment.txt", + "contentType" : "text/plain" + }] + }], + "attachments": [], + "parameters": [], + "labels": [ + { + "name": "package", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "tag", + "value": "All" + }, + { + "name": "host", + "value": "host" + }, + { + "name": "testMethod", + "value": "beforeTestFixtures" + }, + { + "name": "suite", + "value": "My suite" + }, + { + "name": "epic", + "value": "TestNG integration" + }, + { + "name": "testClass", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "subSuite", + "value": "io.qameta.allure.test.Test" + }, + { + "name": "thread", + "value": "6795@host.Test worker(11)" + }, + { + "name": "feature", + "value": "Basic framework support" + } + ], + "links": [ + { + "name": "67", + "url": "https://github.com/allure-framework/allure-java/issues/67", + "type": "issue" + } + ], + "children": [] +} \ No newline at end of file diff --git a/allure-generator/src/test/resources/allure3/test-sample-attachment.txt b/allure-generator/src/test/resources/allure3/test-sample-attachment.txt new file mode 100644 index 000000000..93509c8f0 --- /dev/null +++ b/allure-generator/src/test/resources/allure3/test-sample-attachment.txt @@ -0,0 +1 @@ +Test sample attachments! \ No newline at end of file diff --git a/build.gradle b/build.gradle index c35bef745..cf5481dc7 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ description = 'Allure Report' buildscript { repositories { + mavenLocal() jcenter() maven { url 'https://plugins.gradle.org/m2/' } } @@ -90,6 +91,7 @@ allprojects { dependency 'commons-io:commons-io:2.6' dependency 'io.qameta.allure:allure-java-commons:2.0-BETA21' dependency 'io.qameta.allure:allure2-model-api:1.0-BETA4' + dependency 'io.qameta.allure:allure-model:2.0-SNAPSHOT' dependency 'javax.xml.bind:jaxb-api:2.3.0' dependency 'junit:junit:4.12' dependency 'org.allurefw:allure1-model:1.0' @@ -111,6 +113,7 @@ allprojects { } repositories { + mavenLocal() jcenter() } }