diff --git a/src/test/java/com/epam/reportportal/junit5/IssueReportingTest.java b/src/test/java/com/epam/reportportal/junit5/IssueReportingTest.java index e8c5e14..7547417 100644 --- a/src/test/java/com/epam/reportportal/junit5/IssueReportingTest.java +++ b/src/test/java/com/epam/reportportal/junit5/IssueReportingTest.java @@ -25,6 +25,7 @@ import com.epam.ta.reportportal.ws.model.OperationCompletionRS; import com.epam.ta.reportportal.ws.model.issue.Issue; import io.reactivex.Maybe; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; @@ -62,6 +63,11 @@ protected Launch getLaunch(ExtensionContext context) { private final Maybe stepThreeMaybe = Maybe.just(stepThreeId); private final Queue> stepIds = new LinkedList<>(Arrays.asList(stepOneMaybe, stepTwoMaybe, stepThreeMaybe)); + @BeforeAll + public static void setupProperty() { + System.setProperty("reportDisabledTests", Boolean.TRUE.toString()); + } + @BeforeEach public void setupMock() { Launch launch = mock(Launch.class); @@ -219,4 +225,20 @@ public void verify_two_dynamic_test_failures_two_issues() { assertThat(issue.getIssueType(), equalTo("pb001")); assertThat(issue.getComment(), equalTo(TwoDynamicTwoIssueTest.FAILURE_MESSAGE)); } + + @Test + public void verify_simple_test_skip() { + TestUtils.runClasses(SimpleSkippedIssueTest.class); + + Launch launch = IssueReportingTest.TestExtension.LAUNCH; + ArgumentCaptor testCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class); + verify(launch).finishTestItem(same(stepOneMaybe), testCaptor.capture()); + + FinishTestItemRQ finishTestItemRQ = testCaptor.getValue(); + assertThat(finishTestItemRQ.getStatus(), equalTo(ItemStatus.SKIPPED.name())); + assertThat(finishTestItemRQ.getIssue(), notNullValue()); + Issue issue = finishTestItemRQ.getIssue(); + assertThat(issue.getIssueType(), equalTo("pb001")); + assertThat(issue.getComment(), equalTo(SimpleSkippedIssueTest.FAILURE_MESSAGE)); + } } diff --git a/src/test/java/com/epam/reportportal/junit5/features/issue/SimpleSkippedIssueTest.java b/src/test/java/com/epam/reportportal/junit5/features/issue/SimpleSkippedIssueTest.java new file mode 100644 index 0000000..c82655d --- /dev/null +++ b/src/test/java/com/epam/reportportal/junit5/features/issue/SimpleSkippedIssueTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2024 EPAM Systems + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.epam.reportportal.junit5.features.issue; + +import com.epam.reportportal.annotations.Issue; +import com.epam.reportportal.junit5.IssueReportingTest; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +@ExtendWith(IssueReportingTest.TestExtension.class) +public class SimpleSkippedIssueTest { + + public static final String FAILURE_MESSAGE = "This test is expected to fail"; + + @Test + @Issue(value = "pb001", comment = FAILURE_MESSAGE) + @Disabled + public void failureTest() { + throw new IllegalStateException(FAILURE_MESSAGE); + } +}