Search in sources :

Example 16 with ReportPortal

use of com.epam.reportportal.service.ReportPortal in project agent-java-testNG by reportportal.

the class StepReporterTest method initMocks.

@BeforeEach
public void initMocks() {
    mockLaunch(client, "launchUuid", suitedUuid, testClassUuid, testMethodUuid);
    ReportPortal reportPortal = ReportPortal.create(client, standardParameters());
    TestNgListener.initReportPortal(reportPortal);
}
Also used : ReportPortal(com.epam.reportportal.service.ReportPortal) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 17 with ReportPortal

use of com.epam.reportportal.service.ReportPortal in project agent-java-testNG by reportportal.

the class TestWithRetryWithStepsAndDependentMethodTest method initMocks.

@BeforeEach
public void initMocks() {
    mockLaunch(client, namedUuid("launchUuid"), suitedUuid, testClassUuid, testUuidList);
    TestUtils.mockNestedSteps(client, testStepUuidOrder);
    ReportPortal reportPortal = ReportPortal.create(client, standardParameters());
    TestListener.initReportPortal(reportPortal);
}
Also used : ReportPortal(com.epam.reportportal.service.ReportPortal) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 18 with ReportPortal

use of com.epam.reportportal.service.ReportPortal in project agent-java-junit5 by reportportal.

the class ReportPortalExtension method getLaunch.

/**
 * Returns a current launch instance, starts new if no such instance
 *
 * @param context JUnit's launch context
 * @return represents current launch
 */
protected Launch getLaunch(ExtensionContext context) {
    return launchMap.computeIfAbsent(getLaunchId(context), id -> {
        ReportPortal rp = getReporter();
        ListenerParameters params = rp.getParameters();
        StartLaunchRQ rq = buildStartLaunchRq(params);
        Launch launch = rp.newLaunch(rq);
        Runtime.getRuntime().addShutdownHook(getShutdownHook(id));
        Maybe<String> launchIdResponse = launch.start();
        if (params.isCallbackReportingEnabled()) {
            TEST_ITEM_TREE.setLaunchId(launchIdResponse);
        }
        return launch;
    });
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) ReportPortal(com.epam.reportportal.service.ReportPortal) Launch(com.epam.reportportal.service.Launch)

Example 19 with ReportPortal

use of com.epam.reportportal.service.ReportPortal 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;
}
Also used : java.util(java.util) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) Launch(com.epam.reportportal.service.Launch) com.epam.ta.reportportal.ws.model(com.epam.ta.reportportal.ws.model) Maybe(io.reactivex.Maybe) LoggerFactory(org.slf4j.LoggerFactory) ReportPortal(com.epam.reportportal.service.ReportPortal) AttributeParser(com.epam.reportportal.utils.AttributeParser) TestCaseId(com.epam.reportportal.annotations.TestCaseId) TestItemTree(com.epam.reportportal.service.tree.TestItemTree) StringUtils(org.apache.commons.lang3.StringUtils) TestCaseIdEntry(com.epam.reportportal.service.item.TestCaseIdEntry) SystemAttributesFetcher.collectSystemAttributes(com.epam.reportportal.junit5.SystemAttributesFetcher.collectSystemAttributes) Attributes(com.epam.reportportal.annotations.attribute.Attributes) TestCaseIdUtils(com.epam.reportportal.utils.TestCaseIdUtils) Nonnull(javax.annotation.Nonnull) Method(java.lang.reflect.Method) Nullable(javax.annotation.Nullable) ParameterUtils(com.epam.reportportal.utils.ParameterUtils) TestItemTree.createTestItemLeaf(com.epam.reportportal.service.tree.TestItemTree.createTestItemLeaf) Logger(org.slf4j.Logger) Optional.ofNullable(java.util.Optional.ofNullable) TestAbortedException(org.opentest4j.TestAbortedException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ExceptionUtils.getStackTrace(org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace) ItemStatus(com.epam.reportportal.listeners.ItemStatus) SaveLogRQ(com.epam.ta.reportportal.ws.model.log.SaveLogRQ) ParameterKey(com.epam.reportportal.annotations.ParameterKey) Collectors(java.util.stream.Collectors) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) org.junit.jupiter.api(org.junit.jupiter.api) ItemType(com.epam.reportportal.junit5.ItemType) org.junit.jupiter.api.extension(org.junit.jupiter.api.extension) ItemTreeUtils.createItemTreeKey(com.epam.reportportal.junit5.utils.ItemTreeUtils.createItemTreeKey) AnnotatedElement(java.lang.reflect.AnnotatedElement) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) Method(java.lang.reflect.Method) TestCaseIdEntry(com.epam.reportportal.service.item.TestCaseIdEntry) Nonnull(javax.annotation.Nonnull)

Example 20 with ReportPortal

use of com.epam.reportportal.service.ReportPortal in project allure-java by reportportal.

the class DescriptionAnnotationTest method initMocks.

@BeforeEach
public void initMocks() {
    mockLaunch(client, namedUuid("launchUuid"), suitedUuid, testClassUuid, stepUuids);
    ReportPortal reportPortal = ReportPortal.create(client, standardParameters());
    TestNgListener.REPORT_PORTAL_THREAD_LOCAL.set(reportPortal);
}
Also used : ReportPortal(com.epam.reportportal.service.ReportPortal) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ReportPortal (com.epam.reportportal.service.ReportPortal)24 BeforeEach (org.junit.jupiter.api.BeforeEach)17 ListenerParameters (com.epam.reportportal.listeners.ListenerParameters)7 StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)4 SaveLogRQ (com.epam.ta.reportportal.ws.model.log.SaveLogRQ)4 Launch (com.epam.reportportal.service.Launch)3 ParameterKey (com.epam.reportportal.annotations.ParameterKey)2 TestCaseId (com.epam.reportportal.annotations.TestCaseId)2 Attributes (com.epam.reportportal.annotations.attribute.Attributes)2 ItemType (com.epam.reportportal.junit5.ItemType)2 SystemAttributesFetcher.collectSystemAttributes (com.epam.reportportal.junit5.SystemAttributesFetcher.collectSystemAttributes)2 ItemTreeUtils.createItemTreeKey (com.epam.reportportal.junit5.utils.ItemTreeUtils.createItemTreeKey)2 ItemStatus (com.epam.reportportal.listeners.ItemStatus)2 TestCaseIdEntry (com.epam.reportportal.service.item.TestCaseIdEntry)2 TestItemTree (com.epam.reportportal.service.tree.TestItemTree)2 TestItemTree.createTestItemLeaf (com.epam.reportportal.service.tree.TestItemTree.createTestItemLeaf)2 AttributeParser (com.epam.reportportal.utils.AttributeParser)2 ParameterUtils (com.epam.reportportal.utils.ParameterUtils)2 TestCaseIdUtils (com.epam.reportportal.utils.TestCaseIdUtils)2 com.epam.ta.reportportal.ws.model (com.epam.ta.reportportal.ws.model)2