Skip to content

Commit

Permalink
add support for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
baev committed Oct 26, 2023
1 parent 12f8842 commit 55fc310
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.spockframework.runtime.model.MethodInfo;
import org.spockframework.runtime.model.MethodKind;
import org.spockframework.runtime.model.SpecInfo;
import org.spockframework.runtime.model.TestTag;

import java.lang.reflect.Method;
import java.security.MessageDigest;
Expand Down Expand Up @@ -185,6 +186,12 @@ public void beforeIteration(final IterationInfo iteration) {
labels.add(createParentSuiteLabel(superSpec.getName()));
}

final List<Label> testTags = feature.getTestTags().stream()
.map(TestTag::getValue)
.map(ResultsUtils::createTagLabel)
.collect(Collectors.toList());

labels.addAll(testTags);
labels.addAll(featureLabels);
labels.addAll(specLabels);
labels.addAll(getProvidedLabels());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import io.qameta.allure.spock2.samples.OneTest;
import io.qameta.allure.spock2.samples.ParametersTest;
import io.qameta.allure.spock2.samples.SpecFixtures;
import io.qameta.allure.spock2.samples.SpockTags;
import io.qameta.allure.spock2.samples.StepsAndBlocks;
import io.qameta.allure.spock2.samples.TestWithAnnotations;
import io.qameta.allure.spock2.samples.TestWithAnnotationsOnClass;
Expand Down Expand Up @@ -219,6 +220,19 @@ void shouldProcessMethodAnnotations() {
);
}

@Test
void shouldProcessSpockTags() {
final AllureResults results = runClasses(SpockTags.class);
assertThat(results.getTestResults())
.hasSize(1)
.flatExtracting(TestResult::getLabels)
.extracting(Label::getName, Label::getValue)
.contains(
tuple("tag", "first"),
tuple("tag", "second")
);
}

@Test
void shouldProcessClassAnnotations() {
final AllureResults results = runClasses(TestWithAnnotationsOnClass.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2019 Qameta Software OÜ
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.qameta.allure.spock2.samples

import spock.lang.Specification
import spock.lang.Tag

/**
* @author charlie (Dmitry Baev).
*/
class SpockTags extends Specification {

@Tag("first")
@Tag("second")
def "someTest"() {
expect:
true
}
}

0 comments on commit 55fc310

Please sign in to comment.