From 4ddcd84df61febb85952968f515f17f8b9a9d0cf Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Fri, 30 May 2025 18:38:30 +0300 Subject: [PATCH 1/8] Client version update --- CHANGELOG.md | 2 ++ build.gradle | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b64894e..39afa5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog ## [Unreleased] +### Changed +- Client version updated on [5.3.14](https://github.com/reportportal/client-java/releases/tag/5.3.14), by @HardNorth ## [5.4.2] ### Changed diff --git a/build.gradle b/build.gradle index 214c805..eaad148 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ repositories { } dependencies { - api 'com.epam.reportportal:client-java:5.3.12' + api 'com.epam.reportportal:client-java:5.3.14' implementation "io.cucumber:cucumber-gherkin:${project.cucumber_version}" implementation 'org.slf4j:slf4j-api:2.0.7' From 93ded560b7d4d2efa00f8f1d5e3b43ea420d8918 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Fri, 27 Jun 2025 13:45:50 +0300 Subject: [PATCH 2/8] Add SkipException test --- .../epam/reportportal/cucumber/HooksTest.java | 96 ++++++++++++++++--- .../integration/hooks/skip/EmptySteps.java | 49 ++++++++++ 2 files changed, 133 insertions(+), 12 deletions(-) create mode 100644 src/test/java/com/epam/reportportal/cucumber/integration/hooks/skip/EmptySteps.java diff --git a/src/test/java/com/epam/reportportal/cucumber/HooksTest.java b/src/test/java/com/epam/reportportal/cucumber/HooksTest.java index 591bbb4..9ca2a60 100644 --- a/src/test/java/com/epam/reportportal/cucumber/HooksTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/HooksTest.java @@ -19,15 +19,22 @@ import com.epam.reportportal.cucumber.integration.TestScenarioReporter; import com.epam.reportportal.cucumber.integration.TestStepReporter; import com.epam.reportportal.cucumber.integration.util.TestUtils; +import com.epam.reportportal.listeners.ItemStatus; import com.epam.reportportal.listeners.ListenerParameters; import com.epam.reportportal.service.ReportPortal; import com.epam.reportportal.service.ReportPortalClient; import com.epam.reportportal.util.test.CommonUtils; +import com.epam.ta.reportportal.ws.model.FinishExecutionRQ; +import com.epam.ta.reportportal.ws.model.FinishTestItemRQ; +import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; import io.cucumber.testng.AbstractTestNGCucumberTests; import io.cucumber.testng.CucumberOptions; +import okhttp3.MultipartBody; +import org.apache.commons.lang3.tuple.Pair; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; import java.util.List; import java.util.concurrent.ExecutorService; @@ -35,45 +42,62 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static com.epam.reportportal.cucumber.integration.util.TestUtils.filterLogs; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.contains; import static org.mockito.Mockito.*; +import static org.mockito.Mockito.any; /** - * TODO: finish the test + * TODO: finish unfinished tests */ public class HooksTest { @CucumberOptions(features = "src/test/resources/features/DummyScenario.feature", glue = { - "com.epam.reportportal.cucumber.integration.hooks.step" }, plugin = { "pretty", + "com.epam.reportportal.cucumber.integration.hooks.step" }, plugin = { "com.epam.reportportal.cucumber.integration.TestStepReporter" }) public static class StepHooksReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/DummyScenario.feature", glue = { - "com.epam.reportportal.cucumber.integration.hooks.scenario" }, plugin = { "pretty", + "com.epam.reportportal.cucumber.integration.hooks.scenario" }, plugin = { "com.epam.reportportal.cucumber.integration.TestStepReporter" }) public static class ScenarioHooksReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/DummyScenario.feature", glue = { - "com.epam.reportportal.cucumber.integration.hooks.all" }, plugin = { "pretty", + "com.epam.reportportal.cucumber.integration.hooks.all" }, plugin = { "com.epam.reportportal.cucumber.integration.TestStepReporter" }) public static class AllHooksReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/DummyScenario.feature", glue = { - "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", + "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "com.epam.reportportal.cucumber.integration.TestStepReporter" }) public static class NoHooksReporterTest extends AbstractTestNGCucumberTests { } + @CucumberOptions(features = "src/test/resources/features/DummyScenario.feature", glue = { + "com.epam.reportportal.cucumber.integration.hooks.skip" }, plugin = { + "com.epam.reportportal.cucumber.integration.TestScenarioReporter" }) + public static class SkipStepHooksReporterTest extends AbstractTestNGCucumberTests { + + } + private final String launchId = CommonUtils.namedId("launch_"); private final String suiteId = CommonUtils.namedId("suite_"); - private final String testId = CommonUtils.namedId("test_"); - private final List stepIds = Stream.generate(() -> CommonUtils.namedId("step_")).limit(3).collect(Collectors.toList()); + private final String featureId = CommonUtils.namedId("feature_"); + private final List scenarioIds = Stream.generate(() -> CommonUtils.namedId("scenario_")).limit(3).collect(Collectors.toList()); + private final List> steps = scenarioIds.stream() + .flatMap(s -> Stream.generate(() -> CommonUtils.namedId("step_")).limit(6).map(ns -> Pair.of(s, ns))) + .collect(Collectors.toList()); + + private final List stepIds = steps.stream().map(Pair::getValue).collect(Collectors.toList()); private final ListenerParameters params = TestUtils.standardParameters(); private final ReportPortalClient client = mock(ReportPortalClient.class); @@ -82,7 +106,8 @@ public static class NoHooksReporterTest extends AbstractTestNGCucumberTests { @BeforeEach public void setup() { - TestUtils.mockLaunch(client, launchId, suiteId, testId, stepIds); + TestUtils.mockLaunch(client, launchId, suiteId, featureId, scenarioIds); + TestUtils.mockNestedSteps(client, steps); TestUtils.mockLogging(client); TestScenarioReporter.RP.set(reportPortal); TestStepReporter.RP.set(reportPortal); @@ -100,7 +125,7 @@ public void verify_before_after_step_reported_in_steps() { verify(client, times(1)).startTestItem(any()); verify(client, times(1)).startTestItem(same(suiteId), any()); - verify(client, times(6)).startTestItem(same(testId), any()); + verify(client, times(6)).startTestItem(same(featureId), any()); verify(client, times(6)).log(any(List.class)); } @@ -111,7 +136,7 @@ public void verify_before_after_scenario_reported_in_steps() { verify(client, times(1)).startTestItem(any()); verify(client, times(1)).startTestItem(same(suiteId), any()); - verify(client, times(4)).startTestItem(same(testId), any()); + verify(client, times(4)).startTestItem(same(featureId), any()); verify(client, times(4)).log(any(List.class)); } @@ -124,7 +149,7 @@ public void verify_before_after_all_reported_in_steps() { verify(client, times(1)).startTestItem(same(suiteId), any()); // @BeforeAll and @AfterAll hooks does not emit any events, see: https://github.com/cucumber/cucumber-jvm/issues/2422 - verify(client, times(2)).startTestItem(same(testId), any()); + verify(client, times(2)).startTestItem(same(featureId), any()); verify(client, times(3)).log(any(List.class)); } @@ -135,9 +160,56 @@ public void verify_before_after_not_reported_in_steps() { verify(client, times(1)).startTestItem(any()); verify(client, times(1)).startTestItem(same(suiteId), any()); - verify(client, times(2)).startTestItem(same(testId), any()); + verify(client, times(2)).startTestItem(same(featureId), any()); verify(client, times(2)).log(any(List.class)); + } + @Test + @SuppressWarnings("unchecked") + public void verify_skip_exception_in_before_step_hook_reported_correctly() { + TestUtils.runTests(SkipStepHooksReporterTest.class); + + // Capture log entries + ArgumentCaptor> logCaptor = ArgumentCaptor.forClass(List.class); + verify(client, times(2)).log(logCaptor.capture()); + + // Verify the first "Before" step has reported single Log entry with ERROR level and "SkipException" with "Skipping test" message + List errorLogs = filterLogs( + logCaptor, + l -> l.getLevel() != null && l.getLevel().equals("ERROR") && l.getMessage() != null && l.getMessage() + .contains("SkipException") && l.getMessage().contains("Skipping test") + ); + assertThat(errorLogs, hasSize(1)); + SaveLogRQ skipExceptionLog = errorLogs.get(0); + assertThat(skipExceptionLog.getMessage(), containsString("SkipException")); + assertThat(skipExceptionLog.getMessage(), containsString("Skipping test")); + assertThat(skipExceptionLog.getLevel(), equalTo("ERROR")); + + // Verify step statuses - all main steps and Before should be SKIPPED, After should be PASSED + ArgumentCaptor stepsFinishCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class); + verify(client).finishTestItem(eq(stepIds.get(0)), stepsFinishCaptor.capture()); + verify(client).finishTestItem(eq(stepIds.get(1)), stepsFinishCaptor.capture()); + verify(client).finishTestItem(eq(stepIds.get(2)), stepsFinishCaptor.capture()); + verify(client).finishTestItem(eq(stepIds.get(3)), stepsFinishCaptor.capture()); + verify(client).finishTestItem(eq(stepIds.get(4)), stepsFinishCaptor.capture()); + verify(client).finishTestItem(eq(stepIds.get(5)), stepsFinishCaptor.capture()); + List finishSteps = stepsFinishCaptor.getAllValues(); + assertThat( + finishSteps.stream().map(FinishExecutionRQ::getStatus).collect(Collectors.toList()), + contains( + ItemStatus.SKIPPED.name(), + ItemStatus.SKIPPED.name(), + ItemStatus.PASSED.name(), + ItemStatus.SKIPPED.name(), + ItemStatus.SKIPPED.name(), + ItemStatus.SKIPPED.name() + ) + ); + + // Verify the Scenario finish event is reported as SKIPPED + ArgumentCaptor scenarioFinishCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class); + verify(client).finishTestItem(eq(scenarioIds.get(0)), scenarioFinishCaptor.capture()); + assertThat(scenarioFinishCaptor.getValue().getStatus(), equalTo(ItemStatus.SKIPPED.name())); } } diff --git a/src/test/java/com/epam/reportportal/cucumber/integration/hooks/skip/EmptySteps.java b/src/test/java/com/epam/reportportal/cucumber/integration/hooks/skip/EmptySteps.java new file mode 100644 index 0000000..8864043 --- /dev/null +++ b/src/test/java/com/epam/reportportal/cucumber/integration/hooks/skip/EmptySteps.java @@ -0,0 +1,49 @@ +/* + * Copyright 2021 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 + * + * http://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 com.epam.reportportal.cucumber.integration.hooks.skip; + +import io.cucumber.java.AfterStep; +import io.cucumber.java.BeforeStep; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.SkipException; + +public class EmptySteps { + private static final Logger LOGGER = LoggerFactory.getLogger(EmptySteps.class); + + @BeforeStep + public void my_before_step_hook() { + throw new SkipException("Skipping test"); + } + + @AfterStep + public void my_after_step_hook() { + LOGGER.info("Inside 'my_after_step_hook'"); + } + + @Given("I have empty step") + public void i_have_empty_step() { + LOGGER.info("Inside 'I have empty step'"); + } + + @Then("I have another empty step") + public void i_have_another_empty_step() { + LOGGER.info("Inside 'I have another empty step'"); + } +} From 8e3bfd1bfe8950fe11b8122b4374bcac6079d56f Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Fri, 27 Jun 2025 13:48:00 +0300 Subject: [PATCH 3/8] Fix test --- src/test/java/com/epam/reportportal/cucumber/HooksTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/epam/reportportal/cucumber/HooksTest.java b/src/test/java/com/epam/reportportal/cucumber/HooksTest.java index 9ca2a60..6849a5a 100644 --- a/src/test/java/com/epam/reportportal/cucumber/HooksTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/HooksTest.java @@ -196,7 +196,7 @@ public void verify_skip_exception_in_before_step_hook_reported_correctly() { List finishSteps = stepsFinishCaptor.getAllValues(); assertThat( finishSteps.stream().map(FinishExecutionRQ::getStatus).collect(Collectors.toList()), - contains( + containsInAnyOrder( ItemStatus.SKIPPED.name(), ItemStatus.SKIPPED.name(), ItemStatus.PASSED.name(), From 812bc3586c0dd8fd3465d99c6f8dfc95d84bf9a7 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Fri, 27 Jun 2025 13:48:17 +0300 Subject: [PATCH 4/8] Fix test --- src/test/java/com/epam/reportportal/cucumber/HooksTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/test/java/com/epam/reportportal/cucumber/HooksTest.java b/src/test/java/com/epam/reportportal/cucumber/HooksTest.java index 6849a5a..cf9902d 100644 --- a/src/test/java/com/epam/reportportal/cucumber/HooksTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/HooksTest.java @@ -45,7 +45,6 @@ import static com.epam.reportportal.cucumber.integration.util.TestUtils.filterLogs; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.hamcrest.Matchers.contains; import static org.mockito.Mockito.*; import static org.mockito.Mockito.any; @@ -195,8 +194,7 @@ public void verify_skip_exception_in_before_step_hook_reported_correctly() { verify(client).finishTestItem(eq(stepIds.get(5)), stepsFinishCaptor.capture()); List finishSteps = stepsFinishCaptor.getAllValues(); assertThat( - finishSteps.stream().map(FinishExecutionRQ::getStatus).collect(Collectors.toList()), - containsInAnyOrder( + finishSteps.stream().map(FinishExecutionRQ::getStatus).collect(Collectors.toList()), containsInAnyOrder( ItemStatus.SKIPPED.name(), ItemStatus.SKIPPED.name(), ItemStatus.PASSED.name(), From e969190defa4e5e733dd93e230b23e502effa46f Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Tue, 16 Sep 2025 16:14:06 +0300 Subject: [PATCH 5/8] Update client-java to 5.3.16 and ensure test-utils 0.0.13 Why: Align with latest client and keep test utilities consistent. --- CHANGELOG.md | 2 +- build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39afa5c..35ca236 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ## [Unreleased] ### Changed -- Client version updated on [5.3.14](https://github.com/reportportal/client-java/releases/tag/5.3.14), by @HardNorth +- Client version updated on [5.3.16](https://github.com/reportportal/client-java/releases/tag/5.3.16), by @HardNorth ## [5.4.2] ### Changed diff --git a/build.gradle b/build.gradle index eaad148..32cca88 100644 --- a/build.gradle +++ b/build.gradle @@ -39,14 +39,14 @@ repositories { } dependencies { - api 'com.epam.reportportal:client-java:5.3.14' + api 'com.epam.reportportal:client-java:5.3.16' implementation "io.cucumber:cucumber-gherkin:${project.cucumber_version}" implementation 'org.slf4j:slf4j-api:2.0.7' testImplementation 'com.squareup.okhttp3:okhttp:4.12.0' testImplementation "io.cucumber:cucumber-java:${project.cucumber_version}" - testImplementation 'com.epam.reportportal:agent-java-test-utils:0.0.7' + testImplementation 'com.epam.reportportal:agent-java-test-utils:0.0.13' testImplementation "io.cucumber:cucumber-testng:${project.cucumber_version}" testImplementation 'org.aspectj:aspectjweaver:1.9.19' testImplementation 'org.hamcrest:hamcrest-core:2.2' From 656ea8adc452682b1ab9e28fa0e6f7a2f4f4eebb Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Tue, 16 Sep 2025 16:19:35 +0300 Subject: [PATCH 6/8] Replace promote workflow with maven-publish; set artifact to agent-java-cucumber6 Why: Align with shared workflow and correct artifact naming. --- .github/workflows/maven-publish.yml | 33 ++++++++ .github/workflows/promote.yml | 112 ---------------------------- 2 files changed, 33 insertions(+), 112 deletions(-) create mode 100644 .github/workflows/maven-publish.yml delete mode 100644 .github/workflows/promote.yml diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml new file mode 100644 index 0000000..97a773a --- /dev/null +++ b/.github/workflows/maven-publish.yml @@ -0,0 +1,33 @@ +# Copyright 2025 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 +# +# http://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. + +name: Publish to Maven Central + +on: + workflow_dispatch: + inputs: + version: + description: 'Release version (e.g., 5.3.14)' + required: true + type: string + +jobs: + publish: + uses: reportportal/.github/.github/workflows/maven-publish.yml@main + with: + version: ${{ github.event.inputs.version }} + artifact: agent-java-cucumber6 + package_suffixes: '-javadoc.jar,-javadoc.jar.asc,-javadoc.jar.md5,-javadoc.jar.sha1,-javadoc.jar.sha256,-javadoc.jar.sha512,-sources.jar,-sources.jar.asc,-sources.jar.md5,-sources.jar.sha1,-sources.jar.sha256,-sources.jar.sha512,.jar,.jar.asc,.jar.md5,.jar.sha1,.jar.sha256,.jar.sha512,.pom,.pom.asc,.pom.md5,.pom.sha1,.pom.sha256,.pom.sha512,.module,.module.asc,.module.md5,.module.sha1,.module.sha256,.module.sha512' + secrets: + SONATYPE_USER: ${{ secrets.SONATYPE_USER }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml deleted file mode 100644 index 8bf7fcf..0000000 --- a/.github/workflows/promote.yml +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright 2021 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 -# -# http://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. - -name: Promote - -on: - workflow_dispatch: - inputs: - version: - description: 'Release version' - required: true - -env: - REPOSITORY_URL: 'https://maven.pkg.github.com' - UPSTREAM_REPOSITORY_URL: 'https://oss.sonatype.org' - PACKAGE_SUFFIXES: '-javadoc.jar,-javadoc.jar.asc,-sources.jar,-sources.jar.asc,.jar,.jar.asc,.pom,.pom.asc' - PACKAGE: 'com.epam.reportportal' - - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - - name: Get variables - run: | - echo "ARTIFACT=`echo ${{ github.repository }} | cut -d/ -f2- | awk '{print tolower($0)}'`" >> $GITHUB_ENV - echo "PACKAGE_PATH=`echo ${{ env.PACKAGE }} | sed 's/\./\//g'`" >> $GITHUB_ENV - - - name: Upload package - run: | - IFS=',' read -a files <<< '${{ env.PACKAGE_SUFFIXES }}' - for f in ${files[@]}; do - export URL="${{ env.REPOSITORY_URL }}/${{ github.repository }}/${PACKAGE_PATH}/${ARTIFACT}/${{ github.event.inputs.version }}/${ARTIFACT}-${{ github.event.inputs.version }}${f}" - echo "Downloading artifact: ${URL}" - curl -f -u ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} -s -O -L "${URL}" - done - files=($(ls)) - echo 'Files downloaded:' - echo "${files[@]}" - - echo 'Bundle generation' - export BUNDLE_FILE="bundle.jar" - jar -cvf ${BUNDLE_FILE} "${files[@]}" - - echo 'Bundle upload' - curl -f -u ${{ secrets.SONATYPE_USER }}:${{ secrets.SONATYPE_PASSWORD }} -L \ - --request POST '${{ env.UPSTREAM_REPOSITORY_URL }}/service/local/staging/bundle_upload' \ - --form "file=@${BUNDLE_FILE}" >response.json - - response_type=`jq type response.json || echo ''` - if [ -z "$response_type" ]; then - echo 'ERROR: Response is not JSON!' 1>&2 - cat response.json 1>&2 - exit 1 - fi - - repo=`jq -r '.repositoryUris[0]' response.json` - if [ -z "$repo" ]; then - echo 'Unable to upload bundle' 1>&2 - cat response.json 1>&2 - exit 1 - fi - - echo "NEXUS_REPOSITORY=${repo}" >> $GITHUB_ENV - - - name: Get repository variables - run: | - echo "NEXUS_REPOSITORY_NAME=`echo ${NEXUS_REPOSITORY} | sed -E 's/(.+)\/([^\/]+)$/\2/'`" >> $GITHUB_ENV - - - name: Promote package - env: - ATTEMPTS: 60 - SLEEP_TIME: 10 - run: | - verified=false - for i in `seq 0 ${ATTEMPTS}`; do - sleep $SLEEP_TIME - curl -f -s -u ${{ secrets.SONATYPE_USER }}:${{ secrets.SONATYPE_PASSWORD }} -L \ - --header 'Accept: application/json' \ - ${{ env.UPSTREAM_REPOSITORY_URL }}/service/local/staging/repository/${NEXUS_REPOSITORY_NAME} >result.json - - is_closed=`jq -r '.type' result.json` - is_transitioning=`jq -r '.transitioning' result.json` - echo "Current repository status: $is_closed; transitioning: $is_transitioning" - - if [[ "$is_closed" == "closed" && "$is_transitioning" == "false" ]]; then - verified=true - break - fi - done - if $verified; then - echo "A bundle was verified, releasing" - curl -f -u ${{ secrets.SONATYPE_USER }}:${{ secrets.SONATYPE_PASSWORD }} -L \ - --header 'Content-Type: application/json' \ - --data-raw "{\"data\":{\"stagedRepositoryIds\":[\"${NEXUS_REPOSITORY_NAME}\"], \"description\":\"Releasing ${{ github.event.inputs.version }}\"}}" \ - --request POST ${{ env.UPSTREAM_REPOSITORY_URL }}/service/local/staging/bulk/promote - else - echo 'Verification failed, please check the bundle' 1>&2 - exit 1 - fi From 05bf9e6462ffc758096ed7e22a605f9c4b18d0fc Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Tue, 16 Sep 2025 16:44:17 +0300 Subject: [PATCH 7/8] Fix tests --- .../cucumber/AmbiguousScenarioTest.java | 1 + .../reportportal/cucumber/BackgroundTest.java | 12 ++++----- .../reportportal/cucumber/CodeRefTest.java | 13 ++++----- .../epam/reportportal/cucumber/HooksTest.java | 10 +++---- .../cucumber/ManualStepReporterTest.java | 13 +++++---- .../NestedStepsScenarioReporterTest.java | 5 ++-- .../cucumber/NestedStepsStepReporterTest.java | 5 ++-- .../ParameterScenarioReporterTest.java | 19 +++++++------ .../cucumber/ParameterStepReporterTest.java | 27 ++++++++++++------- .../cucumber/RuleKeywordTest.java | 11 ++++---- .../ScenarioOutlineStepReporterTest.java | 9 ++++--- .../reportportal/cucumber/TestCaseIdTest.java | 17 ++++++------ 12 files changed, 79 insertions(+), 63 deletions(-) diff --git a/src/test/java/com/epam/reportportal/cucumber/AmbiguousScenarioTest.java b/src/test/java/com/epam/reportportal/cucumber/AmbiguousScenarioTest.java index 57393f2..214ebe5 100644 --- a/src/test/java/com/epam/reportportal/cucumber/AmbiguousScenarioTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/AmbiguousScenarioTest.java @@ -75,6 +75,7 @@ public static class SimpleTestScenarioReporterTest extends AbstractTestNGCucumbe @BeforeEach public void setup() { TestUtils.mockLaunch(client, launchId, suiteId, testId, stepIds); + TestUtils.mockLogging(client); TestScenarioReporter.RP.set(reportPortal); TestStepReporter.RP.set(reportPortal); } diff --git a/src/test/java/com/epam/reportportal/cucumber/BackgroundTest.java b/src/test/java/com/epam/reportportal/cucumber/BackgroundTest.java index 4d35666..9ab826e 100644 --- a/src/test/java/com/epam/reportportal/cucumber/BackgroundTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/BackgroundTest.java @@ -55,14 +55,14 @@ public class BackgroundTest { @CucumberOptions(features = "src/test/resources/features/BackgroundScenario.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class MyStepReporter extends AbstractTestNGCucumberTests { + public static class MyStepReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/BackgroundScenario.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestScenarioReporter" }) - public static class MyScenarioReporter extends AbstractTestNGCucumberTests { + public static class MyScenarioReporterTest extends AbstractTestNGCucumberTests { } @@ -107,7 +107,7 @@ public void tearDown() { @Test @SuppressWarnings("unchecked") public void verify_background_step_reporter() { - runTests(MyStepReporter.class); + runTests(MyStepReporterTest.class); verify(client, times(1)).startTestItem(any()); verify(client, times(2)).startTestItem(same(suiteId), any()); @@ -115,7 +115,7 @@ public void verify_background_step_reporter() { verify(client, times(2)).startTestItem(same(testIds.get(0)), firstStepStarts.capture()); ArgumentCaptor secondStepStarts = ArgumentCaptor.forClass(StartTestItemRQ.class); verify(client, times(2)).startTestItem(same(testIds.get(1)), secondStepStarts.capture()); - verify(client, times(4)).log(any(List.class)); + verify(client, times(5)).log(any(List.class)); assertThat(firstStepStarts.getAllValues() .stream() @@ -147,7 +147,7 @@ public void verify_background_step_reporter() { @SuppressWarnings("unchecked") public void verify_background_scenario_reporter() { mockNestedSteps(client, nestedSteps); - runTests(MyScenarioReporter.class); + runTests(MyScenarioReporterTest.class); verify(client, times(1)).startTestItem(any()); verify(client, times(1)).startTestItem(same(suiteId), any()); @@ -156,7 +156,7 @@ public void verify_background_scenario_reporter() { verify(client, times(2)).startTestItem(same(stepIds.get(0)), firstStepStarts.capture()); ArgumentCaptor secondStepStarts = ArgumentCaptor.forClass(StartTestItemRQ.class); verify(client, times(2)).startTestItem(same(stepIds.get(1)), secondStepStarts.capture()); - verify(client, times(4)).log(any(List.class)); + verify(client, times(5)).log(any(List.class)); assertThat(firstStepStarts.getAllValues() .stream() diff --git a/src/test/java/com/epam/reportportal/cucumber/CodeRefTest.java b/src/test/java/com/epam/reportportal/cucumber/CodeRefTest.java index 165f9c7..a9132fd 100644 --- a/src/test/java/com/epam/reportportal/cucumber/CodeRefTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/CodeRefTest.java @@ -52,21 +52,21 @@ public class CodeRefTest { @CucumberOptions(features = "src/test/resources/features/belly.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestScenarioReporter" }) - public static class BellyScenarioReporter extends AbstractTestNGCucumberTests { + public static class BellyScenarioReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/belly.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class BellyStepReporter extends AbstractTestNGCucumberTests { + public static class BellyStepReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/TwoScenarioInOne.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class TwoFeaturesStepReporter extends AbstractTestNGCucumberTests { + public static class TwoFeaturesStepReporterTest extends AbstractTestNGCucumberTests { } @@ -85,6 +85,7 @@ public static class TwoFeaturesStepReporter extends AbstractTestNGCucumberTests @BeforeEach public void initLaunch() { TestUtils.mockLaunch(client, launchId, suiteId, tests); + TestUtils.mockLogging(client); TestScenarioReporter.RP.set(reportPortal); TestStepReporter.RP.set(reportPortal); } @@ -95,7 +96,7 @@ public void initLaunch() { @Test public void verify_code_reference_scenario_reporter() { - TestUtils.runTests(BellyScenarioReporter.class); + TestUtils.runTests(BellyScenarioReporterTest.class); verify(client, times(1)).startTestItem(any()); ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); @@ -119,7 +120,7 @@ public void verify_code_reference_scenario_reporter() { @Test public void verify_code_reference_step_reporter() { - TestUtils.runTests(BellyStepReporter.class); + TestUtils.runTests(BellyStepReporterTest.class); verify(client, times(1)).startTestItem(any()); ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); @@ -148,7 +149,7 @@ public void verify_code_reference_step_reporter() { @Test public void verify_code_reference_two_features_step_reporter() { - TestUtils.runTests(TwoFeaturesStepReporter.class); + TestUtils.runTests(TwoFeaturesStepReporterTest.class); verify(client, times(1)).startTestItem(any()); ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); diff --git a/src/test/java/com/epam/reportportal/cucumber/HooksTest.java b/src/test/java/com/epam/reportportal/cucumber/HooksTest.java index cf9902d..2b39f88 100644 --- a/src/test/java/com/epam/reportportal/cucumber/HooksTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/HooksTest.java @@ -125,7 +125,7 @@ public void verify_before_after_step_reported_in_steps() { verify(client, times(1)).startTestItem(any()); verify(client, times(1)).startTestItem(same(suiteId), any()); verify(client, times(6)).startTestItem(same(featureId), any()); - verify(client, times(6)).log(any(List.class)); + verify(client, times(7)).log(any(List.class)); } @Test @@ -136,7 +136,7 @@ public void verify_before_after_scenario_reported_in_steps() { verify(client, times(1)).startTestItem(any()); verify(client, times(1)).startTestItem(same(suiteId), any()); verify(client, times(4)).startTestItem(same(featureId), any()); - verify(client, times(4)).log(any(List.class)); + verify(client, times(5)).log(any(List.class)); } @Test @@ -149,7 +149,7 @@ public void verify_before_after_all_reported_in_steps() { // @BeforeAll and @AfterAll hooks does not emit any events, see: https://github.com/cucumber/cucumber-jvm/issues/2422 verify(client, times(2)).startTestItem(same(featureId), any()); - verify(client, times(3)).log(any(List.class)); + verify(client, times(4)).log(any(List.class)); } @Test @@ -160,7 +160,7 @@ public void verify_before_after_not_reported_in_steps() { verify(client, times(1)).startTestItem(any()); verify(client, times(1)).startTestItem(same(suiteId), any()); verify(client, times(2)).startTestItem(same(featureId), any()); - verify(client, times(2)).log(any(List.class)); + verify(client, times(3)).log(any(List.class)); } @Test @@ -170,7 +170,7 @@ public void verify_skip_exception_in_before_step_hook_reported_correctly() { // Capture log entries ArgumentCaptor> logCaptor = ArgumentCaptor.forClass(List.class); - verify(client, times(2)).log(logCaptor.capture()); + verify(client, times(3)).log(logCaptor.capture()); // Verify the first "Before" step has reported single Log entry with ERROR level and "SkipException" with "Skipping test" message List errorLogs = filterLogs( diff --git a/src/test/java/com/epam/reportportal/cucumber/ManualStepReporterTest.java b/src/test/java/com/epam/reportportal/cucumber/ManualStepReporterTest.java index 64ccf81..a6fa81a 100644 --- a/src/test/java/com/epam/reportportal/cucumber/ManualStepReporterTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/ManualStepReporterTest.java @@ -42,7 +42,6 @@ import java.util.stream.IntStream; import java.util.stream.Stream; -import static com.epam.reportportal.cucumber.integration.util.TestUtils.extractJsonParts; import static com.epam.reportportal.cucumber.integration.util.TestUtils.filterLogs; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @@ -54,14 +53,14 @@ public class ManualStepReporterTest { @CucumberOptions(features = "src/test/resources/features/ManualStepReporter.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class SimpleTestStepReporter extends AbstractTestNGCucumberTests { + public static class SimpleTestStepReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/ManualStepReporter.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestScenarioReporter" }) - public static class SimpleTestScenarioReporter extends AbstractTestNGCucumberTests { + public static class SimpleTestScenarioReporterTest extends AbstractTestNGCucumberTests { } @@ -123,13 +122,13 @@ private static void verifyLogEntry(SaveLogRQ firstStepLog, String stepId, String @SuppressWarnings("unchecked") public void verify_step_reporter_steps_integrity() { TestUtils.mockNestedSteps(client, stepNestedSteps); - TestUtils.runTests(SimpleTestStepReporter.class); + TestUtils.runTests(SimpleTestStepReporterTest.class); verify(client, times(2)).startTestItem(same(testId), any()); ArgumentCaptor firstStepCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); verify(client, times(1)).startTestItem(same(stepIds.get(0)), firstStepCaptor.capture()); ArgumentCaptor> logCaptor = ArgumentCaptor.forClass(List.class); - verify(client, times(5)).log(logCaptor.capture()); + verify(client, times(6)).log(logCaptor.capture()); StartTestItemRQ firstStep = firstStepCaptor.getValue(); List logs = filterLogs(logCaptor, l -> true); SaveLogRQ firstStepLog = logs.get(0); @@ -187,13 +186,13 @@ public void verify_step_reporter_steps_integrity() { public void verify_scenario_reporter_steps_integrity() { TestUtils.mockNestedSteps(client, scenarioNestedSteps); TestUtils.mockNestedSteps(client, scenarioSecondNestedSteps); - TestUtils.runTests(SimpleTestScenarioReporter.class); + TestUtils.runTests(SimpleTestScenarioReporterTest.class); verify(client, times(2)).startTestItem(same(stepIds.get(0)), any()); ArgumentCaptor firstStepCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); verify(client, times(1)).startTestItem(same(scenarioNestedStepIds.get(0)), firstStepCaptor.capture()); ArgumentCaptor> logCaptor = ArgumentCaptor.forClass(List.class); - verify(client, times(5)).log(logCaptor.capture()); + verify(client, times(6)).log(logCaptor.capture()); StartTestItemRQ firstStep = firstStepCaptor.getValue(); List logs = filterLogs(logCaptor, l -> true); diff --git a/src/test/java/com/epam/reportportal/cucumber/NestedStepsScenarioReporterTest.java b/src/test/java/com/epam/reportportal/cucumber/NestedStepsScenarioReporterTest.java index cc13eef..e8c63b2 100644 --- a/src/test/java/com/epam/reportportal/cucumber/NestedStepsScenarioReporterTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/NestedStepsScenarioReporterTest.java @@ -51,7 +51,7 @@ public class NestedStepsScenarioReporterTest { @CucumberOptions(features = "src/test/resources/features/NestedStepsFeature.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestScenarioReporter" }) - public static class NestedStepsScenarioReporter extends AbstractTestNGCucumberTests { + public static class NestedStepsTest extends AbstractTestNGCucumberTests { } @@ -84,6 +84,7 @@ public static class NestedStepsScenarioReporter extends AbstractTestNGCucumberTe @BeforeEach public void setup() { TestUtils.mockLaunch(client, launchId, suiteId, testId, stepId); + TestUtils.mockLogging(client); TestUtils.mockNestedSteps(client, firstLevelNestedStepIds); TestUtils.mockNestedSteps(client, secondLevelNestedStepIds); TestUtils.mockNestedSteps(client, Pair.of(nestedNestedStepIds.get(0), nestedNestedNestedStepId)); @@ -105,7 +106,7 @@ public void tearDown() { @Test public void test_scenario_reporter_nested_steps() { - TestUtils.runTests(NestedStepsScenarioReporter.class); + TestUtils.runTests(NestedStepsTest.class); ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); verify(client, times(1)).startTestItem(captor.capture()); diff --git a/src/test/java/com/epam/reportportal/cucumber/NestedStepsStepReporterTest.java b/src/test/java/com/epam/reportportal/cucumber/NestedStepsStepReporterTest.java index 7c5a828..6b58cfd 100644 --- a/src/test/java/com/epam/reportportal/cucumber/NestedStepsStepReporterTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/NestedStepsStepReporterTest.java @@ -49,7 +49,7 @@ public class NestedStepsStepReporterTest { @CucumberOptions(features = "src/test/resources/features/NestedStepsFeature.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class NestedStepsStepReporter extends AbstractTestNGCucumberTests { + public static class NestedStepsTest extends AbstractTestNGCucumberTests { } @@ -74,6 +74,7 @@ public static class NestedStepsStepReporter extends AbstractTestNGCucumberTests @BeforeEach public void setup() { TestUtils.mockLaunch(client, launchId, suiteId, testId, stepIds); + TestUtils.mockLogging(client); TestUtils.mockNestedSteps(client, firstLevelNestedStepIds); TestUtils.mockNestedSteps(client, Pair.of(nestedStepIds.get(0), nestedNestedStepId)); TestScenarioReporter.RP.set(reportPortal); @@ -92,7 +93,7 @@ public void tearDown() { @Test public void test_step_reporter_nested_steps() { - TestUtils.runTests(NestedStepsStepReporter.class); + TestUtils.runTests(NestedStepsTest.class); ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); verify(client, times(1)).startTestItem(captor.capture()); diff --git a/src/test/java/com/epam/reportportal/cucumber/ParameterScenarioReporterTest.java b/src/test/java/com/epam/reportportal/cucumber/ParameterScenarioReporterTest.java index 149fd26..1847308 100644 --- a/src/test/java/com/epam/reportportal/cucumber/ParameterScenarioReporterTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/ParameterScenarioReporterTest.java @@ -46,8 +46,8 @@ import static com.epam.reportportal.cucumber.integration.util.TestUtils.filterLogs; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.mockito.Mockito.any; import static org.mockito.Mockito.*; +import static org.mockito.Mockito.any; /** * @author Ihar Kahadouski @@ -74,7 +74,8 @@ public static class DataTableParameterTest extends AbstractTestNGCucumberTests { } private static final String DOCSTRING_PARAM = "My very long parameter\nWith some new lines"; - private static final String TABLE_PARAM = MarkdownUtils.formatDataTable(Arrays.asList(Arrays.asList("key", "value"), + private static final String TABLE_PARAM = MarkdownUtils.formatDataTable(Arrays.asList( + Arrays.asList("key", "value"), Arrays.asList("myKey", "myValue") )); @@ -87,7 +88,8 @@ public static class DataTableParameterTest extends AbstractTestNGCucumberTests { .limit(9) .collect(Collectors.toList()); - private final List> nestedStepMap = Stream.concat(IntStream.range(0, 4) + private final List> nestedStepMap = Stream.concat( + IntStream.range(0, 4) .mapToObj(i -> Pair.of(stepIds.get(0), nestedStepIds.get(i))), IntStream.range(4, 9).mapToObj(i -> Pair.of(stepIds.get(1), nestedStepIds.get(i))) ).collect(Collectors.toList()); @@ -108,7 +110,8 @@ public void initLaunch() { public static final List> PARAMETERS = Arrays.asList(Pair.of("str", "\"first\""), Pair.of("parameters", 123)); - public static final List STEP_NAMES = Arrays.asList(String.format("When I have parameter %s", PARAMETERS.get(0).getValue()), + public static final List STEP_NAMES = Arrays.asList( + String.format("When I have parameter %s", PARAMETERS.get(0).getValue()), String.format("Then I emit number %s on level info", PARAMETERS.get(1).getValue().toString()) ); @@ -148,8 +151,8 @@ public void verify_agent_reports_docstring_parameter() { assertThat(param1.getValue(), equalTo(DOCSTRING_PARAM)); ArgumentCaptor> logCaptor = ArgumentCaptor.forClass(List.class); - verify(client, times(3)).log(logCaptor.capture()); - List logs = filterLogs(logCaptor, l -> l.getItemUuid().equals(nestedStepIds.get(1))).stream() + verify(client, times(4)).log(logCaptor.capture()); + List logs = filterLogs(logCaptor, l -> l.getItemUuid() != null && l.getItemUuid().equals(nestedStepIds.get(1))).stream() .map(SaveLogRQ::getMessage) .collect(Collectors.toList()); @@ -173,8 +176,8 @@ public void verify_agent_reports_data_table_parameter() { assertThat(param1.getValue(), equalTo(TABLE_PARAM)); ArgumentCaptor> logCaptor = ArgumentCaptor.forClass(List.class); - verify(client, times(2)).log(logCaptor.capture()); - List logs = filterLogs(logCaptor, l -> l.getItemUuid().equals(nestedStepIds.get(0))).stream() + verify(client, times(3)).log(logCaptor.capture()); + List logs = filterLogs(logCaptor, l -> l.getItemUuid() != null && l.getItemUuid().equals(nestedStepIds.get(0))).stream() .map(SaveLogRQ::getMessage) .collect(Collectors.toList()); diff --git a/src/test/java/com/epam/reportportal/cucumber/ParameterStepReporterTest.java b/src/test/java/com/epam/reportportal/cucumber/ParameterStepReporterTest.java index e168689..a7db78c 100644 --- a/src/test/java/com/epam/reportportal/cucumber/ParameterStepReporterTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/ParameterStepReporterTest.java @@ -46,8 +46,8 @@ import static com.epam.reportportal.cucumber.integration.util.TestUtils.filterLogs; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.mockito.Mockito.any; import static org.mockito.Mockito.*; +import static org.mockito.Mockito.any; /** * @author Ihar Kahadouski @@ -88,7 +88,8 @@ public static class DataTableParameterTestStepReporterTest extends AbstractTestN } private static final String DOCSTRING_PARAM = "My very long parameter\nWith some new lines"; - private static final String TABLE_PARAM = MarkdownUtils.formatDataTable(Arrays.asList(Arrays.asList("key", "value"), + private static final String TABLE_PARAM = MarkdownUtils.formatDataTable(Arrays.asList( + Arrays.asList("key", "value"), Arrays.asList("myKey", "myValue") )); @@ -112,7 +113,8 @@ public void initLaunch() { TestStepReporter.RP.set(reportPortal); } - public static final List> PARAMETERS = Arrays.asList(Pair.of("java.lang.String", "\"first\""), + public static final List> PARAMETERS = Arrays.asList( + Pair.of("java.lang.String", "\"first\""), Pair.of("int", 123), Pair.of("java.lang.String", "\"second\""), Pair.of("int", 12345), @@ -120,7 +122,8 @@ public void initLaunch() { Pair.of("int", 12345678) ); - public static final List STEP_NAMES = Arrays.asList(String.format("When I have parameter %s", PARAMETERS.get(0).getValue()), + public static final List STEP_NAMES = Arrays.asList( + String.format("When I have parameter %s", PARAMETERS.get(0).getValue()), String.format("Then I emit number %s on level info", PARAMETERS.get(1).getValue().toString()), String.format("When I have parameter %s", PARAMETERS.get(2).getValue()), String.format("Then I emit number %s on level info", PARAMETERS.get(3).getValue().toString()), @@ -224,10 +227,11 @@ public void verify_docstring_parameters() { assertThat(param1.getValue(), equalTo(DOCSTRING_PARAM)); ArgumentCaptor> logCaptor = ArgumentCaptor.forClass(List.class); - verify(client, times(2)).log(logCaptor.capture()); - List logs = filterLogs(logCaptor, l -> l.getItemUuid().equals(tests.get(0).getValue().get(1))).stream() - .map(SaveLogRQ::getMessage) - .collect(Collectors.toList()); + verify(client, times(3)).log(logCaptor.capture()); + List logs = filterLogs( + logCaptor, + l -> l.getItemUuid() != null && l.getItemUuid().equals(tests.get(0).getValue().get(1)) + ).stream().map(SaveLogRQ::getMessage).collect(Collectors.toList()); assertThat(logs, hasSize(1)); assertThat(logs, not(hasItem(equalTo("\"\"\"\n" + DOCSTRING_PARAM + "\n\"\"\"")))); @@ -249,9 +253,12 @@ public void verify_data_table_parameters() { assertThat(param1.getValue(), equalTo(TABLE_PARAM)); ArgumentCaptor> logCaptor = ArgumentCaptor.forClass(List.class); - verify(client, times(1)).log(logCaptor.capture()); + verify(client, times(2)).log(logCaptor.capture()); - List logs = filterLogs(logCaptor, l -> l.getItemUuid().equals(tests.get(0).getValue().get(0))).stream() + List logs = filterLogs( + logCaptor, + l -> l.getItemUuid() != null && l.getItemUuid().equals(tests.get(0).getValue().get(0)) + ).stream() .map(SaveLogRQ::getMessage) .collect(Collectors.toList()); diff --git a/src/test/java/com/epam/reportportal/cucumber/RuleKeywordTest.java b/src/test/java/com/epam/reportportal/cucumber/RuleKeywordTest.java index b64dfae..54ac452 100644 --- a/src/test/java/com/epam/reportportal/cucumber/RuleKeywordTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/RuleKeywordTest.java @@ -23,7 +23,6 @@ import com.epam.reportportal.service.ReportPortal; import com.epam.reportportal.service.ReportPortalClient; import com.epam.reportportal.util.test.CommonUtils; -import com.epam.reportportal.utils.properties.SystemAttributesExtractor; import com.epam.ta.reportportal.ws.model.StartTestItemRQ; import io.cucumber.testng.AbstractTestNGCucumberTests; import io.cucumber.testng.CucumberOptions; @@ -48,14 +47,14 @@ public class RuleKeywordTest { @CucumberOptions(features = "src/test/resources/features/RuleKeyword.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class SimpleTestStepReporter extends AbstractTestNGCucumberTests { + public static class SimpleTestStepReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/RuleKeyword.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestScenarioReporter" }) - public static class SimpleTestScenarioReporter extends AbstractTestNGCucumberTests { + public static class SimpleTestScenarioReporterTest extends AbstractTestNGCucumberTests { } @@ -84,11 +83,12 @@ public static class SimpleTestScenarioReporter extends AbstractTestNGCucumberTes @Test public void verify_rule_keyword_step_reporter() { TestUtils.mockLaunch(client, launchId, featureId, tests); + TestUtils.mockLogging(client); TestUtils.mockNestedSteps(client, steps); TestScenarioReporter.RP.set(reportPortal); TestStepReporter.RP.set(reportPortal); - TestUtils.runTests(SimpleTestStepReporter.class); + TestUtils.runTests(SimpleTestStepReporterTest.class); verify(client, times(1)).startTestItem(any()); ArgumentCaptor ruleRqCapture = ArgumentCaptor.forClass(StartTestItemRQ.class); @@ -109,6 +109,7 @@ public void verify_rule_keyword_step_reporter() { @Test public void verify_rule_keyword_scenario_reporter() { TestUtils.mockLaunch(client, launchId, suiteId, featureId, ruleIds); + TestUtils.mockLogging(client); TestUtils.mockNestedSteps(client, tests.stream().flatMap(e -> e.getValue().stream().map(v -> Pair.of(e.getKey(), v))).collect(Collectors.toList()) ); @@ -117,7 +118,7 @@ public void verify_rule_keyword_scenario_reporter() { TestScenarioReporter.RP.set(reportPortal); TestStepReporter.RP.set(reportPortal); - TestUtils.runTests(SimpleTestScenarioReporter.class); + TestUtils.runTests(SimpleTestScenarioReporterTest.class); verify(client, times(1)).startTestItem(any()); verify(client, times(1)).startTestItem(same(suiteId), any()); diff --git a/src/test/java/com/epam/reportportal/cucumber/ScenarioOutlineStepReporterTest.java b/src/test/java/com/epam/reportportal/cucumber/ScenarioOutlineStepReporterTest.java index 3c6a2ef..9d37b82 100644 --- a/src/test/java/com/epam/reportportal/cucumber/ScenarioOutlineStepReporterTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/ScenarioOutlineStepReporterTest.java @@ -53,14 +53,14 @@ public class ScenarioOutlineStepReporterTest { @CucumberOptions(features = "src/test/resources/features/BasicScenarioOutlineParameters.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class RunOutlineParametersTestStepReporter extends AbstractTestNGCucumberTests { + public static class RunOutlineParametersTestStepReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/DynamicScenarioOutlineNames.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class RunDynamicScenarioOutlineTitlesTestStepReporter extends AbstractTestNGCucumberTests { + public static class RunDynamicScenarioOutlineTitlesTestStepReporterTest extends AbstractTestNGCucumberTests { } @@ -79,6 +79,7 @@ public static class RunDynamicScenarioOutlineTitlesTestStepReporter extends Abst @BeforeEach public void initLaunch() { TestUtils.mockLaunch(client, launchId, suiteId, tests); + TestUtils.mockLogging(client); TestScenarioReporter.RP.set(reportPortal); TestStepReporter.RP.set(reportPortal); } @@ -89,7 +90,7 @@ public void initLaunch() { // Do not add iteration indexes / numbers, since it breaks re-runs @Test public void verify_scenario_outline_names() { - TestUtils.runTests(RunOutlineParametersTestStepReporter.class); + TestUtils.runTests(RunOutlineParametersTestStepReporterTest.class); verify(client, times(1)).startTestItem(any()); ArgumentCaptor testCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); @@ -108,7 +109,7 @@ public void verify_scenario_outline_names() { @Test public void verify_dynamic_scenario_outline_names() { - TestUtils.runTests(RunDynamicScenarioOutlineTitlesTestStepReporter.class); + TestUtils.runTests(RunDynamicScenarioOutlineTitlesTestStepReporterTest.class); verify(client, times(1)).startTestItem(any()); ArgumentCaptor testCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); diff --git a/src/test/java/com/epam/reportportal/cucumber/TestCaseIdTest.java b/src/test/java/com/epam/reportportal/cucumber/TestCaseIdTest.java index 173f238..638b284 100644 --- a/src/test/java/com/epam/reportportal/cucumber/TestCaseIdTest.java +++ b/src/test/java/com/epam/reportportal/cucumber/TestCaseIdTest.java @@ -49,28 +49,28 @@ public class TestCaseIdTest { @CucumberOptions(features = "src/test/resources/features/belly.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestScenarioReporter" }) - public static class RunBellyTestScenarioReporter extends AbstractTestNGCucumberTests { + public static class RunBellyTestScenarioReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/belly.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class RunBellyTestStepReporter extends AbstractTestNGCucumberTests { + public static class RunBellyTestStepReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/TestCaseIdOnAMethod.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestStepReporter" }) - public static class StepDefStepReporter extends AbstractTestNGCucumberTests { + public static class StepDefStepReporterTest extends AbstractTestNGCucumberTests { } @CucumberOptions(features = "src/test/resources/features/BasicScenarioOutlineParameters.feature", glue = { "com.epam.reportportal.cucumber.integration.feature" }, plugin = { "pretty", "com.epam.reportportal.cucumber.integration.TestScenarioReporter" }) - public static class OutlineScenarioReporter extends AbstractTestNGCucumberTests { + public static class OutlineScenarioReporterTest extends AbstractTestNGCucumberTests { } @@ -91,6 +91,7 @@ public static class OutlineScenarioReporter extends AbstractTestNGCucumberTests @BeforeEach public void setup() { TestUtils.mockLaunch(client, launchId, suiteId, testId, stepIds); + TestUtils.mockLogging(client); TestScenarioReporter.RP.set(reportPortal); TestStepReporter.RP.set(reportPortal); } @@ -102,7 +103,7 @@ public void tearDown() { @Test public void shouldSendCaseIdWhenParametrizedScenarioReporter() { - TestUtils.runTests(RunBellyTestScenarioReporter.class); + TestUtils.runTests(RunBellyTestScenarioReporterTest.class); verify(client, times(1)).startTestItem(any()); verify(client, times(1)).startTestItem(same(suiteId), any()); @@ -115,7 +116,7 @@ public void shouldSendCaseIdWhenParametrizedScenarioReporter() { @Test public void shouldSendCaseIdWhenParametrizedStepReporter() { - TestUtils.runTests(RunBellyTestStepReporter.class); + TestUtils.runTests(RunBellyTestStepReporterTest.class); verify(client, times(1)).startTestItem(any()); verify(client, times(1)).startTestItem(same(suiteId), any()); @@ -138,7 +139,7 @@ public void shouldSendCaseIdWhenParametrizedStepReporter() { @Test public void verify_test_case_id_bypassed_through_annotation_on_a_stepdef() { - TestUtils.runTests(StepDefStepReporter.class); + TestUtils.runTests(StepDefStepReporterTest.class); ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); verify(client, times(1)).startTestItem(same(testId), captor.capture()); @@ -153,7 +154,7 @@ public void verify_test_case_id_bypassed_through_annotation_on_a_stepdef() { @Test public void verify_test_case_id_scenario_outline() { TestUtils.mockNestedSteps(client, nestedSteps); - TestUtils.runTests(OutlineScenarioReporter.class); + TestUtils.runTests(OutlineScenarioReporterTest.class); verify(client, times(1)).startTestItem(any()); verify(client, times(1)).startTestItem(same(suiteId), any()); From 6e4cb6053de1fa01a887efb42bc88a28b52fd92a Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Tue, 16 Sep 2025 17:27:07 +0300 Subject: [PATCH 8/8] Limit execution time --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 027e839..49a7367 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,7 @@ jobs: java-version: '11' - name: Build with Gradle + timeout-minutes: 15 run: ./gradlew build - name: Codecov upload