Я хотел бы использовать приведенный ниже совет, упомянутый в документации, чтобы портал отчетов отображал последнюю трассировку стека при каждом сбое тестового случая. Однако, когда я пытаюсь работать с предоставленным примером кода, я не могу видеть, как определенные файлы разрешаются без контекста о том, как go об этом.
Например: - StartTestItemRQ
не имеет Любой getAttributes()
метод
Ниже приведена ошибка, которая не может быть устранена:
Set<ItemAttributesRQ> attributes = Optional.fromNullable(rq.getAttributes()).or(new HashSet<>());
Вот полный файл.
package core.reporting;
import com.epam.reportportal.testng.BaseTestNGListener;
import com.epam.reportportal.testng.TestNGService;
import com.epam.ta.reportportal.ws.model.FinishTestItemRQ;
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import org.testng.ITestResult;
import rp.com.google.common.base.Optional;
import rp.com.google.common.base.Throwables;
import java.util.HashSet;
import java.util.Set;
public class Reporting {
public static class ExtendedListener extends BaseTestNGListener {
public ExtendedListener() {
super(new ParamTaggingTestNgService());
}
@Override
public void onTestStart(ITestResult testResult) {
System.out.println(testResult.getMethod().getInvocationCount());
System.out.println(testResult.getMethod().getCurrentInvocationCount());
super.onTestStart(testResult);
}
}
public static class ParamTaggingTestNgService extends TestNGService {
@Override
protected StartTestItemRQ buildStartStepRq(ITestResult testResult) {
final StartTestItemRQ rq = super.buildStartStepRq(testResult);
if (testResult.getParameters() != null && testResult.getParameters().length != 0) {
Set<ItemAttributesRQ> attributes = Optional.fromNullable(rq.getAttributes()).or(new HashSet<>());
for (Object param : testResult.getParameters()) {
attributes.add(new ItemAttributesRQ(null, param.toString()));
}
rq.setAttributes(attributes);
}
return rq;
}
@Override
protected FinishTestItemRQ buildFinishTestMethodRq(String status, ITestResult testResult) {
FinishTestItemRQ finishTestItemRQ = super.buildFinishTestMethodRq(status, testResult);
if (testResult.getThrowable() != null) {
String description = "```error\n" + Throwables.getStackTraceAsString(testResult.getThrowable()) + "\n```";
description = description + Throwables.getStackTraceAsString(testResult.getThrowable());
finishTestItemRQ.setDescription(description);
}
return finishTestItemRQ;
}
}
}
Вот версии lib, которые Я использую.
compile group: 'com.epam.reportportal', name: 'agent-java-testng', version: '4.2.0'
compile group: 'com.epam.reportportal', name: 'logger-java-logback', version: '4.0.0'
Что мне здесь не хватает? Пожалуйста, помогите.