use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project agent-java-testNG by reportportal.
the class AttributeTest method verify_class_level_attributes_bypass.
@Test
public void verify_class_level_attributes_bypass() {
TestUtils.runTests(Collections.singletonList(TestReportPortalListener.class), ClassLevelAttributesTest.class);
// Start parent suite
verify(launch).startTestItem(any());
ArgumentCaptor<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
// Start test and step
verify(launch, times(2)).startTestItem(any(), captor.capture());
StartTestItemRQ testRequest = extractRequest(captor, "test");
assertThat(testRequest.getAttributes(), hasSize(1));
ItemAttributesRQ attribute = testRequest.getAttributes().iterator().next();
assertThat(attribute.getKey(), equalTo(ClassLevelAttributesTest.KEY));
assertThat(attribute.getValue(), equalTo(ClassLevelAttributesTest.VALUE));
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project agent-java-testNG by reportportal.
the class BuildStepTest method testRetryFlagPositive.
@Test
public void testRetryFlagPositive() {
when(testResult.getMethod()).thenReturn(testNGMethod);
when(testResult.wasRetried()).thenReturn(true);
when(testNGMethod.getConstructorOrMethod()).thenReturn(constructorOrMethod);
when(testNGMethod.isTest()).thenReturn(true);
StartTestItemRQ rq = testNGService.buildStartStepRq(testResult);
assertThat("Incorrect retry flag", rq.isRetry(), is(true));
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project agent-java-testNG by reportportal.
the class BuildStepTest method testCaseId_fromAnnotation.
@Test
public void testCaseId_fromAnnotation() {
when(testResult.getMethod()).thenReturn(testNGMethod);
when(testNGMethod.getConstructorOrMethod()).thenReturn(constructorOrMethod);
when(testNGMethod.isTest()).thenReturn(true);
Optional<Method> methodOptional = Arrays.stream(TestMethodsExamples.class.getDeclaredMethods()).filter(it -> it.getName().equals("testCaseId")).findFirst();
assertTrue(methodOptional.isPresent());
String expectedCodeRef = "com.test.BuildStepTest.codeRefTest";
when(constructorOrMethod.getMethod()).thenReturn(methodOptional.get());
when(testResult.getMethod().getQualifiedName()).thenReturn(expectedCodeRef);
StartTestItemRQ request = testNGService.buildStartStepRq(testResult);
assertEquals(expectedCodeRef, request.getCodeRef());
assertEquals("test-case-id", request.getTestCaseId());
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project agent-java-testNG by reportportal.
the class BuildStepTest method testMethodName.
@Test
public void testMethodName() {
when(testResult.getMethod()).thenReturn(testNGMethod);
when(testNGMethod.getConstructorOrMethod()).thenReturn(constructorOrMethod);
when(testNGMethod.isTest()).thenReturn(true);
when(testNGMethod.getMethodName()).thenReturn(DEFAULT_NAME);
StartTestItemRQ rq = testNGService.buildStartStepRq(testResult);
assertThat("Incorrect test item name", rq.getName(), is(DEFAULT_NAME));
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project agent-java-testNG by reportportal.
the class BuildStepTest method testParameters.
@Test
public void testParameters() {
when(testResult.getMethod()).thenReturn(testNGMethod);
when(testNGMethod.getConstructorOrMethod()).thenReturn(constructorOrMethod);
when(testNGMethod.isTest()).thenReturn(true);
Method[] methods = TestMethodsExamples.class.getDeclaredMethods();
Method method = null;
for (Method m : methods) {
if (m.getName().contains("parametersAnnotation")) {
method = m;
}
}
when(constructorOrMethod.getMethod()).thenReturn(method);
when(testResult.getParameters()).thenReturn(new Object[] { "param_0", "param_1" });
StartTestItemRQ rq = testNGService.buildStartStepRq(testResult);
assertThat("Incorrect parameter key", rq.getParameters().get(0).getKey(), is("message_0"));
assertThat("Incorrect parameter value", rq.getParameters().get(0).getValue(), is("param_0"));
assertThat("Incorrect parameter key", rq.getParameters().get(1).getKey(), is("message_1"));
assertThat("Incorrect parameter value", rq.getParameters().get(1).getValue(), is("param_1"));
}
Aggregations