Skip to content

Commit

Permalink
Add more @Issue annotation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Nov 6, 2024
1 parent dc65fac commit e0ed0e2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/test/java/com/epam/reportportal/junit5/IssueReportingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,6 +63,11 @@ protected Launch getLaunch(ExtensionContext context) {
private final Maybe<String> stepThreeMaybe = Maybe.just(stepThreeId);
private final Queue<Maybe<String>> 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);
Expand Down Expand Up @@ -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<FinishTestItemRQ> 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));
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit e0ed0e2

Please sign in to comment.