Skip to content

Commit

Permalink
Add @Issue annotation examples
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Nov 13, 2024
1 parent 1053d7c commit fcdb701
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.example.junit5.annotated;

import com.epam.reportportal.annotations.Issue;
import org.junit.jupiter.api.Test;

public class SimpleIssueTest {

public static final String FAILURE_MESSAGE = "This test is expected to fail";

@Test
@Issue(value = "pb001", comment = FAILURE_MESSAGE)
public void failureTest() {
throw new IllegalStateException(FAILURE_MESSAGE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.example.junit5.annotated;

import com.epam.reportportal.annotations.Issue;
import com.epam.reportportal.annotations.TestFilter;
import com.epam.reportportal.annotations.TestParamFilter;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

public class TwoIssuesTest {

public static final String FAILURE_MESSAGE = "This parameterized test is expected to fail: ";
public static final String ISSUE_MESSAGE = "This test is expected to fail";

@ParameterizedTest
@ValueSource(booleans = { true, false })
@Issue(value = "ab001", comment = ISSUE_MESSAGE, filter = @TestFilter(param = { @TestParamFilter(valueStartsWith = "true") }))
@Issue(value = "pb001", comment = ISSUE_MESSAGE, filter = @TestFilter(param = { @TestParamFilter(valueStartsWith = "false") }))
public void failureTest(boolean param) {
throw new IllegalStateException(FAILURE_MESSAGE + param);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.example.testng.logback.annotated;

import com.epam.reportportal.annotations.Issue;
import org.testng.annotations.Test;

public class SimpleIssueTest {

public static final String FAILURE_MESSAGE = "This test is expected to fail";

@Test
@Issue(value = "pb001", comment = FAILURE_MESSAGE)
public void failureTest() {
throw new IllegalStateException(FAILURE_MESSAGE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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.example.testng.logback.annotated;

import com.epam.reportportal.annotations.Issue;
import com.epam.reportportal.annotations.TestFilter;
import com.epam.reportportal.annotations.TestParamFilter;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class TwoIssuesTest {

public static final String FAILURE_MESSAGE = "This parameterized test is expected to fail: ";
public static final String ISSUE_MESSAGE = "This test is expected to fail";

public static final Object[][] PARAMS = { { true }, { false } };

@DataProvider
public static Object[][] paramsProvider() {
return PARAMS;
}

@Test(dataProvider = "paramsProvider")
@Issue(value = "ab001", comment = ISSUE_MESSAGE, filter = @TestFilter(param = { @TestParamFilter(valueStartsWith = "true") }))
@Issue(value = "pb001", comment = ISSUE_MESSAGE, filter = @TestFilter(param = { @TestParamFilter(valueStartsWith = "false") }))
public void failureTest(boolean param) {
throw new IllegalStateException(FAILURE_MESSAGE + param);
}
}
15 changes: 15 additions & 0 deletions example-testng-logback/suites/custom_annotations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,19 @@
<class name="com.epam.reportportal.example.testng.logback.annotated.DisplayNameTest" />
</classes>
</test>
<test name="Test case id test">
<classes>
<class name="com.epam.reportportal.example.testng.logback.annotated.TestCaseIdTest"/>
</classes>
</test>
<test name="Runtime Issue reporting for simple test">
<classes>
<class name="com.epam.reportportal.example.testng.logback.annotated.SimpleIssueTest"/>
</classes>
</test>
<test name="Runtime Issue reporting for parameterized test">
<classes>
<class name="com.epam.reportportal.example.testng.logback.annotated.TwoIssuesTest"/>
</classes>
</test>
</suite>
9 changes: 0 additions & 9 deletions example-testng-logback/suites/test_case_id_suite.xml

This file was deleted.

0 comments on commit fcdb701

Please sign in to comment.