Skip to content

Commit

Permalink
ReportPortalHook: Tests WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Jan 5, 2024
1 parent 7028aa8 commit db08eda
Show file tree
Hide file tree
Showing 15 changed files with 195 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> stepIds = Stream.generate(() -> CommonUtils.namedId("step_"))
Expand All @@ -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<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> stepIds = Stream.generate(() -> CommonUtils.namedId("step_"))
Expand All @@ -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<StartLaunchRQ> startCaptor = ArgumentCaptor.forClass(StartLaunchRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> stepIds = Stream.generate(() -> CommonUtils.namedId("step_"))
Expand All @@ -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<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> stepIds = Stream.generate(() -> CommonUtils.namedId("step_"))
Expand All @@ -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<StartLaunchRQ> startCaptor = ArgumentCaptor.forClass(StartLaunchRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> scenarioIds = Stream.generate(() -> CommonUtils.namedId("scenario_"))
.limit(2).collect(Collectors.toList());
Expand All @@ -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<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> stepIds = Stream.generate(() -> CommonUtils.namedId("step_"))
Expand All @@ -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<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> stepIds = Stream.generate(() -> CommonUtils.namedId("step_"))
Expand All @@ -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<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> exampleIds = Stream.generate(() -> CommonUtils.namedId("example_")).limit(2)
.collect(Collectors.toList());
Expand All @@ -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<StartTestItemRQ> featureCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> stepIds = Stream.generate(() -> CommonUtils.namedId("step_"))
Expand All @@ -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<StartTestItemRQ> featureCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> exampleIds = Stream.generate(() -> CommonUtils.namedId("example_")).limit(2)
.collect(Collectors.toList());
Expand All @@ -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<StartTestItemRQ> featureCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Loading

0 comments on commit db08eda

Please sign in to comment.