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 8, 2024
1 parent e21c219 commit 19c772c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import com.epam.reportportal.util.test.CommonUtils;
import com.epam.ta.reportportal.ws.model.ParameterResource;
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 ExamplesScenarioParametersTest {
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 @@ -39,9 +42,15 @@ public void setupMock() {
mockBatchLogging(client);
}

@Test
public void test_examples_scenario_parameters() {
var results = TestUtils.runAsReport(rp, "classpath:feature/examples.feature");
@ParameterizedTest
@ValueSource(booleans = {true, false})
public void test_examples_scenario_parameters(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 @@ -8,10 +8,12 @@
import com.epam.ta.reportportal.ws.model.ParameterResource;
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ;
import com.intuit.karate.Results;
import okhttp3.MultipartBody;
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.Collection;
Expand All @@ -30,6 +32,7 @@
import static org.mockito.Mockito.*;

public class ExamplesStepParametersTest {
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 @@ -54,10 +57,16 @@ private static Set<String> toParameterStringList(List<ParameterResource> paramet
.collect(Collectors.toSet());
}

@Test
@ParameterizedTest
@ValueSource(booleans = {true, false})
@SuppressWarnings({"unchecked", "rawtypes"})
public void test_examples_parameters_for_steps() {
var results = TestUtils.runAsReport(rp, "classpath:feature/examples.feature");
public void test_examples_parameters_for_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 @@ -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;
Expand All @@ -20,6 +22,7 @@
import static org.mockito.Mockito.*;

public class NoParametersTest {
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 @@ -34,9 +37,15 @@ public void setupMock() {
mockBatchLogging(client);
}

@Test
public void test_no_parameters_reporting() {
var results = TestUtils.runAsReport(rp, "classpath:feature/simple.feature");
@ParameterizedTest
@ValueSource(booleans = {true, false})
public void test_no_parameters_reporting(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 @@ -7,9 +7,11 @@
import com.epam.reportportal.util.test.CommonUtils;
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ;
import com.intuit.karate.Results;
import okhttp3.MultipartBody;
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 TableParametersTest {
private static final String TEST_FEATURE = "classpath:feature/table.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 @@ -38,10 +41,16 @@ public void setupMock() {
mockBatchLogging(client);
}

@Test
@ParameterizedTest
@ValueSource(booleans = {true, false})
@SuppressWarnings({"unchecked", "rawtypes"})
public void test_table_parameters_reporting() {
var results = TestUtils.runAsReport(rp, "classpath:feature/table.feature");
public void test_table_parameters_reporting(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
1 change: 1 addition & 0 deletions src/test/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
</appender>

<logger name="com.intuit.karate" level="DEBUG"/>
<logger name="com.epam.reportportal" level="WARN"/>

<!-- By default, the level of the root level is set to DEBUG -->
<root level="DEBUG">
Expand Down

0 comments on commit 19c772c

Please sign in to comment.