use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ in project agent-java-junit5 by reportportal.
the class ReportPortalExtension method buildStartStepRq.
/**
* Extension point to customize test step creation event/request
*
* @param context JUnit's test context
* @param arguments a test arguments list
* @param itemType a test method item type
* @param description a test method description
* @param startTime a start time of the test
* @return Request to ReportPortal
*/
@Nonnull
protected StartTestItemRQ buildStartStepRq(@Nonnull final ExtensionContext context, @Nonnull final List<Object> arguments, @Nonnull final ItemType itemType, @Nonnull final String description, @Nonnull final Date startTime) {
StartTestItemRQ rq = new StartTestItemRQ();
rq.setStartTime(startTime);
rq.setName(createStepName(context));
rq.setDescription(description);
rq.setUniqueId(context.getUniqueId());
rq.setType(itemType == TEMPLATE ? SUITE.name() : itemType.name());
String codeRef = getCodeRef(context);
rq.setCodeRef(codeRef);
rq.setAttributes(context.getTags().stream().map(it -> new ItemAttributesRQ(null, it)).collect(Collectors.toSet()));
if (SUITE == itemType) {
context.getTestClass().ifPresent(c -> rq.getAttributes().addAll(getAttributes(c)));
}
Optional<Method> testMethod = getTestMethod(context);
TestCaseIdEntry caseId = testMethod.map(m -> {
rq.getAttributes().addAll(getAttributes(m));
rq.setParameters(getParameters(m, arguments));
return getTestCaseId(m, codeRef, arguments, context.getTestInstance().orElse(null));
}).orElseGet(() -> TestCaseIdUtils.getTestCaseId(codeRef, arguments));
rq.setTestCaseId(ofNullable(caseId).map(TestCaseIdEntry::getId).orElse(null));
return rq;
}
use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ in project agent-java-junit5 by reportportal.
the class SystemAttributesFetcher method skippedAnIssue.
private static ItemAttributesRQ skippedAnIssue(Boolean fromParams) {
ItemAttributesRQ skippedIssueAttr = new ItemAttributesRQ();
skippedIssueAttr.setKey(SKIPPED_ISSUE_KEY);
skippedIssueAttr.setValue(fromParams == null ? "true" : fromParams.toString());
skippedIssueAttr.setSystem(true);
return skippedIssueAttr;
}
use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ in project allure-java by reportportal.
the class AnnotationUtils method processFlaky.
public static void processFlaky(@Nonnull StartTestItemRQ rq, @Nullable Method source) {
ofNullable(source).ifPresent(s -> {
Flaky annotation = ofNullable(s.getAnnotation(Flaky.class)).orElseGet(() -> source.getDeclaringClass().getAnnotation(Flaky.class));
if (annotation != null) {
ItemAttributesRQ attribute = new ItemAttributesRQ(Flaky.class.getSimpleName().toLowerCase(Locale.ROOT));
Set<ItemAttributesRQ> attributes = retrieveAttributes(rq);
attributes.add(attribute);
}
});
}
use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ in project allure-java by reportportal.
the class LabelAnnotationTest method test_attributes_should_contain_attached_labels.
@Test
public void test_attributes_should_contain_attached_labels() {
TestNG result = runTests(TestMyFirstFeature.class);
assertThat(result.getStatus(), equalTo(0));
// Start launch
verify(client).startLaunch(any());
// Start parent suites
verify(client).startTestItem(any());
ArgumentCaptor<StartTestItemRQ> startTestCapture = ArgumentCaptor.forClass(StartTestItemRQ.class);
// Start test class
verify(client).startTestItem(same(suitedUuid), startTestCapture.capture());
ArgumentCaptor<StartTestItemRQ> startMethodCapture = ArgumentCaptor.forClass(StartTestItemRQ.class);
// Start test step
verify(client).startTestItem(same(testClassUuid), startMethodCapture.capture());
Set<ItemAttributesRQ> attributes = startTestCapture.getValue().getAttributes();
assertThat(attributes, hasSize(1));
assertThat(attributes.iterator().next(), allOf(hasProperty("key", equalTo("feature")), hasProperty("value", equalTo("My feature"))));
attributes = startMethodCapture.getValue().getAttributes();
assertThat(attributes, hasSize(1));
assertThat(attributes.iterator().next(), allOf(hasProperty("key", equalTo("story")), hasProperty("value", equalTo("My story 1"))));
}
use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ in project allure-java by reportportal.
the class ScenarioMetaTest method verify_a_scenario_with_meta_attributes.
@Test
public void verify_a_scenario_with_meta_attributes() {
run(format, STORY_PATH, new EmptySteps());
ArgumentCaptor<StartTestItemRQ> startCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
verify(client).startTestItem(startCaptor.capture());
verify(client).startTestItem(same(storyId), startCaptor.capture());
verify(client).startTestItem(same(scenarioId), any());
List<StartTestItemRQ> items = startCaptor.getAllValues();
StartTestItemRQ startSuite = items.get(0);
assertThat(startSuite.getAttributes(), empty());
StartTestItemRQ startScenario = items.get(1);
assertThat(startScenario.getAttributes(), allOf(notNullValue(), hasSize(STEP_ATTRIBUTES.size())));
Set<ItemAttributesRQ> scenarioAttributes = startScenario.getAttributes();
scenarioAttributes.forEach(a -> assertThat(STEP_ATTRIBUTES, hasItem(Pair.of(a.getKey(), a.getValue()))));
}
Aggregations