Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Jan 21, 2025
1 parent cf8c453 commit 5715c1a
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import static com.epam.reportportal.spock.utils.TestUtils.standardParameters;
import static com.epam.reportportal.spock.utils.TestUtils.testExecutor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.*;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
Expand All @@ -36,7 +35,7 @@ public class ExceptionErrorMessageWithDescriptionTest {

private final ReportPortalClient client = mock(ReportPortalClient.class);

private static final String ERROR_DESCRIPTION_EXCEPTION = "Setup: \nError:\njava.lang.IllegalStateException: Some test flow failure";
private static final String ERROR_DESCRIPTION_EXCEPTION = "Setup: \n\n---\n\nError:\njava.lang.IllegalStateException: Some test flow failure";

@BeforeEach
public void setupMock() {
Expand All @@ -47,10 +46,6 @@ public void setupMock() {

@Test
public void verify_error_exception_message_with_description() {

TestUtils.mockLaunch(client, launchId, classId, methodIds);
TestExtension.listener = new ReportPortalSpockListener(ReportPortal.create(client, standardParameters(), testExecutor()));

TestExecutionSummary result = runClasses(FailsInDifferentMethod.class);

assertThat(result.getTotalFailureCount(), equalTo(1L));
Expand All @@ -64,6 +59,6 @@ public void verify_error_exception_message_with_description() {
.collect(Collectors.toList());

assertThat(failedFinishItemStatuses, hasSize(1));
assertThat(failedFinishItemStatuses.iterator().next().getDescription(), equalTo(ERROR_DESCRIPTION_EXCEPTION));
assertThat(failedFinishItemStatuses.iterator().next().getDescription(), startsWith(ERROR_DESCRIPTION_EXCEPTION));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import static com.epam.reportportal.spock.utils.TestUtils.standardParameters;
import static com.epam.reportportal.spock.utils.TestUtils.testExecutor;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.*;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
Expand All @@ -36,7 +35,7 @@ public class ExceptionWithoutErrorMessageWithDescriptionTest {

private final ReportPortalClient client = mock(ReportPortalClient.class);

private static final String ERROR_DESCRIPTION_EXCEPTION = "Setup: \nWhen: \nThen: \nError:\njava.util.NoSuchElementException";
private static final String ERROR_DESCRIPTION_EXCEPTION = "Setup: \nWhen: \nThen: \n\n---\n\nError:\njava.util.NoSuchElementException";

@BeforeEach
public void setupMock() {
Expand All @@ -47,10 +46,6 @@ public void setupMock() {

@Test
public void verify_exception_without_error_message_with_description() {

TestUtils.mockLaunch(client, launchId, classId, methodIds);
TestExtension.listener = new ReportPortalSpockListener(ReportPortal.create(client, standardParameters(), testExecutor()));

TestExecutionSummary result = runClasses(FailWithExceptionWithoutMessage.class);

assertThat(result.getTotalFailureCount(), equalTo(1L));
Expand All @@ -65,6 +60,6 @@ public void verify_exception_without_error_message_with_description() {
.collect(Collectors.toList());

assertThat(failedFinishItemStatuses, hasSize(1));
assertThat(failedFinishItemStatuses.iterator().next().getDescription(), equalTo(ERROR_DESCRIPTION_EXCEPTION));
assertThat(failedFinishItemStatuses.iterator().next().getDescription(), startsWith(ERROR_DESCRIPTION_EXCEPTION));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void verify_setup_fixture_failure_correct_reporting() {

assertThat(result.getTotalFailureCount(), equalTo(1L));

verify(client).getProjectSettings();
verify(client).startLaunch(any());
verify(client).startTestItem(any(StartTestItemRQ.class));
ArgumentCaptor<StartTestItemRQ> startCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void verify_cleanup_fixture_correct_reporting() {

assertThat(result.getTotalFailureCount(), equalTo(0L));

verify(client).getProjectSettings();
verify(client).startLaunch(any());
verify(client).startTestItem(any(StartTestItemRQ.class));
ArgumentCaptor<StartTestItemRQ> startCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void verify_setup_fixture_failure_correct_reporting() {

assertThat(result.getTotalFailureCount(), equalTo(1L));

verify(client).getProjectSettings();
verify(client).startLaunch(any());
verify(client).startTestItem(any(StartTestItemRQ.class));
ArgumentCaptor<StartTestItemRQ> startCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void verify_spec_fixture_correct_reporting() {

assertThat(result.getTotalFailureCount(), equalTo(0L));

verify(client).getProjectSettings();
verify(client).startLaunch(any());
verify(client).startTestItem(any(StartTestItemRQ.class));
ArgumentCaptor<StartTestItemRQ> startCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void verify_setup_fixture_failure_correct_reporting_parameterized_feature

assertThat(result.getTotalFailureCount(), equalTo(1L));

verify(client).getProjectSettings();
verify(client).startLaunch(any());
verify(client).startTestItem(any(StartTestItemRQ.class));
verify(client).startTestItem(same(classId), any(StartTestItemRQ.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void verify_setup_fixture_failure_correct_reporting() {

assertThat(result.getTotalFailureCount(), equalTo(1L));

verify(client).getProjectSettings();
verify(client).startLaunch(any());
verify(client).startTestItem(any(StartTestItemRQ.class));
ArgumentCaptor<StartTestItemRQ> startCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void verify_setup_fixture_correct_reporting() {

assertThat(result.getTotalFailureCount(), equalTo(0L));

verify(client).getProjectSettings();
verify(client).startLaunch(any());
verify(client).startTestItem(any(StartTestItemRQ.class));
ArgumentCaptor<StartTestItemRQ> startCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void verify_setup_spec_failure_correct_reporting() {

assertThat(result.getTotalFailureCount(), equalTo(1L));

verify(client).getProjectSettings();
verify(client).startLaunch(any());
verify(client).startTestItem(any(StartTestItemRQ.class));
ArgumentCaptor<StartTestItemRQ> startFeatureCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void verify_setup_spec_failure_parameters_unroll_correct_reporting() {

assertThat(result.getTotalFailureCount(), equalTo(1L));

verify(client).getProjectSettings();
verify(client).startLaunch(any());
verify(client).startTestItem(any(StartTestItemRQ.class));
ArgumentCaptor<StartTestItemRQ> startFeatureCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void verify_setup_spec_fixture_correct_reporting() {

assertThat(result.getTotalFailureCount(), equalTo(0L));

verify(client).getProjectSettings();
verify(client).startLaunch(any());
verify(client).startTestItem(any(StartTestItemRQ.class));
ArgumentCaptor<StartTestItemRQ> startCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void verify_setup_fixture_failure_correct_reporting_unrolled_feature() {

assertThat(result.getTotalFailureCount(), equalTo(3L));

verify(client).getProjectSettings();
verify(client).startLaunch(any());
verify(client).startTestItem(any(StartTestItemRQ.class));
ArgumentCaptor<StartTestItemRQ> startCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
Expand Down

0 comments on commit 5715c1a

Please sign in to comment.