Skip to content

Commit

Permalink
Merge pull request #124 from reportportal/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
HardNorth authored Mar 14, 2024
2 parents 07c4478 + 89e0ff8 commit 3018a21
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 37 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 1.8
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
Expand All @@ -47,4 +47,6 @@ jobs:
run: ./gradlew build

- name: Codecov upload
run: bash <(curl -s https://codecov.io/bash)
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Generate versions
uses: HardNorth/github-version-generate@v1
Expand All @@ -50,7 +50,7 @@ jobs:
version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }}

- name: Set up JDK 1.8
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:

- name: Checkout develop branch
if: ${{ github.ref }} == 'master'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: 'develop'
fetch-depth: 0
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog

## [Unreleased]
### Added
- `finishTest` method which controls finishing Tests with statuses, to distinguish them from suites and configuration methods, by @HardNorth
### Changed
- JUnit 5 dependency marked as `compileOnly` to avoid overriding JUnit 5 API version for users, by @HardNorth
- JSR 305 dependency marked as `implementation` to force users specify their own versions, by @HardNorth
- Client version updated on [5.2.5](https://github.com/reportportal/client-java/releases/tag/5.2.5), by @HardNorth
### Removed
- Setting of Unique ID on Test Step and Configuration start, as redundant action, by @HardNorth

## [5.2.1]
### Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A JUnit 5 reporter that uploads the results to a ReportPortal server.
[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/agent-java-junit5.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.epam.reportportal/agent-java-junit5)
[![CI Build](https://github.com/reportportal/agent-java-junit5/actions/workflows/ci.yml/badge.svg)](https://github.com/reportportal/agent-java-junit5/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/reportportal/agent-java-junit5/branch/develop/graph/badge.svg?token=tq832Jsqef)](https://codecov.io/gh/reportportal/agent-java-junit5)
[![Join Slack chat!](https://slack.epmrpp.reportportal.io/badge.svg)](https://slack.epmrpp.reportportal.io/)
[![Join Slack chat!](https://img.shields.io/badge/slack-join-brightgreen.svg)](https://slack.epmrpp.reportportal.io/)
[![stackoverflow](https://img.shields.io/badge/reportportal-stackoverflow-orange.svg?style=flat)](http://stackoverflow.com/questions/tagged/reportportal)
[![Build with Love](https://img.shields.io/badge/build%20with-❤%EF%B8%8F%E2%80%8D-lightgrey.svg)](http://reportportal.io?style=flat)

Expand Down
2 changes: 1 addition & 1 deletion README_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A JUnit 5 reporter that uploads the results to a ReportPortal server.
[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/agent-java-junit5.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.epam.reportportal/agent-java-junit5)
[![CI Build](https://github.com/reportportal/agent-java-junit5/actions/workflows/ci.yml/badge.svg)](https://github.com/reportportal/agent-java-junit5/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/reportportal/agent-java-junit5/branch/develop/graph/badge.svg?token=tq832Jsqef)](https://codecov.io/gh/reportportal/agent-java-junit5)
[![Join Slack chat!](https://slack.epmrpp.reportportal.io/badge.svg)](https://slack.epmrpp.reportportal.io/)
[![Join Slack chat!](https://img.shields.io/badge/slack-join-brightgreen.svg)](https://slack.epmrpp.reportportal.io/)
[![stackoverflow](https://img.shields.io/badge/reportportal-stackoverflow-orange.svg?style=flat)](http://stackoverflow.com/questions/tagged/reportportal)
[![Build with Love](https://img.shields.io/badge/build%20with-❤%EF%B8%8F%E2%80%8D-lightgrey.svg)](http://reportportal.io?style=flat)

Expand Down
17 changes: 7 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,21 @@ repositories {
}

dependencies {
api 'com.epam.reportportal:client-java:5.2.4'
api 'com.google.code.findbugs:jsr305:3.0.2'
api 'com.epam.reportportal:client-java:5.2.5'

implementation "org.junit.jupiter:junit-jupiter-api:${junit_version}"
compileOnly "org.junit.jupiter:junit-jupiter-api:${junit_version}"
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'org.slf4j:slf4j-api:2.0.7'

testImplementation 'com.epam.reportportal:agent-java-test-utils:0.0.2'

testImplementation ("org.junit.platform:junit-platform-runner:${junit_runner_version}")
testImplementation "org.junit.jupiter:junit-jupiter-engine:${junit_version}"
testImplementation 'com.epam.reportportal:agent-java-test-utils:0.0.3'
testImplementation "org.junit.platform:junit-platform-runner:${junit_runner_version}" // We need runner for JUnit 4 compatibility tests
testImplementation "org.junit.jupiter:junit-jupiter-engine:${junit_version}" // Required for tests to run
testImplementation "org.junit.jupiter:junit-jupiter-params:${junit_version}"
testImplementation 'org.aspectj:aspectjweaver:1.9.19'
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.mockito:mockito-core:3.3.3'
testImplementation 'ch.qos.logback:logback-classic:1.3.12'
testImplementation ('com.epam.reportportal:logger-java-logback:5.2.0') {
exclude module: 'client-java'
}
testImplementation 'com.epam.reportportal:logger-java-logback:5.2.2'
testImplementation 'org.assertj:assertj-core:3.23.1'
testImplementation 'com.squareup.okhttp3:okhttp:4.12.0'
}
Expand Down
7 changes: 4 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
version=5.2.2-SNAPSHOT
version=5.3.0-SNAPSHOT
description=JUnit5 integration for ReportPortal
junit_version=5.9.1
junit_runner_version=1.9.1
junit_version=5.9.3
# We need runner for JUnit 4 compatibility tests
junit_runner_version=1.9.3
scripts_url=https://raw.githubusercontent.com/reportportal/gradle-scripts
scripts_branch=master
excludeTests=
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ public void interceptDynamicTest(Invocation<Void> invocation, DynamicTestInvocat
startTestItem(extensionContext, STEP);
try {
invocation.proceed();
finishTestItem(extensionContext, PASSED);
finishTest(extensionContext, PASSED);
} catch (Throwable throwable) {
finishTestItem(extensionContext, getExecutionStatus(throwable));
finishTest(extensionContext, getExecutionStatus(throwable));
throw throwable;
}
}
Expand All @@ -344,33 +344,25 @@ protected ItemStatus getExecutionStatus(@Nonnull final ExtensionContext context)
@Override
public void afterTestExecution(ExtensionContext context) {
finishTemplates(context);
finishTestItem(context, getExecutionStatus(context));
finishTest(context, getExecutionStatus(context));
}

@Override
public void testDisabled(ExtensionContext context, Optional<String> reason) {
if (Boolean.parseBoolean(System.getProperty("reportDisabledTests"))) {
String description = reason.orElse(createStepDescription(context));
startTestItem(context, Collections.emptyList(), STEP, description, Calendar.getInstance().getTime());
finishTestItem(context, SKIPPED);
finishTest(context, SKIPPED);
}
}

@Override
public void testSuccessful(ExtensionContext context) {
}

@Override
public void testAborted(ExtensionContext context, Throwable throwable) {
}

@Override
public void testFailed(ExtensionContext context, Throwable cause) {
context.getParent().ifPresent(parent -> {
if(failedClassInits.contains(parent)) {
startTestItem(context, STEP);
sendStackTraceToRP(cause);
finishTestItem(context, FAILED);
finishTest(context, FAILED);
}
});
}
Expand Down Expand Up @@ -554,6 +546,16 @@ protected void finishTestItem(@Nonnull final ExtensionContext context, @Nullable
finishTestItem(context, buildFinishTestItemRq(context, status));
}

/**
* Finishes a test in RP with a specific status, builds a finish request based on the status
*
* @param context JUnit's test context
* @param status a test execution status
*/
protected void finishTest(@Nonnull final ExtensionContext context, @Nullable final ItemStatus status) {
finishTestItem(context, buildFinishTestRq(context, status));
}

/**
* Finishes a test item in RP with a custom request
*
Expand Down Expand Up @@ -673,7 +675,6 @@ protected StartTestItemRQ buildStartStepRq(@Nonnull final ExtensionContext conte
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);
Expand Down Expand Up @@ -705,6 +706,7 @@ protected StartTestItemRQ buildStartStepRq(@Nonnull final ExtensionContext conte
* @return Request to ReportPortal
*/
@Nonnull
@SuppressWarnings("unused")
protected StartTestItemRQ buildStartConfigurationRq(@Nonnull Method method, @Nonnull ExtensionContext parentContext,
@Nonnull ExtensionContext context, @Nonnull ItemType itemType) {
StartTestItemRQ rq = new StartTestItemRQ();
Expand All @@ -717,8 +719,6 @@ protected StartTestItemRQ buildStartConfigurationRq(@Nonnull Method method, @Non
rq.setName(createConfigurationName(method.getDeclaringClass(), method));
rq.setDescription(createConfigurationDescription(method.getDeclaringClass(), method));
}
String uniqueId = parentContext.getUniqueId() + "/[method:" + method.getName() + "()]";
rq.setUniqueId(uniqueId);
ofNullable(context.getTags()).ifPresent(it -> rq.setAttributes(it.stream()
.map(tag -> new ItemAttributesRQ(null, tag))
.collect(Collectors.toSet())));
Expand All @@ -743,6 +743,22 @@ protected StartTestItemRQ buildStartConfigurationRq(@Nonnull Method method, @Non
protected void createSkippedSteps(ExtensionContext context, Throwable cause) {
}

/**
* Extension point to customize a test result on it's finish
*
* @param context JUnit's test context
* @param status a test item execution result
* @return Request to ReportPortal
*/
@SuppressWarnings("unused")
@Nonnull
protected FinishTestItemRQ buildFinishTestRq(@Nonnull ExtensionContext context, @Nullable ItemStatus status) {
FinishTestItemRQ rq = new FinishTestItemRQ();
ofNullable(status).ifPresent(s -> rq.setStatus(s.name()));
rq.setEndTime(Calendar.getInstance().getTime());
return rq;
}

/**
* Extension point to customize a test item result on it's finish
*
Expand Down
22 changes: 22 additions & 0 deletions src/main/resources/META-INF/aop-ajc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
~ Copyright 2024 EPAM Systems
~
~ 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.
-->

<aspectj>
<weaver options="-nowarn -Xset:weaveJavaPackages=false,weaveJavaxPackages=false" />
<aspects>
<aspect name="com.epam.reportportal.aspect.StepAspect"/>
</aspects>
</aspectj>

0 comments on commit 3018a21

Please sign in to comment.