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 19c772c commit 3e8cf83
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ protected StartTestItemRQ buildStartFeatureRq(@Nonnull FeatureRuntime fr) {

@Override
public boolean beforeFeature(FeatureRuntime fr) {
// TODO: add item start time test
Maybe<String> featureId = launch.get().startTestItem(buildStartFeatureRq(fr));
Feature feature = fr.featureCall.feature;
featureIdMap.put(feature.getNameForReport(), featureId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
import com.epam.reportportal.service.ReportPortalClient;
import com.epam.reportportal.util.test.CommonUtils;
import com.epam.ta.reportportal.ws.model.FinishTestItemRQ;
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 @@ -37,6 +39,7 @@
import static org.mockito.Mockito.*;

public class SimpleAllPassedTest {
private static final String TEST_FEATURE = "classpath:feature/simple.feature";
private final String launchUuid = CommonUtils.namedId("launch_");
private final String featureId = CommonUtils.namedId("feature_");
private final String scenarioId = CommonUtils.namedId("scenario_");
Expand All @@ -52,9 +55,15 @@ public void setupMock() {
mockBatchLogging(client);
}

@Test
public void test_simple_all_passed() {
var results = TestUtils.runAsReport(rp, "classpath:feature/simple.feature");
@ParameterizedTest
@ValueSource(booleans = {true, false})
public void test_simple_all_passed(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<FinishTestItemRQ> featureCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.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.FinishExecutionRQ;
import com.epam.ta.reportportal.ws.model.FinishTestItemRQ;
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.*;

public class SimpleOneStepFailedTest {
private static final String TEST_FEATURE = "classpath:feature/simple_failed.feature";
private final String launchUuid = CommonUtils.namedId("launch_");
private final String featureId = CommonUtils.namedId("feature_");
private final String scenarioId = CommonUtils.namedId("scenario_");
Expand All @@ -53,9 +56,15 @@ public void setupMock() {
mockBatchLogging(client);
}

@Test
public void test_simple_one_step_failed() {
var results = TestUtils.runAsReport(rp, "classpath:feature/simple_failed.feature");
@ParameterizedTest
@ValueSource(booleans = {true, false})
public void test_simple_one_step_failed(boolean report) {
Results results;
if (report) {
results = TestUtils.runAsReport(rp, TEST_FEATURE);
} else {
results = TestUtils.runAsHook(rp, TEST_FEATURE);
}
assertThat(results.getFailCount(), equalTo(1));

ArgumentCaptor<FinishTestItemRQ> featureCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
Expand Down

0 comments on commit 3e8cf83

Please sign in to comment.