-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[agent-reportportal] Migrate to ReportPortal agent-java-jbehave 5.1.1…
…; logger-java-log4j 5.1.3
- Loading branch information
Showing
16 changed files
with
480 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.Integrations | ||
* xref:azure-devops-exporter.adoc[Azure DevOps Exporter] | ||
* xref:reportportal.adoc | ||
* xref:xray-exporter.adoc[Xray Exporter] | ||
* xref:zephyr-exporter.adoc[Zephyr Exporter] | ||
* xref:docker.adoc[Docker] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
= Report Portal | ||
|
||
https://reportportal.io/[ReportPortal] is a test automation analytics platform and real-time reporting, powered by Machine Learning. | ||
|
||
== Installation | ||
|
||
.build.gradle | ||
[source,gradle,subs="attributes+"] | ||
---- | ||
implementation(group: 'org.vividus', name: 'agent-reportportal', version: '{current-version}') | ||
---- | ||
|
||
== Properties | ||
|
||
NOTE: The properties marked with bold are mandatory. | ||
|
||
[cols="4,3,2,6", options="header"] | ||
|=== | ||
|Property Name | ||
|Acceptable values | ||
|Default | ||
|Description | ||
|
||
|*system.rp.enable* | ||
|`true`/`false` | ||
|`false` | ||
|Enables reporting to the ReportPortal | ||
|
||
|*system.rp.endpoint* | ||
|URL | ||
|none | ||
|URL to the ReportPortal instance | ||
|
||
|*system.rp.uuid* | ||
|Access token from ReportPortal profile | ||
|none | ||
|Will be used to authenticate user | ||
|
||
|*system.rp.project* | ||
|Any string | ||
|none | ||
|Name of the project that will be used for launch reporting | ||
|
||
|*system.rp.launch* | ||
|Any string | ||
|none | ||
|The name of the launch, e.g. `SMOKE` | ||
|
||
|system.rp.description | ||
|Any string | ||
|none | ||
|Launch description | ||
|
||
|system.rp.test-entity | ||
|`SCENARIO`/`STEP` | ||
|`SCENARIO` | ||
|Defines what will be reported as a test case `SCENARIO` or `STEP` | ||
|
||
|system.rp.attributes | ||
|Semi-colon seprated values, e.g. `key:value; value;` | ||
|none | ||
|Attributes could be used for additional tagging of the launches | ||
|
||
|=== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...ain/java/org/vividus/reportportal/jbehave/AdaptedDelegatingReportPortalStoryReporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright 2019-2021 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.vividus.reportportal.jbehave; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
import com.epam.reportportal.jbehave.ReportPortalStoryReporter; | ||
import com.epam.reportportal.listeners.LogLevel; | ||
import com.epam.reportportal.service.ReportPortal; | ||
import com.epam.reportportal.service.tree.TestItemTree.TestItemLeaf; | ||
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; | ||
import com.google.common.eventbus.EventBus; | ||
import com.google.common.eventbus.Subscribe; | ||
|
||
import org.apache.commons.lang3.exception.ExceptionUtils; | ||
import org.jbehave.core.model.Scenario; | ||
import org.jbehave.core.model.Step; | ||
import org.jbehave.core.reporters.DelegatingStoryReporter; | ||
import org.jbehave.core.steps.Timing; | ||
import org.vividus.softassert.event.AssertionFailedEvent; | ||
|
||
public class AdaptedDelegatingReportPortalStoryReporter extends DelegatingStoryReporter | ||
{ | ||
private final ReportPortalStoryReporter reporter; | ||
private final List<TestItemLeaf> failedSteps = new ArrayList<>(); | ||
|
||
public AdaptedDelegatingReportPortalStoryReporter(EventBus eventBus, ReportPortalStoryReporter reporter) | ||
{ | ||
super(reporter); | ||
this.reporter = reporter; | ||
eventBus.register(this); | ||
} | ||
|
||
@Override | ||
public void beforeStep(Step step) | ||
{ | ||
runIfNotSystem(step.getStepAsString(), reporter::beforeStep); | ||
} | ||
|
||
@Override | ||
public void successful(String step) | ||
{ | ||
reporter.getLastStep() | ||
.map(failedSteps::remove) | ||
.filter(Boolean.TRUE::equals) | ||
.ifPresentOrElse(e -> reporter.failed(step, null), | ||
() -> runIfNotSystem(step, reporter::successful)); | ||
} | ||
|
||
private void runIfNotSystem(String step, Consumer<String> toRun) | ||
{ | ||
if (!step.contains("afterStories")) | ||
{ | ||
toRun.accept(step); | ||
} | ||
} | ||
|
||
@Override | ||
public void afterScenario(Timing timing) | ||
{ | ||
reporter.afterScenario(); | ||
} | ||
|
||
@Override | ||
public void scenarioExcluded(Scenario scenario, String filter) | ||
{ | ||
reporter.scenarioNotAllowed(scenario, filter); | ||
} | ||
|
||
@Subscribe | ||
public void onAssertionFailure(AssertionFailedEvent event) | ||
{ | ||
reporter.getLastStep().ifPresent(s -> { | ||
failedSteps.add(s); | ||
ReportPortal.emitLog(s.getItemId(), itemUuid -> { | ||
SaveLogRQ rq = new SaveLogRQ(); | ||
rq.setItemUuid(itemUuid); | ||
rq.setLevel(LogLevel.ERROR.name()); | ||
rq.setLogTime(new Date()); | ||
rq.setMessage(ExceptionUtils.getStackTrace(event.getSoftAssertionError().getError())); | ||
return rq; | ||
}); | ||
}); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
...eportportal/src/main/java/org/vividus/reportportal/jbehave/AdaptedReportPortalFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright 2019-2021 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.vividus.reportportal.jbehave; | ||
|
||
import java.util.function.BiFunction; | ||
import java.util.function.Supplier; | ||
|
||
import com.epam.reportportal.jbehave.ReportPortalFormat; | ||
import com.epam.reportportal.jbehave.ReportPortalScenarioStoryReporter; | ||
import com.epam.reportportal.jbehave.ReportPortalStepStoryReporter; | ||
import com.epam.reportportal.jbehave.ReportPortalStoryReporter; | ||
import com.epam.reportportal.service.Launch; | ||
import com.epam.reportportal.service.ReportPortal; | ||
import com.epam.reportportal.service.tree.TestItemTree; | ||
import com.google.common.eventbus.EventBus; | ||
|
||
import org.jbehave.core.reporters.FilePrintStreamFactory; | ||
import org.jbehave.core.reporters.StoryReporter; | ||
import org.jbehave.core.reporters.StoryReporterBuilder; | ||
|
||
public class AdaptedReportPortalFormat extends ReportPortalFormat | ||
{ | ||
private final EventBus eventBus; | ||
private TestEntity testEntity; | ||
|
||
public AdaptedReportPortalFormat(EventBus eventBus) | ||
{ | ||
super(ReportPortal.builder().build()); | ||
this.eventBus = eventBus; | ||
} | ||
|
||
@Override | ||
public StoryReporter createStoryReporter(FilePrintStreamFactory factory, StoryReporterBuilder storyReporterBuilder) | ||
{ | ||
return new AdaptedDelegatingReportPortalStoryReporter(eventBus, testEntity.buildReporter(launch, itemTree)); | ||
} | ||
|
||
@Override | ||
protected ReportPortalStoryReporter createReportPortalReporter(FilePrintStreamFactory factory, | ||
StoryReporterBuilder storyReporterBuilder) | ||
{ | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public void setTestEntity(TestEntity testEntity) | ||
{ | ||
this.testEntity = testEntity; | ||
} | ||
|
||
public enum TestEntity | ||
{ | ||
STEP(ReportPortalStepStoryReporter::new), | ||
SCENARIO(ReportPortalScenarioStoryReporter::new); | ||
|
||
private final BiFunction<Supplier<Launch>, TestItemTree, ReportPortalStoryReporter> factory; | ||
|
||
TestEntity(BiFunction<Supplier<Launch>, TestItemTree, ReportPortalStoryReporter> factory) | ||
{ | ||
this.factory = factory; | ||
} | ||
|
||
ReportPortalStoryReporter buildReporter(Supplier<Launch> launch, TestItemTree itemTree) | ||
{ | ||
return factory.apply(launch, itemTree); | ||
} | ||
} | ||
} |
30 changes: 0 additions & 30 deletions
30
...rtal/src/main/java/org/vividus/reportportal/jbehave/AdaptedReportPortalStoryReporter.java
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
...eportportal/src/main/java/org/vividus/reportportal/listener/AssertionFailureListener.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.