From db08eda539c4a5a6a7a5a7f1a74510eb96697220 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Sat, 6 Jan 2024 01:14:07 +0300 Subject: [PATCH] ReportPortalHook: Tests WIP --- .../attributes/DifferentAttributesTest.java | 17 +++++++++++++---- .../karate/attributes/LaunchAttributesTest.java | 17 +++++++++++++---- .../karate/attributes/NoAttributesTest.java | 17 +++++++++++++---- .../karate/attributes/SystemAttributesTest.java | 17 +++++++++++++---- .../background/BackgroundExamplesTest.java | 17 +++++++++++++---- .../karate/background/BackgroundTest.java | 17 +++++++++++++---- .../background/BackgroundTwoStepsTest.java | 17 +++++++++++++---- .../karate/coderef/ExamplesCodeRefTest.java | 17 +++++++++++++---- .../karate/coderef/ScenarioCodeRefTest.java | 17 +++++++++++++---- .../description/DescriptionExamplesTest.java | 17 +++++++++++++---- .../description/LaunchDescriptionTest.java | 17 +++++++++++++---- .../description/NoDescriptionExamplesTest.java | 17 +++++++++++++---- .../karate/description/NoDescriptionTest.java | 17 +++++++++++++---- .../description/NoLaunchDescriptionTest.java | 17 +++++++++++++---- .../description/SimpleDescriptionTest.java | 17 +++++++++++++---- 15 files changed, 195 insertions(+), 60 deletions(-) diff --git a/src/test/java/com/epam/reportportal/karate/attributes/DifferentAttributesTest.java b/src/test/java/com/epam/reportportal/karate/attributes/DifferentAttributesTest.java index 6dec4d0..80e4f24 100644 --- a/src/test/java/com/epam/reportportal/karate/attributes/DifferentAttributesTest.java +++ b/src/test/java/com/epam/reportportal/karate/attributes/DifferentAttributesTest.java @@ -22,9 +22,11 @@ import com.epam.reportportal.util.test.CommonUtils; import com.epam.ta.reportportal.ws.model.StartTestItemRQ; import com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ; +import com.intuit.karate.Results; import org.apache.commons.lang3.tuple.Pair; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import java.util.List; @@ -39,6 +41,7 @@ import static org.mockito.Mockito.*; public class DifferentAttributesTest { + private static final String TEST_FEATURE = "classpath:feature/tags.feature"; private final String featureId = CommonUtils.namedId("feature_"); private final String scenarioId = CommonUtils.namedId("scenario_"); private final List stepIds = Stream.generate(() -> CommonUtils.namedId("step_")) @@ -53,9 +56,15 @@ public void setupMock() { mockBatchLogging(client); } - @Test - public void test_different_attributes() { - var results = TestUtils.runAsReport(rp, "classpath:feature/tags.feature"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void test_different_attributes(boolean report) { + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); diff --git a/src/test/java/com/epam/reportportal/karate/attributes/LaunchAttributesTest.java b/src/test/java/com/epam/reportportal/karate/attributes/LaunchAttributesTest.java index ee59bad..5273a28 100644 --- a/src/test/java/com/epam/reportportal/karate/attributes/LaunchAttributesTest.java +++ b/src/test/java/com/epam/reportportal/karate/attributes/LaunchAttributesTest.java @@ -23,8 +23,10 @@ import com.epam.reportportal.util.test.CommonUtils; import com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ; import com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ; +import com.intuit.karate.Results; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import java.util.Arrays; @@ -41,6 +43,7 @@ import static org.mockito.Mockito.verify; public class LaunchAttributesTest { + private static final String TEST_FEATURE = "classpath:feature/simple.feature"; private final String featureId = CommonUtils.namedId("feature_"); private final String scenarioId = CommonUtils.namedId("scenario_"); private final List stepIds = Stream.generate(() -> CommonUtils.namedId("step_")) @@ -59,9 +62,15 @@ public void setupMock() { mockBatchLogging(client); } - @Test - public void verify_start_launch_request_contains_launch_attributes() { - var results = TestUtils.runAsReport(rp, "classpath:feature/simple.feature"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void verify_start_launch_request_contains_launch_attributes(boolean report) { + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor startCaptor = ArgumentCaptor.forClass(StartLaunchRQ.class); diff --git a/src/test/java/com/epam/reportportal/karate/attributes/NoAttributesTest.java b/src/test/java/com/epam/reportportal/karate/attributes/NoAttributesTest.java index dd6a4ce..8c371b0 100644 --- a/src/test/java/com/epam/reportportal/karate/attributes/NoAttributesTest.java +++ b/src/test/java/com/epam/reportportal/karate/attributes/NoAttributesTest.java @@ -21,8 +21,10 @@ import com.epam.reportportal.service.ReportPortalClient; import com.epam.reportportal.util.test.CommonUtils; import com.epam.ta.reportportal.ws.model.StartTestItemRQ; +import com.intuit.karate.Results; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import java.util.List; @@ -36,6 +38,7 @@ import static org.mockito.Mockito.*; public class NoAttributesTest { + private static final String TEST_FEATURE = "classpath:feature/simple.feature"; private final String featureId = CommonUtils.namedId("feature_"); private final String scenarioId = CommonUtils.namedId("scenario_"); private final List stepIds = Stream.generate(() -> CommonUtils.namedId("step_")) @@ -50,9 +53,15 @@ public void setupMock() { mockBatchLogging(client); } - @Test - public void test_different_attributes() { - var results = TestUtils.runAsReport(rp, "classpath:feature/simple.feature"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void test_different_attributes(boolean report) { + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); diff --git a/src/test/java/com/epam/reportportal/karate/attributes/SystemAttributesTest.java b/src/test/java/com/epam/reportportal/karate/attributes/SystemAttributesTest.java index a5cb85e..5a1a85f 100644 --- a/src/test/java/com/epam/reportportal/karate/attributes/SystemAttributesTest.java +++ b/src/test/java/com/epam/reportportal/karate/attributes/SystemAttributesTest.java @@ -22,8 +22,10 @@ import com.epam.reportportal.util.test.CommonUtils; import com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ; import com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ; +import com.intuit.karate.Results; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import java.util.List; @@ -38,6 +40,7 @@ import static org.mockito.Mockito.verify; public class SystemAttributesTest { + private static final String TEST_FEATURE = "classpath:feature/simple.feature"; private final String featureId = CommonUtils.namedId("feature_"); private final String scenarioId = CommonUtils.namedId("scenario_"); private final List stepIds = Stream.generate(() -> CommonUtils.namedId("step_")) @@ -52,9 +55,15 @@ public void setupMock() { mockBatchLogging(client); } - @Test - public void verify_start_launch_request_contains_system_attributes() { - var results = TestUtils.runAsReport(rp, "classpath:feature/simple.feature"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void verify_start_launch_request_contains_system_attributes(boolean report) { + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor startCaptor = ArgumentCaptor.forClass(StartLaunchRQ.class); diff --git a/src/test/java/com/epam/reportportal/karate/background/BackgroundExamplesTest.java b/src/test/java/com/epam/reportportal/karate/background/BackgroundExamplesTest.java index bdf0b09..14a2b72 100644 --- a/src/test/java/com/epam/reportportal/karate/background/BackgroundExamplesTest.java +++ b/src/test/java/com/epam/reportportal/karate/background/BackgroundExamplesTest.java @@ -6,10 +6,12 @@ import com.epam.reportportal.service.ReportPortalClient; import com.epam.reportportal.util.test.CommonUtils; import com.epam.ta.reportportal.ws.model.StartTestItemRQ; +import com.intuit.karate.Results; import com.intuit.karate.core.Background; import org.apache.commons.lang3.tuple.Pair; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import java.util.List; @@ -25,6 +27,7 @@ import static org.mockito.Mockito.*; public class BackgroundExamplesTest { + private static final String TEST_FEATURE = "classpath:feature/background_examples.feature"; private final String featureId = CommonUtils.namedId("feature_"); private final List scenarioIds = Stream.generate(() -> CommonUtils.namedId("scenario_")) .limit(2).collect(Collectors.toList()); @@ -50,9 +53,15 @@ public void setupMock() { mockBatchLogging(client); } - @Test - public void test_background_steps() { - var results = TestUtils.runAsReport(rp, "classpath:feature/background_examples.feature"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void test_background_steps(boolean report) { + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); diff --git a/src/test/java/com/epam/reportportal/karate/background/BackgroundTest.java b/src/test/java/com/epam/reportportal/karate/background/BackgroundTest.java index fa81516..f869904 100644 --- a/src/test/java/com/epam/reportportal/karate/background/BackgroundTest.java +++ b/src/test/java/com/epam/reportportal/karate/background/BackgroundTest.java @@ -6,10 +6,12 @@ import com.epam.reportportal.service.ReportPortalClient; import com.epam.reportportal.util.test.CommonUtils; import com.epam.ta.reportportal.ws.model.StartTestItemRQ; +import com.intuit.karate.Results; import com.intuit.karate.core.Background; import org.apache.commons.lang3.tuple.Pair; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import java.util.List; @@ -24,6 +26,7 @@ import static org.mockito.Mockito.*; public class BackgroundTest { + private static final String TEST_FEATURE = "classpath:feature/background.feature"; private final String featureId = CommonUtils.namedId("feature_"); private final String scenarioId = CommonUtils.namedId("scenario_"); private final List stepIds = Stream.generate(() -> CommonUtils.namedId("step_")) @@ -41,9 +44,15 @@ public void setupMock() { mockBatchLogging(client); } - @Test - public void test_background_steps() { - var results = TestUtils.runAsReport(rp, "classpath:feature/background.feature"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void test_background_steps(boolean report) { + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); diff --git a/src/test/java/com/epam/reportportal/karate/background/BackgroundTwoStepsTest.java b/src/test/java/com/epam/reportportal/karate/background/BackgroundTwoStepsTest.java index 4659a40..5c92af0 100644 --- a/src/test/java/com/epam/reportportal/karate/background/BackgroundTwoStepsTest.java +++ b/src/test/java/com/epam/reportportal/karate/background/BackgroundTwoStepsTest.java @@ -6,10 +6,12 @@ import com.epam.reportportal.service.ReportPortalClient; import com.epam.reportportal.util.test.CommonUtils; import com.epam.ta.reportportal.ws.model.StartTestItemRQ; +import com.intuit.karate.Results; import com.intuit.karate.core.Background; import org.apache.commons.lang3.tuple.Pair; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import java.util.List; @@ -25,6 +27,7 @@ import static org.mockito.Mockito.*; public class BackgroundTwoStepsTest { + private static final String TEST_FEATURE = "classpath:feature/background_two_steps.feature"; private final String featureId = CommonUtils.namedId("feature_"); private final String scenarioId = CommonUtils.namedId("scenario_"); private final List stepIds = Stream.generate(() -> CommonUtils.namedId("step_")) @@ -44,9 +47,15 @@ public void setupMock() { mockBatchLogging(client); } - @Test - public void test_background_steps() { - var results = TestUtils.runAsReport(rp, "classpath:feature/background_two_steps.feature"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void test_background_steps(boolean report) { + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); diff --git a/src/test/java/com/epam/reportportal/karate/coderef/ExamplesCodeRefTest.java b/src/test/java/com/epam/reportportal/karate/coderef/ExamplesCodeRefTest.java index 961de3a..8de1055 100644 --- a/src/test/java/com/epam/reportportal/karate/coderef/ExamplesCodeRefTest.java +++ b/src/test/java/com/epam/reportportal/karate/coderef/ExamplesCodeRefTest.java @@ -6,9 +6,11 @@ import com.epam.reportportal.service.ReportPortalClient; import com.epam.reportportal.util.test.CommonUtils; import com.epam.ta.reportportal.ws.model.StartTestItemRQ; +import com.intuit.karate.Results; import org.apache.commons.lang3.tuple.Pair; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import java.util.List; @@ -22,6 +24,7 @@ import static org.mockito.Mockito.*; public class ExamplesCodeRefTest { + private static final String TEST_FEATURE = "classpath:feature/examples.feature"; private final String featureId = CommonUtils.namedId("feature_"); private final List exampleIds = Stream.generate(() -> CommonUtils.namedId("example_")).limit(2) .collect(Collectors.toList()); @@ -46,9 +49,15 @@ public void setupMock() { mockBatchLogging(client); } - @Test - public void test_examples_code_reference() { - var results = TestUtils.runAsReport(rp, "classpath:feature/examples.feature"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void test_examples_code_reference(boolean report) { + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor featureCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); diff --git a/src/test/java/com/epam/reportportal/karate/coderef/ScenarioCodeRefTest.java b/src/test/java/com/epam/reportportal/karate/coderef/ScenarioCodeRefTest.java index fe0c31e..d267413 100644 --- a/src/test/java/com/epam/reportportal/karate/coderef/ScenarioCodeRefTest.java +++ b/src/test/java/com/epam/reportportal/karate/coderef/ScenarioCodeRefTest.java @@ -6,8 +6,10 @@ import com.epam.reportportal.service.ReportPortalClient; import com.epam.reportportal.util.test.CommonUtils; import com.epam.ta.reportportal.ws.model.StartTestItemRQ; +import com.intuit.karate.Results; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import java.util.List; @@ -21,6 +23,7 @@ import static org.mockito.Mockito.*; public class ScenarioCodeRefTest { + private static final String TEST_FEATURE = "classpath:feature/simple.feature"; private final String featureId = CommonUtils.namedId("feature_"); private final String scenarioId = CommonUtils.namedId("scenario_"); private final List stepIds = Stream.generate(() -> CommonUtils.namedId("step_")) @@ -37,9 +40,15 @@ public void setupMock() { mockBatchLogging(client); } - @Test - public void test_scenario_code_reference() { - var results = TestUtils.runAsReport(rp, "classpath:feature/simple.feature"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void test_scenario_code_reference(boolean report) { + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor featureCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); diff --git a/src/test/java/com/epam/reportportal/karate/description/DescriptionExamplesTest.java b/src/test/java/com/epam/reportportal/karate/description/DescriptionExamplesTest.java index 6755c5c..3cee9d1 100644 --- a/src/test/java/com/epam/reportportal/karate/description/DescriptionExamplesTest.java +++ b/src/test/java/com/epam/reportportal/karate/description/DescriptionExamplesTest.java @@ -6,9 +6,11 @@ import com.epam.reportportal.service.ReportPortalClient; import com.epam.reportportal.util.test.CommonUtils; import com.epam.ta.reportportal.ws.model.StartTestItemRQ; +import com.intuit.karate.Results; import org.apache.commons.lang3.tuple.Pair; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import java.util.List; @@ -22,6 +24,7 @@ import static org.mockito.Mockito.*; public class DescriptionExamplesTest { + private static final String TEST_FEATURE = "classpath:feature/description_examples.feature"; private final String featureId = CommonUtils.namedId("feature_"); private final List exampleIds = Stream.generate(() -> CommonUtils.namedId("example_")).limit(2) .collect(Collectors.toList()); @@ -48,9 +51,15 @@ public void setupMock() { mockBatchLogging(client); } - @Test - public void test_examples_description() { - var results = TestUtils.runAsReport(rp, "classpath:feature/description_examples.feature"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void test_examples_description(boolean report) { + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor featureCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); diff --git a/src/test/java/com/epam/reportportal/karate/description/LaunchDescriptionTest.java b/src/test/java/com/epam/reportportal/karate/description/LaunchDescriptionTest.java index 91819f9..a255582 100644 --- a/src/test/java/com/epam/reportportal/karate/description/LaunchDescriptionTest.java +++ b/src/test/java/com/epam/reportportal/karate/description/LaunchDescriptionTest.java @@ -22,8 +22,10 @@ import com.epam.reportportal.service.ReportPortalClient; import com.epam.reportportal.util.test.CommonUtils; import com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ; +import com.intuit.karate.Results; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import java.util.List; @@ -37,6 +39,7 @@ import static org.mockito.Mockito.verify; public class LaunchDescriptionTest { + private static final String TEST_FEATURE = "classpath:feature/simple.feature"; private static final String TEST_DESCRIPTION = "My test description"; private final String featureId = CommonUtils.namedId("feature_"); private final String scenarioId = CommonUtils.namedId("scenario_"); @@ -55,9 +58,15 @@ public void setupMock() { mockBatchLogging(client); } - @Test - public void verify_start_launch_request_contains_launch_description() { - var results = TestUtils.runAsReport(rp, "classpath:feature/simple.feature"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void verify_start_launch_request_contains_launch_description(boolean report) { + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor startCaptor = ArgumentCaptor.forClass(StartLaunchRQ.class); diff --git a/src/test/java/com/epam/reportportal/karate/description/NoDescriptionExamplesTest.java b/src/test/java/com/epam/reportportal/karate/description/NoDescriptionExamplesTest.java index d8a896b..ddc57c0 100644 --- a/src/test/java/com/epam/reportportal/karate/description/NoDescriptionExamplesTest.java +++ b/src/test/java/com/epam/reportportal/karate/description/NoDescriptionExamplesTest.java @@ -6,9 +6,11 @@ import com.epam.reportportal.util.test.CommonUtils; import com.epam.reportportal.utils.markdown.MarkdownUtils; import com.epam.ta.reportportal.ws.model.StartTestItemRQ; +import com.intuit.karate.Results; import org.apache.commons.lang3.tuple.Pair; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import java.util.List; @@ -22,6 +24,7 @@ import static org.mockito.Mockito.*; public class NoDescriptionExamplesTest { + private static final String TEST_FEATURE = "classpath:feature/examples.feature"; private final String featureId = CommonUtils.namedId("feature_"); private final List exampleIds = Stream.generate(() -> CommonUtils.namedId("example_")).limit(2) .collect(Collectors.toList()); @@ -51,9 +54,15 @@ public void setupMock() { mockBatchLogging(client); } - @Test - public void test_examples_no_description() { - var results = TestUtils.runAsReport(rp, "classpath:feature/examples.feature"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void test_examples_no_description(boolean report) { + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor featureCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); diff --git a/src/test/java/com/epam/reportportal/karate/description/NoDescriptionTest.java b/src/test/java/com/epam/reportportal/karate/description/NoDescriptionTest.java index 05b4b97..d972090 100644 --- a/src/test/java/com/epam/reportportal/karate/description/NoDescriptionTest.java +++ b/src/test/java/com/epam/reportportal/karate/description/NoDescriptionTest.java @@ -5,8 +5,10 @@ import com.epam.reportportal.service.ReportPortalClient; import com.epam.reportportal.util.test.CommonUtils; import com.epam.ta.reportportal.ws.model.StartTestItemRQ; +import com.intuit.karate.Results; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import java.util.List; @@ -21,6 +23,7 @@ import static org.mockito.Mockito.*; public class NoDescriptionTest { + private static final String TEST_FEATURE = "classpath:feature/simple.feature"; private final String featureId = CommonUtils.namedId("feature_"); private final String scenarioId = CommonUtils.namedId("scenario_"); private final List stepIds = Stream.generate(() -> CommonUtils.namedId("step_")) @@ -35,9 +38,15 @@ public void setupMock() { mockBatchLogging(client); } - @Test - public void test_description_for_all_possible_items() { - var results = TestUtils.runAsReport(rp, "classpath:feature/simple.feature"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void test_description_for_all_possible_items(boolean report) { + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor featureCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); diff --git a/src/test/java/com/epam/reportportal/karate/description/NoLaunchDescriptionTest.java b/src/test/java/com/epam/reportportal/karate/description/NoLaunchDescriptionTest.java index e552cbd..f92c195 100644 --- a/src/test/java/com/epam/reportportal/karate/description/NoLaunchDescriptionTest.java +++ b/src/test/java/com/epam/reportportal/karate/description/NoLaunchDescriptionTest.java @@ -22,8 +22,10 @@ import com.epam.reportportal.service.ReportPortalClient; import com.epam.reportportal.util.test.CommonUtils; import com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ; +import com.intuit.karate.Results; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.mockito.ArgumentCaptor; @@ -40,6 +42,7 @@ import static org.mockito.Mockito.verify; public class NoLaunchDescriptionTest { + private static final String TEST_FEATURE = "classpath:feature/simple.feature"; private final String featureId = CommonUtils.namedId("feature_"); private final String scenarioId = CommonUtils.namedId("scenario_"); private final List stepIds = Stream.generate(() -> CommonUtils.namedId("step_")) @@ -53,21 +56,27 @@ public void setupMock() { mockBatchLogging(client); } - public static List dataValues() { - return Arrays.asList( + public static List dataValues() { + List descriptions = Arrays.asList( null, "", " " ); + return Arrays.asList(Arguments.of(true, descriptions), Arguments.of(false, descriptions)); } @ParameterizedTest @MethodSource("dataValues") - public void verify_start_launch_request_contains_no_launch_description(String description) { + public void verify_start_launch_request_contains_no_launch_description(boolean report, String description) { ListenerParameters parameters = standardParameters(); parameters.setDescription(description); ReportPortal rp = ReportPortal.create(client, parameters, testExecutor()); - var results = TestUtils.runAsReport(rp, "classpath:feature/simple.feature"); + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor startCaptor = ArgumentCaptor.forClass(StartLaunchRQ.class); diff --git a/src/test/java/com/epam/reportportal/karate/description/SimpleDescriptionTest.java b/src/test/java/com/epam/reportportal/karate/description/SimpleDescriptionTest.java index 94186ce..5b76ffb 100644 --- a/src/test/java/com/epam/reportportal/karate/description/SimpleDescriptionTest.java +++ b/src/test/java/com/epam/reportportal/karate/description/SimpleDescriptionTest.java @@ -5,10 +5,12 @@ import com.epam.reportportal.service.ReportPortalClient; import com.epam.reportportal.util.test.CommonUtils; import com.epam.ta.reportportal.ws.model.StartTestItemRQ; +import com.intuit.karate.Results; import com.intuit.karate.core.Background; import org.apache.commons.lang3.tuple.Pair; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import java.util.List; @@ -23,6 +25,7 @@ import static org.mockito.Mockito.*; public class SimpleDescriptionTest { + private static final String TEST_FEATURE = "classpath:feature/description.feature"; private final String featureId = CommonUtils.namedId("feature_"); private final String scenarioId = CommonUtils.namedId("scenario_"); private final List stepIds = Stream.generate(() -> CommonUtils.namedId("step_")) @@ -42,9 +45,15 @@ public void setupMock() { mockBatchLogging(client); } - @Test - public void test_description_for_all_possible_items() { - var results = TestUtils.runAsReport(rp, "classpath:feature/description.feature"); + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void test_description_for_all_possible_items(boolean report) { + Results results; + if (report) { + results = TestUtils.runAsReport(rp, TEST_FEATURE); + } else { + results = TestUtils.runAsHook(rp, TEST_FEATURE); + } assertThat(results.getFailCount(), equalTo(0)); ArgumentCaptor featureCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);