use of com.epam.reportportal.service.Launch in project agent-java-junit5 by reportportal.
the class AttributesTest method verify_method_level_attributes.
@Test
public void verify_method_level_attributes() {
TestUtils.runClasses(MethodLevelAttributesTest.class);
Launch launch = AttributesTestExtension.LAUNCH;
ArgumentCaptor<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
// Start test
verify(launch).startTestItem(captor.capture());
// Start step
verify(launch).startTestItem(any(), captor.capture());
StartTestItemRQ testRequest = extractRequest(captor, "suite");
assertThat(testRequest.getAttributes(), anyOf(nullValue(), emptyIterable()));
StartTestItemRQ stepRequest = extractRequest(captor, "step");
assertThat(stepRequest.getAttributes(), hasSize(1));
ItemAttributesRQ attribute = stepRequest.getAttributes().iterator().next();
assertThat(attribute.getKey(), equalTo("myKey"));
assertThat(attribute.getValue(), equalTo("myValue"));
}
use of com.epam.reportportal.service.Launch in project agent-java-junit5 by reportportal.
the class TestCaseIdTest method testCaseIdFromCodeRefAndParamsTest.
@Test
void testCaseIdFromCodeRefAndParamsTest() {
TestUtils.runClasses(TestCaseIdFromCodeRefAndParamsTest.class);
String expectedCodeRef = "com.epam.reportportal.junit5.features.testcaseid.TestCaseIdFromCodeRefAndParamsTest.parametrized";
List<String> expected = IntStream.of(101, 0).mapToObj(it -> expectedCodeRef + "[" + it + "]").collect(Collectors.toList());
Launch launch = TestCaseIdExtension.LAUNCH;
// Start parent Suite
verify(launch, times(1)).startTestItem(any());
ArgumentCaptor<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
// Start a test
verify(launch, times(3)).startTestItem(notNull(), captor.capture());
List<StartTestItemRQ> requests = captor.getAllValues();
assertThat(requests.stream().map(e -> e.getType().toLowerCase()).collect(Collectors.toList()), hasItem("suite"));
List<String> actual = requests.stream().filter(it -> "step".equalsIgnoreCase(it.getType())).map(StartTestItemRQ::getTestCaseId).collect(Collectors.toList());
assertThat(actual, equalTo(expected));
}
use of com.epam.reportportal.service.Launch in project agent-java-junit5 by reportportal.
the class TestCaseIdTest method test_verify_test_case_id_supports_templating_with_self_reference.
@Test
void test_verify_test_case_id_supports_templating_with_self_reference() {
TestUtils.runClasses(TestCaseIdTemplateTest.class);
Launch launch = TestCaseIdExtension.LAUNCH;
// Start parent Suite
verify(launch, times(1)).startTestItem(any());
ArgumentCaptor<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
// Start a test
verify(launch, times(1)).startTestItem(notNull(), captor.capture());
StartTestItemRQ request = captor.getValue();
assertThat(request.getTestCaseId(), equalTo(TestCaseIdTemplateTest.TEST_CASE_ID_VALUE.replace("{this.FIELD}", TestCaseIdTemplateTest.FIELD)));
}
use of com.epam.reportportal.service.Launch in project agent-java-testNG by reportportal.
the class TestNGService method startTestSuite.
@Override
public void startTestSuite(ISuite suite) {
StartTestItemRQ rq = buildStartSuiteRq(suite);
Launch myLaunch = launch.get();
final Maybe<String> item = myLaunch.startTestItem(rq);
if (myLaunch.getParameters().isCallbackReportingEnabled()) {
addToTree(suite, item);
}
suite.setAttribute(RP_ID, item);
}
use of com.epam.reportportal.service.Launch in project agent-java-testNG by reportportal.
the class TestNGService method finishTestSuite.
@Override
public void finishTestSuite(ISuite suite) {
Maybe<String> rpId = getAttribute(suite, RP_ID);
Launch myLaunch = launch.get();
if (null != rpId) {
FinishTestItemRQ rq = buildFinishTestSuiteRq(suite);
myLaunch.finishTestItem(rpId, rq);
suite.removeAttribute(RP_ID);
}
if (myLaunch.getParameters().isCallbackReportingEnabled()) {
removeFromTree(suite);
}
}
Aggregations