From 44a1210c28e38ee521acc7e8cb02277ba76d98d4 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Mon, 11 Dec 2023 17:42:46 +0300 Subject: [PATCH] Add the first integration test --- build.gradle | 1 + .../karate/KarateReportPortalRunner.java | 2 +- .../karate/ReportPortalPublisherTest.java | 2 +- .../karate/coderef/ScenarioCodeRefTest.java | 15 +++++++++++++++ .../{ => karate}/utils/ReflectUtils.java | 4 ++-- .../reportportal/karate/utils/TestUtils.java | 16 ++++++++++++++++ src/test/resources/feature/simple.feature | 5 +++++ 7 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 src/test/java/com/epam/reportportal/karate/coderef/ScenarioCodeRefTest.java rename src/test/java/com/epam/reportportal/{ => karate}/utils/ReflectUtils.java (90%) create mode 100644 src/test/java/com/epam/reportportal/karate/utils/TestUtils.java create mode 100644 src/test/resources/feature/simple.feature diff --git a/build.gradle b/build.gradle index 2fb3569..38c8160 100644 --- a/build.gradle +++ b/build.gradle @@ -48,6 +48,7 @@ dependencies { testImplementation "org.junit.jupiter:junit-jupiter-engine:${project.junit_version}" testImplementation "org.mockito:mockito-core:${project.mockito_version}" testImplementation "org.mockito:mockito-junit-jupiter:${project.mockito_version}" + testImplementation 'org.hamcrest:hamcrest-core:2.2' } test { diff --git a/src/main/java/com/epam/reportportal/karate/KarateReportPortalRunner.java b/src/main/java/com/epam/reportportal/karate/KarateReportPortalRunner.java index fb81065..dbc99cf 100644 --- a/src/main/java/com/epam/reportportal/karate/KarateReportPortalRunner.java +++ b/src/main/java/com/epam/reportportal/karate/KarateReportPortalRunner.java @@ -7,7 +7,7 @@ import java.util.*; import java.util.stream.Collectors; -public class KarateReportPortalRunner extends Suite { +public class KarateReportPortalRunner { public static > Builder path(String... paths) { Builder builder = new Builder<>(); diff --git a/src/test/java/com/epam/reportportal/karate/ReportPortalPublisherTest.java b/src/test/java/com/epam/reportportal/karate/ReportPortalPublisherTest.java index dbe1a68..54f5819 100644 --- a/src/test/java/com/epam/reportportal/karate/ReportPortalPublisherTest.java +++ b/src/test/java/com/epam/reportportal/karate/ReportPortalPublisherTest.java @@ -2,7 +2,7 @@ import com.epam.reportportal.listeners.ListenerParameters; import com.epam.reportportal.service.Launch; -import com.epam.reportportal.utils.ReflectUtils; +import com.epam.reportportal.karate.utils.ReflectUtils; import com.epam.ta.reportportal.ws.model.FinishExecutionRQ; import com.epam.ta.reportportal.ws.model.FinishTestItemRQ; import com.epam.ta.reportportal.ws.model.StartTestItemRQ; diff --git a/src/test/java/com/epam/reportportal/karate/coderef/ScenarioCodeRefTest.java b/src/test/java/com/epam/reportportal/karate/coderef/ScenarioCodeRefTest.java new file mode 100644 index 0000000..9587efe --- /dev/null +++ b/src/test/java/com/epam/reportportal/karate/coderef/ScenarioCodeRefTest.java @@ -0,0 +1,15 @@ +package com.epam.reportportal.karate.coderef; + +import com.epam.reportportal.karate.utils.TestUtils; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; + +public class ScenarioCodeRefTest { + @Test + public void test_scenario_code_reference() { + var results = TestUtils.run("classpath:feature/simple.feature"); + assertThat(results.getFailCount(), equalTo(0)); + } +} diff --git a/src/test/java/com/epam/reportportal/utils/ReflectUtils.java b/src/test/java/com/epam/reportportal/karate/utils/ReflectUtils.java similarity index 90% rename from src/test/java/com/epam/reportportal/utils/ReflectUtils.java rename to src/test/java/com/epam/reportportal/karate/utils/ReflectUtils.java index f1d20cf..54d6d9e 100644 --- a/src/test/java/com/epam/reportportal/utils/ReflectUtils.java +++ b/src/test/java/com/epam/reportportal/karate/utils/ReflectUtils.java @@ -1,4 +1,4 @@ -package com.epam.reportportal.utils; +package com.epam.reportportal.karate.utils; import java.lang.reflect.Field; @@ -16,4 +16,4 @@ public static void setField(Object object, Field fld, Object value) { throw new RuntimeException("Failed to set " + fieldName + " of object", e); } } -} \ No newline at end of file +} diff --git a/src/test/java/com/epam/reportportal/karate/utils/TestUtils.java b/src/test/java/com/epam/reportportal/karate/utils/TestUtils.java new file mode 100644 index 0000000..e77569e --- /dev/null +++ b/src/test/java/com/epam/reportportal/karate/utils/TestUtils.java @@ -0,0 +1,16 @@ +package com.epam.reportportal.karate.utils; + +import com.epam.reportportal.karate.KarateReportPortalRunner; +import com.intuit.karate.Results; + +public class TestUtils { + private TestUtils() { + } + + public static Results run(String... paths) { + return KarateReportPortalRunner + .path(paths) + .outputCucumberJson(false) + .parallel(1); + } +} diff --git a/src/test/resources/feature/simple.feature b/src/test/resources/feature/simple.feature new file mode 100644 index 0000000..3c8457b --- /dev/null +++ b/src/test/resources/feature/simple.feature @@ -0,0 +1,5 @@ +Feature: the very basic test to run by Karate + Scenario: Verify response code + Given url 'https://example.com/' + When method GET + Then status 200