Skip to content

Commit

Permalink
Add test examples
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Nov 13, 2024
1 parent 6553e8f commit e5390da
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.testng.integration.feature.issue;

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 ParameterizedWithOneIssueTest {

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 = "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,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.testng.integration.feature.issue;

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 ParameterizedWithTwoIssueTest {

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);
}
}
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.testng.integration.feature.issue;

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,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.testng.integration.feature.issue;

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

public class SimpleSkippedIssueTest {

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

@Test(enabled = false)
@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,32 @@
/*
* 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.testng.integration.feature.issue;

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

public class SimpleTwoIssuesTest {

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

@Test
@Issue(value = "ab001", comment = FAILURE_MESSAGE)
@Issue(value = "pb001", comment = FAILURE_MESSAGE)
public void failureTest() {
throw new IllegalStateException(FAILURE_MESSAGE);
}
}

0 comments on commit e5390da

Please sign in to comment.