├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── ci.yml │ └── qg-example.yml ├── .gitignore ├── .gitlab-ci.yml ├── LICENSE ├── README.md ├── example-cucumber ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── epam │ │ └── reportportal │ │ └── example │ │ └── cucumber │ │ ├── Belly.java │ │ └── reporter │ │ └── ScenarioReporterTestCaseId.java │ └── test │ ├── groovy │ ├── RunStepReporterTest.groovy │ └── cucumber │ │ └── Stepdefs.groovy │ ├── java │ └── com │ │ └── epam │ │ └── reportportal │ │ └── example │ │ └── cucumber │ │ ├── RunLoggingTest.java │ │ ├── RunScenarioReporterTest.java │ │ ├── RunStepReporterTest.java │ │ ├── attribute │ │ └── Stepdefs.java │ │ ├── logging │ │ ├── DataTableTest.java │ │ ├── Hooks.java │ │ ├── LaunchLog.java │ │ ├── LogLevelTest.java │ │ ├── ParametersTest.java │ │ ├── ReportAttachmentsTest.java │ │ ├── ReportsStepWithDefectTest.java │ │ └── ReportsTestWithParameters.java │ │ └── util │ │ ├── Attachment.java │ │ ├── AttachmentHelper.java │ │ ├── LoggingUtils.java │ │ └── MagicRandomizer.java │ └── resources │ ├── features │ ├── attribute │ │ └── belly.feature │ └── logging │ │ ├── dataTableTest.feature │ │ ├── hooks.feature │ │ ├── launchLog.feature │ │ ├── logLevelTest.feature │ │ ├── reportAttachmentsTest.feature │ │ ├── reportsTestWithParametrs.feature │ │ └── testWithDefects.feature │ ├── files │ ├── file.cmd │ ├── file.css │ ├── file.csv │ ├── file.har │ ├── file.html │ ├── file.jpg │ ├── file.js │ ├── file.json │ ├── file.pdf │ ├── file.php │ ├── file.png │ ├── file.tar │ ├── file.tar.gz │ ├── file.txt │ ├── file.xml │ └── file.zip │ ├── logback.xml │ ├── pug │ ├── lucky.jpg │ └── unlucky.jpg │ └── reportportal.properties ├── example-cucumber4 ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── epam │ │ └── reportportal │ │ └── example │ │ └── cucumber4 │ │ ├── Belly.java │ │ └── reporter │ │ ├── ScenarioReporterNoSuite.java │ │ └── ScenarioReporterTestCaseId.java │ └── test │ ├── java │ └── com │ │ └── epam │ │ └── reportportal │ │ └── example │ │ └── cucumber4 │ │ ├── RunLoggingTest.java │ │ ├── RunScenarioReporterNoRootStoryTest.java │ │ ├── RunScenarioReporterTest.java │ │ ├── RunStepReporterTest.java │ │ ├── attribute │ │ └── Stepdefs.java │ │ ├── logging │ │ ├── Hooks.java │ │ ├── LaunchLog.java │ │ ├── LogLevelTest.java │ │ ├── ParametersTest.java │ │ ├── ReportAttachmentsTest.java │ │ ├── ReportsStepWithDefectTest.java │ │ └── ReportsTestWithParameters.java │ │ └── util │ │ ├── Attachment.java │ │ ├── AttachmentHelper.java │ │ ├── LoggingUtils.java │ │ └── MagicRandomizer.java │ └── resources │ ├── features │ ├── attribute │ │ └── belly.feature │ └── logging │ │ ├── hooks.feature │ │ ├── launchLog.feature │ │ ├── logLevelTest.feature │ │ ├── reportAttachmentsTest.feature │ │ ├── reportsTestWithParametrs.feature │ │ └── testWithDefects.feature │ ├── files │ ├── file.cmd │ ├── file.css │ ├── file.csv │ ├── file.har │ ├── file.html │ ├── file.jpg │ ├── file.js │ ├── file.json │ ├── file.pdf │ ├── file.php │ ├── file.png │ ├── file.tar │ ├── file.tar.gz │ ├── file.txt │ ├── file.xml │ └── file.zip │ ├── logback.xml │ ├── pug │ ├── lucky.jpg │ └── unlucky.jpg │ └── reportportal.properties ├── example-cucumber6-testng ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── epam │ │ └── reportportal │ │ └── example │ │ └── cucumber6 │ │ └── Belly.java │ └── test │ ├── java │ └── com │ │ └── epam │ │ └── reportportal │ │ └── example │ │ └── cucumber6 │ │ ├── BasicRunTest.java │ │ └── attributes │ │ └── Stepdefs.java │ └── resources │ ├── features │ └── attributes │ │ └── belly.feature │ ├── logback.xml │ └── reportportal.properties ├── example-cucumber6 ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── epam │ │ └── reportportal │ │ └── example │ │ └── cucumber6 │ │ └── Belly.java │ └── test │ ├── java │ └── com │ │ └── epam │ │ └── reportportal │ │ └── example │ │ └── cucumber6 │ │ ├── BasicReRunTest.java │ │ ├── BasicRunTest.java │ │ ├── attributes │ │ └── AttributeReporter.java │ │ └── glue │ │ ├── attributes │ │ └── Stepdefs.java │ │ ├── logging │ │ ├── LaunchIdLogging.java │ │ └── LaunchUrlLogging.java │ │ └── selenium │ │ └── ScreenshotOnFailureHooks.java │ └── resources │ ├── features │ ├── attributes │ │ ├── belly.feature │ │ └── key-value.feature │ ├── logging │ │ ├── launchIdLogging.feature │ │ └── launchUrlLogging.feature │ └── selenium │ │ └── screenshot.feature │ ├── logback.xml │ └── reportportal.properties ├── example-jbehave ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── epam │ │ └── reportportal │ │ └── example │ │ └── jbehave │ │ ├── MyStoriesTest.java │ │ ├── steps │ │ ├── ApiSteps.java │ │ ├── LogLevelTest.java │ │ ├── ReportAttachmentsTest.java │ │ ├── ReportsStepWithDefectTest.java │ │ └── ReportsTestWithParameters.java │ │ └── util │ │ ├── AttachmentHelper.java │ │ ├── LoggingUtils.java │ │ └── MagicRandomizer.java │ └── resources │ ├── files │ ├── Test.cmd │ ├── Test.csv │ ├── css.css │ ├── demo.zip │ ├── file.css │ ├── file.json │ ├── file.xml │ ├── har.har │ ├── html.html │ ├── javascript.js │ ├── php.php │ ├── plain.txt │ └── test.pdf │ ├── log4j2.xml │ ├── pug │ ├── lucky.jpg │ └── unlucky.jpg │ ├── reportportal.properties │ ├── story │ ├── dashboard.story │ ├── logLevelTest.story │ ├── precondition.story │ ├── reportAttachmentsTest.story │ ├── reportsTestWithParametrs.story │ ├── testWithDefects.story │ └── widget.story │ └── xml │ ├── file.json │ └── file.xml ├── example-junit ├── pom.xml └── src │ └── test │ ├── java │ └── com │ │ └── epam │ │ └── reportportal │ │ └── example │ │ └── junit │ │ ├── DummyTest.java │ │ ├── ExpectToFail.java │ │ ├── FailedTest.java │ │ ├── LaunchLogTest.java │ │ ├── LoggingSuite.java │ │ ├── NestedStepTest.java │ │ ├── annotated │ │ ├── TestCaseIdParameterizedTest.java │ │ └── TestCaseIdTest.java │ │ ├── attribute │ │ ├── ItemAttributeTest.java │ │ └── SaucelabsAttributeTest.java │ │ ├── callback │ │ └── CallbackTest.java │ │ ├── extension │ │ ├── JUnitRetryImpl.java │ │ └── RetryTest.java │ │ ├── logging │ │ ├── AfterAndBeforeMethodTest.java │ │ ├── JsonLoggingTest.java │ │ ├── LoggingTest.java │ │ ├── LuckyPugTest.java │ │ └── XmlLoggingTest.java │ │ ├── parametrized │ │ └── ParameterizedTest.java │ │ ├── suites │ │ ├── SuiteOfSuiteTest.java │ │ └── SuiteTest.java │ │ └── util │ │ ├── Attachment.java │ │ ├── AttachmentHelper.java │ │ ├── LoggingUtils.java │ │ └── MagicRandomizer.java │ └── resources │ ├── META-INF │ ├── aop-ajc.xml │ └── services │ │ ├── com.nordstrom.automation.junit.JUnitRetryAnalyzer │ │ └── com.nordstrom.automation.junit.JUnitWatcher │ ├── files │ ├── file.cmd │ ├── file.css │ ├── file.csv │ ├── file.har │ ├── file.html │ ├── file.jpg │ ├── file.js │ ├── file.json │ ├── file.pdf │ ├── file.php │ ├── file.png │ ├── file.tar │ ├── file.tar.gz │ ├── file.txt │ ├── file.xml │ └── file.zip │ ├── logback.xml │ ├── pug │ ├── lucky.jpg │ └── unlucky.jpg │ ├── reportportal.properties │ └── xml │ ├── file.json │ └── file.xml ├── example-junit5 ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── epam │ │ └── reportportal │ │ └── example │ │ └── junit5 │ │ ├── ScreenShootOnFailureExtension.java │ │ └── util │ │ ├── Attachment.java │ │ ├── AttachmentHelper.java │ │ └── LoggingUtils.java │ └── test │ ├── java │ └── com │ │ └── epam │ │ └── reportportal │ │ └── example │ │ └── junit5 │ │ ├── CallbackTests.java │ │ ├── JUnit5Tests.java │ │ ├── LaunchLogTest.java │ │ ├── LogTest.java │ │ ├── ParametrizedTest.java │ │ ├── RetryTest.java │ │ ├── TestCaseIdTest.java │ │ ├── annotated │ │ ├── DescriptionTest.java │ │ ├── DisplayNameTest.java │ │ ├── JUnit5Tests.java │ │ ├── SimpleIssueTest.java │ │ └── TwoIssuesTest.java │ │ ├── attribute │ │ ├── ItemAttributeTest.java │ │ └── SaucelabsAttributeTest.java │ │ ├── logging │ │ ├── AfterAndBeforeMethodTest.java │ │ ├── ReportsStepWithDefectTest.java │ │ └── SelenideScreenshotLoggingTest.java │ │ └── nested │ │ ├── step │ │ ├── AnnotationNestedStepsComparingTest.java │ │ ├── AnnotationNestedStepsDemoTest.java │ │ └── pattern │ │ │ ├── Container.java │ │ │ ├── Item.java │ │ │ └── PatternTest.java │ │ └── test │ │ └── JunitNestedTest.java │ └── resources │ ├── META-INF │ ├── aop-ajc.xml │ └── services │ │ └── org.junit.jupiter.api.extension.Extension │ ├── files │ ├── file.cmd │ ├── file.css │ ├── file.csv │ ├── file.har │ ├── file.html │ ├── file.jpg │ ├── file.js │ ├── file.json │ ├── file.pdf │ ├── file.php │ ├── file.png │ ├── file.tar │ ├── file.tar.gz │ ├── file.txt │ ├── file.xml │ └── file.zip │ ├── junit-platform.properties │ ├── logback.xml │ └── reportportal.properties ├── example-soapui └── project │ └── soapui-example-project.xml ├── example-spock ├── pom.xml └── src │ └── test │ ├── groovy │ └── com │ │ └── epam │ │ └── reportportal │ │ └── example │ │ └── spock │ │ ├── HelloLoggingSpec.groovy │ │ ├── HelloSpockSpec.groovy │ │ ├── HelloSpockSpecInherited.groovy │ │ ├── HelloSpockSpecUnroll.groovy │ │ ├── OrderedInteractionsSpec.groovy │ │ ├── attributes │ │ ├── FixtureAttributesSpec.groovy │ │ └── SpecAttributes.groovy │ │ ├── fail │ │ ├── FailsInDifferentMethodSpec.groovy │ │ ├── FailsWithAnnotationFailSpec.groovy │ │ ├── HelloSpockSpecFailed.groovy │ │ └── HelloSpockSpecUnrollFailed.groovy │ │ ├── fixtures │ │ ├── CleanupFixtureFailedSpec.groovy │ │ ├── CleanupFixtureSpec.groovy │ │ ├── CleanupSpecFixture.groovy │ │ ├── CleanupSpecFixtureFailed.groovy │ │ ├── SetupFixtureFailedParametersSpec.groovy │ │ ├── SetupFixtureFailedParametersUnrollSpec.groovy │ │ ├── SetupFixtureFailedSpec.groovy │ │ ├── SetupFixtureSpec.groovy │ │ ├── SetupSpecFixture.groovy │ │ ├── SetupSpecFixtureFailed.groovy │ │ └── SetupSpecFixtureFailedParametersUnroll.groovy │ │ ├── ignore │ │ ├── TestOneFeatureIgnoreSpec.groovy │ │ └── TestRestFeaturesIgnoreSpec.groovy │ │ ├── params │ │ ├── NullParamSpec.groovy │ │ └── NullParamSpecUnroll.groovy │ │ └── testcaseid │ │ └── PlainTestCaseIdSpec.groovy │ └── resources │ ├── META-INF │ └── services │ │ └── org.spockframework.runtime.extension.IGlobalExtension │ ├── logback.xml │ └── reportportal.properties ├── example-testng-fork-execution ├── pom.xml ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── epam │ │ │ └── reportportal │ │ │ └── example │ │ │ └── testng │ │ │ └── logback │ │ │ ├── logging │ │ │ ├── LaunchUrlLoggingTest.java │ │ │ ├── LoggingTest.java │ │ │ ├── LuckyPugTest.java │ │ │ └── XmlLoggingTest.java │ │ │ └── util │ │ │ ├── AttachmentHelper.java │ │ │ ├── LoggingUtils.java │ │ │ └── MagicRandomizer.java │ │ └── resources │ │ ├── META-INF │ │ ├── aop-ajc.xml │ │ └── services │ │ │ └── org.testng.ITestNGListener │ │ ├── files │ │ ├── Test.cmd │ │ ├── Test.csv │ │ ├── css.css │ │ ├── demo.zip │ │ ├── har.har │ │ ├── html.html │ │ ├── javascript.js │ │ ├── php.php │ │ ├── plain.txt │ │ └── test.pdf │ │ ├── logback.xml │ │ ├── pug │ │ ├── lucky.jpg │ │ └── unlucky.jpg │ │ ├── reportportal.properties │ │ └── xml │ │ └── file.xml └── suites │ ├── logging_tests.xml │ └── logging_xml_tests.xml ├── example-testng-log4j ├── pom.xml ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── epam │ │ │ └── reportportal │ │ │ └── example │ │ │ └── testng │ │ │ └── log4j │ │ │ ├── extension │ │ │ └── ScreenshotOnFailureTestExtensionTest.java │ │ │ ├── logging │ │ │ ├── JsonLoggingTest.java │ │ │ ├── LoggingTest.java │ │ │ ├── LuckyPugTest.java │ │ │ └── XmlLoggingTest.java │ │ │ ├── parametrized │ │ │ └── ParametrizedTest.java │ │ │ ├── step │ │ │ ├── NestedStepsTest.java │ │ │ ├── NestedStepsWithDataProvider.java │ │ │ └── pattern │ │ │ │ ├── Container.java │ │ │ │ ├── Item.java │ │ │ │ └── PatternTest.java │ │ │ └── util │ │ │ ├── AttachmentHelper.java │ │ │ ├── LoggingUtils.java │ │ │ └── MagicRandomizer.java │ │ └── resources │ │ ├── META-INF │ │ ├── aop-ajc.xml │ │ └── services │ │ │ └── org.testng.ITestNGListener │ │ ├── files │ │ ├── Test.cmd │ │ ├── Test.csv │ │ ├── css.css │ │ ├── demo.zip │ │ │ └── demo.txt │ │ ├── html.html │ │ ├── javascript.js │ │ ├── php.php │ │ ├── plain.txt │ │ ├── test.pdf │ │ └── yaml.yml │ │ ├── log4j2.xml │ │ ├── pug │ │ ├── lucky.jpg │ │ └── unlucky.jpg │ │ ├── reportportal.properties │ │ └── xml │ │ ├── file.json │ │ └── file.xml └── suites │ ├── logging_tests.xml │ └── nested_steps_tests.xml ├── example-testng-logback ├── pom.xml ├── screenshots │ ├── fifth.png │ ├── first.png │ ├── fourth.png │ ├── second.png │ ├── sixth.png │ └── third.png ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── epam │ │ │ └── reportportal │ │ │ └── example │ │ │ └── testng │ │ │ └── logback │ │ │ ├── annotated │ │ │ ├── DescriptionTest.java │ │ │ ├── DisplayNameTest.java │ │ │ ├── SimpleIssueTest.java │ │ │ ├── TestCaseIdTest.java │ │ │ └── TwoIssuesTest.java │ │ │ ├── attribute │ │ │ └── ItemAttributeTest.java │ │ │ ├── bugs │ │ │ └── ReproduceItemIdTest.java │ │ │ ├── callback │ │ │ ├── CallbackReportingTest.java │ │ │ └── SaucelabsIntegrationTest.java │ │ │ ├── extension │ │ │ ├── ParametersAsAttributesTest.java │ │ │ ├── RetriedTestReasonReportingTest.java │ │ │ ├── RetryTest.java │ │ │ ├── RuntimeAttributesTest.java │ │ │ └── ScreenshotOnFailureTestExtensionTest.java │ │ │ ├── logging │ │ │ ├── JsonLoggingTest.java │ │ │ ├── LaunchUrlLoggingTest.java │ │ │ ├── LoggingTest.java │ │ │ ├── LuckyPugTest.java │ │ │ ├── ScreenshotOnFailureSimpleTest.java │ │ │ ├── SelenideLoggingTest.java │ │ │ ├── XmlLoggingTest.java │ │ │ ├── httpcomponents │ │ │ │ ├── HttpComponentsBasicLoggingTest.java │ │ │ │ ├── HttpComponentsFormTest.java │ │ │ │ └── HttpComponentsMultipartTest.java │ │ │ ├── okhttp3 │ │ │ │ ├── OkHttp3BasicLoggingTest.java │ │ │ │ ├── OkHttp3FormTest.java │ │ │ │ └── OkHttp3MultipartTest.java │ │ │ └── restassured │ │ │ │ ├── RestAssuredAdvanceSanitizeTest.java │ │ │ │ ├── RestAssuredBasicLoggingTest.java │ │ │ │ ├── RestAssuredFormTest.java │ │ │ │ └── RestAssuredSimpleSanitizeTest.java │ │ │ ├── parameterized │ │ │ └── ParameterizedTest.java │ │ │ ├── preconditions │ │ │ ├── FailedAftersTest.java │ │ │ └── FailedBeforesTest.java │ │ │ ├── randomizer │ │ │ ├── TestRandomizer.java │ │ │ └── TestRandomizerBoundaries.java │ │ │ ├── step │ │ │ ├── NestedStepsTest.java │ │ │ ├── NestedStepsWithDataProvider.java │ │ │ └── pattern │ │ │ │ ├── Container.java │ │ │ │ ├── Item.java │ │ │ │ └── PatternTest.java │ │ │ └── util │ │ │ ├── AttachmentHelper.java │ │ │ ├── LoggingUtils.java │ │ │ └── MagicRandomizer.java │ │ └── resources │ │ ├── META-INF │ │ ├── aop-ajc.xml │ │ └── services │ │ │ └── org.testng.ITestNGListener │ │ ├── files │ │ ├── Test.cmd │ │ ├── Test.csv │ │ ├── css.css │ │ ├── demo.zip │ │ ├── har.har │ │ ├── html.html │ │ ├── javascript.js │ │ ├── php.php │ │ ├── plain.txt │ │ └── test.pdf │ │ ├── logback.xml │ │ ├── pug │ │ ├── lucky.jpg │ │ └── unlucky.jpg │ │ ├── reportportal.properties │ │ └── xml │ │ ├── file.json │ │ └── file.xml └── suites │ ├── attribute.xml │ ├── callback_suite.xml │ ├── custom_annotations.xml │ ├── issue27.xml │ ├── logging_inner_tests.xml │ ├── logging_tests.xml │ ├── nested_steps_tests.xml │ ├── parameterized_tests.xml │ ├── preconditions_suite.xml │ └── randomizer_suite.xml └── pom.xml /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **Steps to Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. ... 16 | 2. ... 17 | 18 | **Expected behavior** 19 | A clear and concise description of what you expected to happen. 20 | 21 | **Actual behavior** 22 | What actually happened. 23 | 24 | **Dependency versions** 25 | Include version info of the following libraries: client-java, agent library you use 26 | 27 | **Additional context** 28 | Add any other context about the problem here. 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the issue is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 EPAM Systems 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | 14 | name: CI Build 15 | 16 | on: 17 | push: 18 | branches: 19 | - '*' 20 | 21 | jobs: 22 | build: 23 | runs-on: ubuntu-latest 24 | steps: 25 | - name: Checkout repository 26 | uses: actions/checkout@v4 27 | 28 | - name: Set up JDK 11 29 | uses: actions/setup-java@v4 30 | with: 31 | distribution: 'temurin' 32 | java-version: '11' 33 | 34 | - name: Compile with Maven 35 | run: mvn -B test-compile 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.rar 19 | 20 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 21 | hs_err_pid* 22 | 23 | build/ 24 | .gradle/ 25 | gradle/ 26 | 27 | # Maven build artifacts 28 | target/ 29 | */target/ 30 | 31 | # Idea files 32 | *.iml 33 | .idea/ 34 | out/ 35 | test-output/ 36 | 37 | .settings 38 | .project 39 | .classpath 40 | .DS_Store 41 | bin/ 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Java examples of Report Portal usage for different frameworks 2 | [![CI Build](https://github.com/reportportal/examples-java/actions/workflows/ci.yml/badge.svg)](https://github.com/reportportal/examples-java/actions/workflows/ci.yml) 3 | [![Join Slack chat!](https://img.shields.io/badge/slack-join-brightgreen.svg)](https://slack.epmrpp.reportportal.io/) 4 | -------------------------------------------------------------------------------- /example-cucumber/src/main/java/com/epam/reportportal/example/cucumber/Belly.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber; 2 | 3 | public class Belly { 4 | 5 | private int satiation = 0; 6 | 7 | public void eat(int cukes) { 8 | satiation += cukes; 9 | } 10 | 11 | public void wait(int hours) { 12 | if ((hours > 0) && (satiation > 0)) { 13 | int utilized = 60 * hours; 14 | if (utilized > satiation) { 15 | utilized = satiation; 16 | } 17 | satiation -= utilized; 18 | } 19 | } 20 | 21 | public boolean growl() { 22 | return satiation <= 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example-cucumber/src/test/groovy/RunStepReporterTest.groovy: -------------------------------------------------------------------------------- 1 | import cucumber.api.CucumberOptions 2 | import cucumber.api.junit.Cucumber 3 | import org.junit.runner.RunWith 4 | 5 | /* 6 | * Copyright 2021 EPAM Systems 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | @RunWith(Cucumber.class) 22 | @CucumberOptions(plugin = ["pretty", "com.epam.reportportal.cucumber.StepReporter"], features = ["src/test/resources/features/attribute"], 23 | glue = ["src/test/groovy/cucumber"]) 24 | class RunStepReporterTest { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /example-cucumber/src/test/groovy/cucumber/Stepdefs.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package cucumber 18 | 19 | 20 | import com.epam.reportportal.example.cucumber.Belly 21 | 22 | import static cucumber.api.groovy.EN.* 23 | import static org.junit.Assert.assertTrue 24 | 25 | Belly belly = new Belly(); 26 | 27 | Given(~'^I have (\\d+) cukes in my belly$') { int cukes -> 28 | belly.eat(cukes) 29 | } 30 | 31 | When(~'^I wait (\\d+) hour$') { int hours -> 32 | belly.wait(hours) 33 | } 34 | 35 | Then(~'^my belly should growl$') { -> 36 | assertTrue(belly.growl()) 37 | } 38 | -------------------------------------------------------------------------------- /example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/RunLoggingTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber; 2 | 3 | import cucumber.api.CucumberOptions; 4 | import cucumber.api.junit.Cucumber; 5 | import org.junit.runner.RunWith; 6 | 7 | @RunWith(Cucumber.class) 8 | @CucumberOptions(plugin = { "pretty", 9 | "com.epam.reportportal.cucumber.StepReporter" }, features = "src/test/resources/features/logging", tags = "~@ignore") 10 | public class RunLoggingTest { 11 | } 12 | -------------------------------------------------------------------------------- /example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/RunScenarioReporterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.cucumber; 18 | 19 | import com.epam.reportportal.example.cucumber.reporter.ScenarioReporterTestCaseId; 20 | import cucumber.api.CucumberOptions; 21 | import cucumber.api.junit.Cucumber; 22 | import org.junit.runner.RunWith; 23 | 24 | /** 25 | * A JUnit runner for Cucumber which is using customized {@link ScenarioReporterTestCaseId} reporter. 26 | */ 27 | @RunWith(Cucumber.class) 28 | @CucumberOptions(plugin = { "pretty", "com.epam.reportportal.example.cucumber.reporter.ScenarioReporterTestCaseId" }, 29 | features = "src/test/resources/features/attribute") 30 | public class RunScenarioReporterTest { 31 | } 32 | -------------------------------------------------------------------------------- /example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/RunStepReporterTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber; 2 | 3 | import cucumber.api.CucumberOptions; 4 | import cucumber.api.junit.Cucumber; 5 | import org.junit.runner.RunWith; 6 | 7 | @RunWith(Cucumber.class) 8 | @CucumberOptions(plugin = { "pretty", "com.epam.reportportal.cucumber.StepReporter" }, features = "src/test/resources/features/attribute") 9 | public class RunStepReporterTest { 10 | } 11 | -------------------------------------------------------------------------------- /example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/attribute/Stepdefs.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber.attribute; 2 | 3 | import com.epam.reportportal.annotations.attribute.Attribute; 4 | import com.epam.reportportal.annotations.attribute.Attributes; 5 | import com.epam.reportportal.annotations.attribute.MultiKeyAttribute; 6 | import com.epam.reportportal.annotations.attribute.MultiValueAttribute; 7 | import com.epam.reportportal.example.cucumber.Belly; 8 | import cucumber.api.java.en.Given; 9 | import cucumber.api.java.en.Then; 10 | import cucumber.api.java.en.When; 11 | 12 | import static org.junit.Assert.assertTrue; 13 | 14 | public class Stepdefs { 15 | 16 | private Belly belly = new Belly(); 17 | 18 | @Attributes(attributes = { @Attribute(key = "key", value = "value") }) 19 | @Given("^I have (\\d+) cukes in my belly$") 20 | public void I_have_cukes_in_my_belly(int cukes) { 21 | belly.eat(cukes); 22 | } 23 | 24 | @Attributes(attributes = { @Attribute(key = "key1", value = "value1"), 25 | @Attribute(key = "key2", value = "value2") }, multiKeyAttributes = { @MultiKeyAttribute(keys = { "k1", "k2" }, value = "v") }) 26 | @When("^I wait (\\d+) hour$") 27 | public void I_wait(int hours) { 28 | belly.wait(hours); 29 | } 30 | 31 | @Attributes(multiValueAttributes = { @MultiValueAttribute(isNullKey = true, values = { "v1", "v2" }) }) 32 | @Then("^my belly should growl$") 33 | public void my_belly_should_growl() { 34 | assertTrue(belly.growl()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/logging/DataTableTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber.logging; 2 | 3 | import cucumber.api.DataTable; 4 | import cucumber.api.java.en.Given; 5 | import cucumber.api.java.en.Then; 6 | import cucumber.api.java.en.When; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | import static org.junit.Assert.assertEquals; 14 | 15 | /** 16 | * @author Ihar Kahadouski 17 | */ 18 | public class DataTableTest { 19 | private static final Logger LOGGER = LoggerFactory.getLogger(DataTableTest.class); 20 | 21 | private List bag = new ArrayList<>(); 22 | 23 | private int found; 24 | 25 | @Given("^I have the following items in bag$") 26 | public void iHaveTheFollowingItemsInBag(DataTable dataTable) { 27 | bag = dataTable.asList(String.class); 28 | LOGGER.info("I have the following items in bag {}", bag); 29 | } 30 | 31 | @When("^I search for (.*)$") 32 | public void iSearchForGlasses(String item) { 33 | LOGGER.info("I'm searching for {}", item); 34 | found = bag.contains(item) ? 1 : 0; 35 | } 36 | 37 | @Then("^I find (\\d+) items$") 38 | public void iFindItems(int expected) { 39 | LOGGER.info("I found {} items", expected); 40 | assertEquals(expected, found); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/logging/Hooks.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber.logging; 2 | 3 | import cucumber.api.java.After; 4 | import cucumber.api.java.Before; 5 | import cucumber.api.java.en.Given; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import java.util.Arrays; 10 | import java.util.List; 11 | 12 | public class Hooks { 13 | private static final Logger LOGGER = LoggerFactory.getLogger(Hooks.class); 14 | 15 | private List storage; 16 | 17 | @Before 18 | public void beforeScenario() { 19 | LOGGER.info("Inside before"); 20 | LOGGER.info("Initial storage state: {}", storage); 21 | storage = Arrays.asList("one", "two"); 22 | LOGGER.info("Storage is set to {}", storage); 23 | } 24 | 25 | @Given("^I report scenario with hooks$") 26 | public void test() { 27 | LOGGER.info("Storage contains: {}", storage); 28 | } 29 | 30 | @After 31 | public void afterScenario() { 32 | LOGGER.info("Inside after"); 33 | LOGGER.info("Storage state: {}", storage); 34 | storage = null; 35 | LOGGER.info("Final storage state: {}", storage); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/logging/LogLevelTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber.logging; 2 | 3 | import cucumber.api.java.en.Given; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | public class LogLevelTest { 8 | 9 | private static final Logger LOGGER = LoggerFactory.getLogger(LogLevelTest.class); 10 | 11 | @Given("Log level test") 12 | public void logLevelTest() { 13 | LOGGER.info("It is log level test"); 14 | } 15 | 16 | @Given("I emit log on level info") 17 | public void infoLevelTest() { 18 | LOGGER.info("Info level test"); 19 | } 20 | 21 | @Given("I emit log on level error") 22 | public void errorLevelTest() { 23 | LOGGER.error("Error level test"); 24 | } 25 | 26 | @Given("I emit log on level debug") 27 | public void debugLevelTest() { 28 | LOGGER.debug("Debug level test"); 29 | } 30 | 31 | @Given("I emit log on level warn") 32 | public void warnLevelTest() { 33 | LOGGER.warn("Warn level test"); 34 | } 35 | 36 | @Given("I emit log on level trace") 37 | public void traceLevelTest() { 38 | LOGGER.trace("Trace level test"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/logging/ParametersTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber.logging; 2 | 3 | import cucumber.api.java.en.Given; 4 | import cucumber.api.java.en.Then; 5 | import cucumber.api.java.en.When; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import static org.junit.Assert.assertEquals; 10 | 11 | /** 12 | * @author Ihar Kahadouski 13 | */ 14 | public class ParametersTest { 15 | 16 | private static final Logger LOGGER = LoggerFactory.getLogger(ParametersTest.class); 17 | private int itemsCount; 18 | 19 | @Given("^I have (\\d+) (.*) in my pocket$") 20 | public void iHaveNumberItemInMyPocket(int number, String item) { 21 | itemsCount = number; 22 | LOGGER.info("I have {} {} in my pocket", number, item); 23 | 24 | } 25 | 26 | @When("^I eat one$") 27 | public void iEatOne() { 28 | itemsCount -= 1; 29 | LOGGER.info("I eat one"); 30 | } 31 | 32 | @Then("^I have (\\d+) in my pocket$") 33 | public void iHaveResultInMyPocket(int result) { 34 | assertEquals(result, itemsCount); 35 | LOGGER.info("I have {} in my pocket", result); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/logging/ReportsStepWithDefectTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber.logging; 2 | 3 | import cucumber.api.java.en.Given; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import static org.junit.Assert.assertEquals; 8 | 9 | public class ReportsStepWithDefectTest { 10 | 11 | private static final Logger LOGGER = LoggerFactory.getLogger(ReportsStepWithDefectTest.class); 12 | 13 | @Given("Test is skipped") 14 | public void testSkipped() { 15 | LOGGER.info("I must be skipped"); 16 | } 17 | 18 | @Given("^Test is failed$") 19 | public void testFailure() { 20 | assertEquals(2, 1); 21 | } 22 | 23 | @Given("^Test is failed with message$") 24 | public void testFailureWithMessage() { 25 | assertEquals("Failure msg", 2, 1); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/logging/ReportsTestWithParameters.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber.logging; 2 | 3 | import cucumber.api.java.en.Given; 4 | import cucumber.api.java.en.Then; 5 | import cucumber.api.java.en.When; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | public class ReportsTestWithParameters { 10 | 11 | private static final Logger LOGGER = LoggerFactory.getLogger(ReportsTestWithParameters.class); 12 | 13 | @Given("It is test with parameters") 14 | public void infoLevel() { 15 | LOGGER.info("It is test with parameters"); 16 | } 17 | 18 | @When("^I have (.*) parameter$") 19 | public void iHaveStrParameter(String str) { 20 | LOGGER.info("String parameter {}", str); 21 | } 22 | 23 | @Then("^I emit number (\\d+) on level info$") 24 | public void infoLevel(int parameters) { 25 | LOGGER.info("Test with parameters: " + parameters); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/Attachment.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber.util; 2 | 3 | public enum Attachment { 4 | CMD("cmd"), 5 | CSS("css"), 6 | CSV("csv"), 7 | HAR("har"), 8 | HTML("html"), 9 | JPG("jpg"), 10 | JS("js"), 11 | JSON("json"), 12 | PDF("pdf"), 13 | PHP("php"), 14 | PNG("png"), 15 | TAR("tar"), 16 | TAR_GZ("tar.gz"), 17 | TXT("txt"), 18 | XML("xml"), 19 | ZIP("zip"); 20 | 21 | private final String extension; 22 | 23 | public String getExtension() { 24 | return extension; 25 | } 26 | 27 | Attachment(String extension) { 28 | this.extension = extension; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/AttachmentHelper.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber.util; 2 | 3 | import com.epam.reportportal.utils.files.ByteSource; 4 | import com.epam.reportportal.utils.files.Utils; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | 11 | /** 12 | * Utility file to copy / read resource files. 13 | */ 14 | public class AttachmentHelper { 15 | public static final String FILE_NAME = "file"; 16 | 17 | public static File getFileFromResources(String path, String name, String extension) { 18 | File file = null; 19 | try { 20 | file = File.createTempFile("rp-test", "." + extension); 21 | ByteSource source = Utils.getFileAsByteSource(new File(String.format("%s/%s.%s", path, name, extension))); 22 | try (InputStream is = source.openStream()) { 23 | try (OutputStream os = java.nio.file.Files.newOutputStream(file.toPath())) { 24 | Utils.copyStreams(is, os); 25 | } 26 | } 27 | } catch (IOException ignored) { 28 | } 29 | return file; 30 | } 31 | 32 | public static File getFileFromResources(String name, String extension) { 33 | return getFileFromResources("src/test/resources/files", name, extension); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/LoggingUtils.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.File; 7 | import java.util.Base64; 8 | 9 | /** 10 | * Useful utility class for binary data logging (e.g. sending files to ReportPortal). You can disable console output for 11 | * `binary_data_logger` to avoid redundant verbose output. 12 | */ 13 | public class LoggingUtils { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger("binary_data_logger"); 16 | 17 | private LoggingUtils() { 18 | //statics only 19 | } 20 | 21 | public static void log(File file, String message) { 22 | LOGGER.info("RP_MESSAGE#FILE#{}#{}", file.getAbsolutePath(), message); 23 | } 24 | 25 | public static void logBase64(String base64, String message) { 26 | LOGGER.info("RP_MESSAGE#BASE64#{}#{}", base64, message); 27 | } 28 | 29 | public static void log(byte[] bytes, String message) { 30 | logBase64(Base64.getEncoder().encodeToString(bytes), message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/MagicRandomizer.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.util.Random; 7 | 8 | /** 9 | * Just a randomizer 10 | * 11 | * @author Andrei Varabyeu 12 | */ 13 | public class MagicRandomizer { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(MagicRandomizer.class); 16 | 17 | private static final Random RANDOM = new Random(); 18 | private static final int UPPER_LIMIT = 100; 19 | 20 | private MagicRandomizer() { 21 | //statics only 22 | } 23 | 24 | public static int luckyInt(int bound) { 25 | return RANDOM.nextInt(bound); 26 | } 27 | 28 | /** 29 | * Just put probability and check your luckiness 30 | * 31 | * @param probability value [0--100] 32 | * @return TRUE if you are really lucky! 33 | */ 34 | public static boolean checkYourLucky(int probability) { 35 | boolean lucky = luckyInt(UPPER_LIMIT + 1) <= probability; 36 | LOGGER.debug("Generating [TRUE/FALSE] with probability {}%. Result {}", probability, lucky); 37 | return lucky; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/features/attribute/belly.feature: -------------------------------------------------------------------------------- 1 | Feature: Belly 2 | 3 | @ok 4 | Scenario: a few cukes 5 | Given I have 42 cukes in my belly 6 | When I wait 1 hour 7 | Then my belly should growl 8 | -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/features/logging/dataTableTest.feature: -------------------------------------------------------------------------------- 1 | Feature: DataTableTest 2 | 3 | Scenario: Searching for glasses 4 | Given I have the following items in bag 5 | | phone | 6 | | laptop | 7 | When I search for glasses 8 | Then I find 0 items 9 | 10 | Scenario: Searching for phone 11 | Given I have the following items in bag 12 | | phone | 13 | | laptop | 14 | When I search for phone 15 | Then I find 1 items -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/features/logging/hooks.feature: -------------------------------------------------------------------------------- 1 | Feature: Hooks reporting 2 | 3 | Scenario: Hooks 4 | Given I report scenario with hooks -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/features/logging/launchLog.feature: -------------------------------------------------------------------------------- 1 | Feature: Launch logging with attachments 2 | 3 | Scenario: Report launch with logs and attachment 4 | Given I attach files to launch logs -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/features/logging/logLevelTest.feature: -------------------------------------------------------------------------------- 1 | Feature: LogLevelTest 2 | 3 | Background: Common information 4 | Given Log level test 5 | 6 | Scenario: DebugLevelTest 7 | Given I emit log on level debug 8 | 9 | Scenario: InfoLevelTest 10 | Given I emit log on level info 11 | 12 | Scenario: TraceLevelTest 13 | Given I emit log on level trace 14 | 15 | Scenario: WarnLevelTest 16 | Given I emit log on level warn 17 | 18 | Scenario: ErrorLevelTest 19 | Given I emit log on level error 20 | -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/features/logging/reportAttachmentsTest.feature: -------------------------------------------------------------------------------- 1 | Feature: ReportAttachmentsTest 2 | 3 | Background: 4 | 5 | Scenario: ReportAttachmentsTest 6 | Given I attach logCmd 7 | Given I attach logCss 8 | Given I attach logCsv 9 | Given I attach logHar 10 | Given I attach logHtml 11 | Given I attach logImageBase64 12 | Given I attach logJavascript 13 | Given I attach logBase64 14 | Given I attach logJsonFile 15 | Given I attach logPdf 16 | Given I attach logPhp 17 | Given I attach logPlain 18 | Given I attach logXmlBase64 19 | Given I attach logXmlFile 20 | Given I attach logZip 21 | -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/features/logging/reportsTestWithParametrs.feature: -------------------------------------------------------------------------------- 1 | Feature: Test with parameters 2 | 3 | Scenario Outline: Test with different parameters 4 | Given It is test with parameters 5 | When I have parameter 6 | Then I emit number on level info 7 | 8 | Examples: 9 | | str | parameters | 10 | | first | 123 | 11 | | second | 12345 | 12 | | third | 12312345678 | 13 | 14 | Scenario Outline: Test with few parameter in method 15 | Given I have in my pocket 16 | When I eat one 17 | Then I have in my pocket 18 | 19 | Examples: 20 | | number | item | result | 21 | | 100 | apples | 99 | 22 | | 3 | cucumbers | 2 | 23 | | 1 | cake | 0 | 24 | 25 | -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/features/logging/testWithDefects.feature: -------------------------------------------------------------------------------- 1 | Feature: Test with defects 2 | 3 | @ignore 4 | Scenario: Test is skipped 5 | Given Test is skipped 6 | 7 | Scenario: Test is failed 8 | Given Test is failed 9 | 10 | Scenario: Test is failed with custom message 11 | Given Test is failed with message 12 | -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/files/file.cmd: -------------------------------------------------------------------------------- 1 | title Batch File Testing 2 | echo Hello World 3 | echo. 4 | echo Starting Notepad 5 | start notepad 6 | echo. 7 | echo Starting Wordpad 8 | start Wordpad 9 | echo. 10 | pause 11 | exit -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/files/file.css: -------------------------------------------------------------------------------- 1 | p { 2 | font-family: arial, helvetica, sans-serif; 3 | } 4 | 5 | h2 { 6 | font-size: 20pt; 7 | color: red; 8 | background: white; 9 | } 10 | 11 | .note { 12 | color: red; 13 | background-color: yellow; 14 | font-weight: bold; 15 | } 16 | 17 | p#paragraph1 { 18 | padding-left: 10px; 19 | } 20 | 21 | a:hover { 22 | text-decoration: none; 23 | } 24 | 25 | #news p { 26 | color: blue; 27 | } 28 | 29 | [type="button"] { 30 | background-color: green; 31 | } -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/files/file.csv: -------------------------------------------------------------------------------- 1 | 1997,Ford,E350,"ac, abs, moon",3000.00 2 | 1999,Chevy,"Venture ""Extended Edition""","",4900.00 3 | 1996,Jeep,Grand Cherokee,"MUST SELL! air, moon roof, loaded",4799.00 -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/files/file.har: -------------------------------------------------------------------------------- 1 | { 2 | "log": { 3 | "version": "1.2", 4 | "creator": { 5 | "name": "WebInspector", 6 | "version": "537.36" 7 | }, 8 | "pages": [ 9 | { 10 | "startedDateTime": "2017-12-13T11:21:18.288Z", 11 | "id": "page_2", 12 | "title": "http://localhost:8080/", 13 | "pageTimings": { 14 | "onContentLoad": 330.9420000005048, 15 | "onLoad": 464.73599999808357 16 | } 17 | } 18 | ] 19 | } 20 | } -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/files/file.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-cucumber/src/test/resources/files/file.jpg -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/files/file.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-cucumber/src/test/resources/files/file.pdf -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/files/file.php: -------------------------------------------------------------------------------- 1 | a = $a; 11 | $this->b = $b; 12 | } 13 | 14 | public function plus() 15 | { 16 | return $this->a + $this->b; 17 | } 18 | /* ............... */ 19 | } 20 | 21 | $d = new C1(1, 2); 22 | echo $d->plus(); // 3 23 | ?> -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/files/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-cucumber/src/test/resources/files/file.png -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/files/file.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-cucumber/src/test/resources/files/file.tar.gz -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/files/file.txt: -------------------------------------------------------------------------------- 1 | Copyright 2016 EPAM Systems 2 | This file is part of EPAM Report Portal. 3 | https://github.com/reportportal/service-ui 4 | Report Portal is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | Report Portal is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License 13 | along with Report Portal. If not, see . -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/files/file.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Here is some xml content 4 | 5 | -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/files/file.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-cucumber/src/test/resources/files/file.zip -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/pug/lucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-cucumber/src/test/resources/pug/lucky.jpg -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/pug/unlucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-cucumber/src/test/resources/pug/unlucky.jpg -------------------------------------------------------------------------------- /example-cucumber/src/test/resources/reportportal.properties: -------------------------------------------------------------------------------- 1 | rp.endpoint=http://example.com 2 | rp.api.key=api-key 3 | rp.launch=launch-name 4 | rp.project=project-name 5 | rp.attributes=key:value;value 6 | rp.reporting.async=true 7 | -------------------------------------------------------------------------------- /example-cucumber4/src/main/java/com/epam/reportportal/example/cucumber4/Belly.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.cucumber4; 18 | 19 | public class Belly { 20 | 21 | private int satiation = 0; 22 | 23 | public void eat(int cukes) { 24 | satiation += cukes; 25 | } 26 | 27 | public void wait(int hours) { 28 | if ((hours > 0) && (satiation > 0)) { 29 | int utilized = 60 * hours; 30 | if (utilized > satiation) { 31 | utilized = satiation; 32 | } 33 | satiation -= utilized; 34 | } 35 | } 36 | 37 | public boolean growl() { 38 | return satiation <= 0; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/java/com/epam/reportportal/example/cucumber4/RunLoggingTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.cucumber4; 18 | 19 | import io.cucumber.junit.Cucumber; 20 | import io.cucumber.junit.CucumberOptions; 21 | import org.junit.runner.RunWith; 22 | 23 | @RunWith(Cucumber.class) 24 | @CucumberOptions(plugin = { "pretty", 25 | "com.epam.reportportal.cucumber.StepReporter" }, features = "src/test/resources/features/logging", tags = "not @ignore") 26 | public class RunLoggingTest { 27 | } 28 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/java/com/epam/reportportal/example/cucumber4/RunScenarioReporterNoRootStoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.cucumber4; 18 | 19 | import com.epam.reportportal.example.cucumber4.reporter.ScenarioReporterTestCaseId; 20 | import io.cucumber.junit.Cucumber; 21 | import io.cucumber.junit.CucumberOptions; 22 | import org.junit.runner.RunWith; 23 | 24 | /** 25 | * A JUnit runner for Cucumber which is using customized {@link ScenarioReporterTestCaseId} reporter. 26 | */ 27 | @RunWith(Cucumber.class) 28 | @CucumberOptions(plugin = { "pretty", "com.epam.reportportal.example.cucumber4.reporter.ScenarioReporterNoSuite" }, features = { 29 | "src/test/resources/features/attribute" }, glue = { "com.epam.reportportal.example.cucumber4.attribute" }) 30 | public class RunScenarioReporterNoRootStoryTest { 31 | } 32 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/java/com/epam/reportportal/example/cucumber4/RunScenarioReporterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.cucumber4; 18 | 19 | import com.epam.reportportal.example.cucumber4.reporter.ScenarioReporterTestCaseId; 20 | import io.cucumber.junit.Cucumber; 21 | import io.cucumber.junit.CucumberOptions; 22 | import org.junit.runner.RunWith; 23 | 24 | /** 25 | * A JUnit runner for Cucumber which is using customized {@link ScenarioReporterTestCaseId} reporter. 26 | */ 27 | @RunWith(Cucumber.class) 28 | @CucumberOptions(plugin = { "pretty", "com.epam.reportportal.example.cucumber4.reporter.ScenarioReporterTestCaseId" }, features = { 29 | "src/test/resources/features/attribute" }, glue = { "com.epam.reportportal.example.cucumber4.attribute" }) 30 | public class RunScenarioReporterTest { 31 | } 32 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/java/com/epam/reportportal/example/cucumber4/RunStepReporterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.cucumber4; 18 | 19 | import io.cucumber.junit.Cucumber; 20 | import io.cucumber.junit.CucumberOptions; 21 | import org.junit.runner.RunWith; 22 | 23 | @RunWith(Cucumber.class) 24 | @CucumberOptions(plugin = { "pretty", "com.epam.reportportal.cucumber.StepReporter" }, features = { 25 | "src/test/resources/features/attribute" }, glue = { "com.epam.reportportal.example.cucumber4.attribute" }) 26 | public class RunStepReporterTest { 27 | } 28 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/java/com/epam/reportportal/example/cucumber4/logging/ReportsStepWithDefectTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.cucumber4.logging; 18 | 19 | import io.cucumber.java.en.Given; 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | 23 | import static org.junit.Assert.assertEquals; 24 | 25 | public class ReportsStepWithDefectTest { 26 | 27 | private static final Logger LOGGER = LoggerFactory.getLogger(ReportsStepWithDefectTest.class); 28 | 29 | @Given("Test is skipped") 30 | public void testSkipped() { 31 | LOGGER.info("I must be skipped"); 32 | } 33 | 34 | @Given("^Test is failed$") 35 | public void testFailure() { 36 | assertEquals(2, 1); 37 | } 38 | 39 | @Given("^Test is failed with message$") 40 | public void testFailureWithMessage() { 41 | assertEquals("Failure msg", 2, 1); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/java/com/epam/reportportal/example/cucumber4/util/Attachment.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber4.util; 2 | 3 | public enum Attachment { 4 | CMD("cmd"), 5 | CSS("css"), 6 | CSV("csv"), 7 | HAR("har"), 8 | HTML("html"), 9 | JPG("jpg"), 10 | JS("js"), 11 | JSON("json"), 12 | PDF("pdf"), 13 | PHP("php"), 14 | PNG("png"), 15 | TAR("tar"), 16 | TAR_GZ("tar.gz"), 17 | TXT("txt"), 18 | XML("xml"), 19 | ZIP("zip"); 20 | 21 | private final String extension; 22 | 23 | public String getExtension() { 24 | return extension; 25 | } 26 | 27 | Attachment(String extension) { 28 | this.extension = extension; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/java/com/epam/reportportal/example/cucumber4/util/AttachmentHelper.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber4.util; 2 | 3 | import com.epam.reportportal.utils.files.ByteSource; 4 | import com.epam.reportportal.utils.files.Utils; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | 11 | /** 12 | * Utility file to copy / read resource files. 13 | */ 14 | public class AttachmentHelper { 15 | public static final String FILE_NAME = "file"; 16 | 17 | public static File getFileFromResources(String path, String name, String extension) { 18 | File file = null; 19 | try { 20 | file = File.createTempFile("rp-test", "." + extension); 21 | ByteSource source = Utils.getFileAsByteSource(new File(String.format("%s/%s.%s", path, name, extension))); 22 | try (InputStream is = source.openStream()) { 23 | try (OutputStream os = java.nio.file.Files.newOutputStream(file.toPath())) { 24 | Utils.copyStreams(is, os); 25 | } 26 | } 27 | } catch (IOException ignored) { 28 | } 29 | return file; 30 | } 31 | 32 | public static File getFileFromResources(String name, String extension) { 33 | return getFileFromResources("src/test/resources/files", name, extension); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/java/com/epam/reportportal/example/cucumber4/util/LoggingUtils.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber4.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.File; 7 | import java.util.Base64; 8 | 9 | /** 10 | * Useful utility class for binary data logging (e.g. sending files to ReportPortal). You can disable console output for 11 | * `binary_data_logger` to avoid redundant verbose output. 12 | */ 13 | public class LoggingUtils { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger("binary_data_logger"); 16 | 17 | private LoggingUtils() { 18 | //statics only 19 | } 20 | 21 | public static void log(File file, String message) { 22 | LOGGER.info("RP_MESSAGE#FILE#{}#{}", file.getAbsolutePath(), message); 23 | } 24 | 25 | public static void logBase64(String base64, String message) { 26 | LOGGER.info("RP_MESSAGE#BASE64#{}#{}", base64, message); 27 | } 28 | 29 | public static void log(byte[] bytes, String message) { 30 | logBase64(Base64.getEncoder().encodeToString(bytes), message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/java/com/epam/reportportal/example/cucumber4/util/MagicRandomizer.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber4.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.util.Random; 7 | 8 | /** 9 | * Just a randomizer 10 | * 11 | * @author Andrei Varabyeu 12 | */ 13 | public class MagicRandomizer { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(MagicRandomizer.class); 16 | 17 | private static final Random RANDOM = new Random(); 18 | private static final int UPPER_LIMIT = 100; 19 | 20 | private MagicRandomizer() { 21 | //statics only 22 | } 23 | 24 | public static int luckyInt(int bound) { 25 | return RANDOM.nextInt(bound); 26 | } 27 | 28 | /** 29 | * Just put probability and check your luckiness 30 | * 31 | * @param probability value [0--100] 32 | * @return TRUE if you are really lucky! 33 | */ 34 | public static boolean checkYourLucky(int probability) { 35 | boolean lucky = luckyInt(UPPER_LIMIT + 1) <= probability; 36 | LOGGER.debug("Generating [TRUE/FALSE] with probability {}%. Result {}", probability, lucky); 37 | return lucky; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/features/attribute/belly.feature: -------------------------------------------------------------------------------- 1 | @high-severity 2 | Feature: Belly 3 | 4 | @JIRA-1234 5 | @ok 6 | Scenario: a few cukes 7 | Given I have 42 cukes in my belly 8 | When I wait 1 hour 9 | Then my belly should growl 10 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/features/logging/hooks.feature: -------------------------------------------------------------------------------- 1 | Feature: Hooks reporting 2 | 3 | Scenario: Hooks 4 | Given I report scenario with hooks -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/features/logging/launchLog.feature: -------------------------------------------------------------------------------- 1 | Feature: Launch logging with attachments 2 | 3 | Scenario: Report launch with logs and attachment 4 | Given I attach files to launch logs -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/features/logging/logLevelTest.feature: -------------------------------------------------------------------------------- 1 | Feature: LogLevelTest 2 | 3 | Background: Common information 4 | Given Log level test 5 | 6 | Scenario: DebugLevelTest 7 | Given I emit log on level debug 8 | 9 | Scenario: InfoLevelTest 10 | Given I emit log on level info 11 | 12 | Scenario: TraceLevelTest 13 | Given I emit log on level trace 14 | 15 | Scenario: WarnLevelTest 16 | Given I emit log on level warn 17 | 18 | Scenario: ErrorLevelTest 19 | Given I emit log on level error 20 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/features/logging/reportAttachmentsTest.feature: -------------------------------------------------------------------------------- 1 | Feature: ReportAttachmentsTest 2 | 3 | Background: 4 | 5 | Scenario: ReportAttachmentsTest 6 | Given I attach logCmd 7 | Given I attach logCss 8 | Given I attach logCsv 9 | Given I attach logHar 10 | Given I attach logHtml 11 | Given I attach logImageBase64 12 | Given I attach logJavascript 13 | Given I attach logBase64 14 | Given I attach logJsonFile 15 | Given I attach logPdf 16 | Given I attach logPhp 17 | Given I attach logPlain 18 | Given I attach logXmlBase64 19 | Given I attach logXmlFile 20 | Given I attach logZip 21 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/features/logging/reportsTestWithParametrs.feature: -------------------------------------------------------------------------------- 1 | Feature: Test with parameters 2 | 3 | Scenario Outline: Test with different parameters 4 | Given It is test with parameters 5 | When I have parameter 6 | Then I emit number on level info 7 | 8 | Examples: 9 | | str | parameters | 10 | | first | 123 | 11 | | second | 12345 | 12 | | third | 12345678 | 13 | 14 | Scenario Outline: Test with few parameter in method 15 | Given I have in my pocket 16 | When I eat one 17 | Then I have in my pocket 18 | 19 | Examples: 20 | | number | item | result | 21 | | 100 | "apples" | 99 | 22 | | 3 | "cucumbers" | 2 | 23 | | 1 | "cake" | 0 | 24 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/features/logging/testWithDefects.feature: -------------------------------------------------------------------------------- 1 | Feature: Test with defects 2 | 3 | @ignore 4 | Scenario: Test is skipped 5 | Given Test is skipped 6 | 7 | Scenario: Test is failed 8 | Given Test is failed 9 | 10 | Scenario: Test is failed with custom message 11 | Given Test is failed with message 12 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/files/file.cmd: -------------------------------------------------------------------------------- 1 | title Batch File Testing 2 | echo Hello World 3 | echo. 4 | echo Starting Notepad 5 | start notepad 6 | echo. 7 | echo Starting Wordpad 8 | start Wordpad 9 | echo. 10 | pause 11 | exit -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/files/file.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | p { 18 | font-family: arial, helvetica, sans-serif; 19 | } 20 | 21 | h2 { 22 | font-size: 20pt; 23 | color: red; 24 | background: white; 25 | } 26 | 27 | .note { 28 | color: red; 29 | background-color: yellow; 30 | font-weight: bold; 31 | } 32 | 33 | p#paragraph1 { 34 | padding-left: 10px; 35 | } 36 | 37 | a:hover { 38 | text-decoration: none; 39 | } 40 | 41 | #news p { 42 | color: blue; 43 | } 44 | 45 | [type="button"] { 46 | background-color: green; 47 | } -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/files/file.csv: -------------------------------------------------------------------------------- 1 | 1997,Ford,E350,"ac, abs, moon",3000.00 2 | 1999,Chevy,"Venture ""Extended Edition""","",4900.00 3 | 1996,Jeep,Grand Cherokee,"MUST SELL! air, moon roof, loaded",4799.00 -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/files/file.har: -------------------------------------------------------------------------------- 1 | { 2 | "log": { 3 | "version": "1.2", 4 | "creator": { 5 | "name": "WebInspector", 6 | "version": "537.36" 7 | }, 8 | "pages": [ 9 | { 10 | "startedDateTime": "2017-12-13T11:21:18.288Z", 11 | "id": "page_2", 12 | "title": "http://localhost:8080/", 13 | "pageTimings": { 14 | "onContentLoad": 330.9420000005048, 15 | "onLoad": 464.73599999808357 16 | } 17 | } 18 | ] 19 | } 20 | } -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/files/file.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-cucumber4/src/test/resources/files/file.jpg -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/files/file.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-cucumber4/src/test/resources/files/file.pdf -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/files/file.php: -------------------------------------------------------------------------------- 1 | a = $a; 11 | $this->b = $b; 12 | } 13 | 14 | public function plus() 15 | { 16 | return $this->a + $this->b; 17 | } 18 | /* ............... */ 19 | } 20 | 21 | $d = new C1(1, 2); 22 | echo $d->plus(); // 3 23 | ?> -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/files/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-cucumber4/src/test/resources/files/file.png -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/files/file.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-cucumber4/src/test/resources/files/file.tar.gz -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/files/file.txt: -------------------------------------------------------------------------------- 1 | Copyright 2016 EPAM Systems 2 | This file is part of EPAM Report Portal. 3 | https://github.com/reportportal/service-ui 4 | Report Portal is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | Report Portal is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License 13 | along with Report Portal. If not, see . -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/files/file.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | Here is some xml content 20 | 21 | -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/files/file.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-cucumber4/src/test/resources/files/file.zip -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/pug/lucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-cucumber4/src/test/resources/pug/lucky.jpg -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/pug/unlucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-cucumber4/src/test/resources/pug/unlucky.jpg -------------------------------------------------------------------------------- /example-cucumber4/src/test/resources/reportportal.properties: -------------------------------------------------------------------------------- 1 | rp.endpoint=http://example.com 2 | rp.api.key=api-key 3 | rp.launch=launch-name 4 | rp.project=project-name 5 | rp.attributes=key:value;value 6 | rp.reporting.async=true 7 | -------------------------------------------------------------------------------- /example-cucumber6-testng/src/main/java/com/epam/reportportal/example/cucumber6/Belly.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.cucumber6; 18 | 19 | public class Belly { 20 | 21 | private int satiation = 0; 22 | 23 | public void eat(int cukes) { 24 | satiation += cukes; 25 | } 26 | 27 | public void wait(int hours) { 28 | if ((hours > 0) && (satiation > 0)) { 29 | int utilized = 60 * hours; 30 | if (utilized > satiation) { 31 | utilized = satiation; 32 | } 33 | satiation -= utilized; 34 | } 35 | } 36 | 37 | public boolean growl() { 38 | return satiation <= 0; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /example-cucumber6-testng/src/test/java/com/epam/reportportal/example/cucumber6/BasicRunTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.cucumber6; 18 | 19 | import io.cucumber.testng.AbstractTestNGCucumberTests; 20 | import io.cucumber.testng.CucumberOptions; 21 | 22 | @CucumberOptions(plugin = "com.epam.reportportal.cucumber.ScenarioReporter", 23 | features = "src/test/resources/features/attributes", glue = "com.epam.reportportal.example.cucumber6.attributes") 24 | public class BasicRunTest extends AbstractTestNGCucumberTests { 25 | } 26 | -------------------------------------------------------------------------------- /example-cucumber6-testng/src/test/resources/features/attributes/belly.feature: -------------------------------------------------------------------------------- 1 | Feature: Belly 2 | 3 | @JIRA-1234 4 | @ok 5 | Scenario: a few cukes 6 | Given I have 42 cukes in my belly 7 | When I wait 1 hour 8 | Then my belly should growl 9 | -------------------------------------------------------------------------------- /example-cucumber6-testng/src/test/resources/reportportal.properties: -------------------------------------------------------------------------------- 1 | rp.endpoint=http://example.com 2 | rp.api.key=api-key 3 | rp.launch=Cucumber 7 TestNG 4 | rp.project=project-name 5 | rp.attributes=key:value;value 6 | rp.reporting.async=true 7 | -------------------------------------------------------------------------------- /example-cucumber6/src/main/java/com/epam/reportportal/example/cucumber6/Belly.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.cucumber6; 18 | 19 | public class Belly { 20 | 21 | private int satiation = 0; 22 | 23 | public void eat(int cukes) { 24 | satiation += cukes; 25 | } 26 | 27 | public void wait(int hours) { 28 | if ((hours > 0) && (satiation > 0)) { 29 | int utilized = 60 * hours; 30 | if (utilized > satiation) { 31 | utilized = satiation; 32 | } 33 | satiation -= utilized; 34 | } 35 | } 36 | 37 | public boolean growl() { 38 | return satiation <= 0; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /example-cucumber6/src/test/java/com/epam/reportportal/example/cucumber6/BasicReRunTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber6; 2 | 3 | import io.cucumber.junit.Cucumber; 4 | import io.cucumber.junit.CucumberOptions; 5 | import org.junit.runner.RunWith; 6 | 7 | @RunWith(Cucumber.class) 8 | @CucumberOptions( 9 | plugin = { "pretty", "html:report.html", "com.epam.reportportal.example.cucumber6.attributes.AttributeReporter" }, 10 | features = "@rerun.txt", 11 | glue = "com.epam.reportportal.example.cucumber6.glue") 12 | public class BasicReRunTest { 13 | } 14 | -------------------------------------------------------------------------------- /example-cucumber6/src/test/java/com/epam/reportportal/example/cucumber6/BasicRunTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.cucumber6; 2 | 3 | import io.cucumber.junit.Cucumber; 4 | import io.cucumber.junit.CucumberOptions; 5 | import org.junit.runner.RunWith; 6 | 7 | @RunWith(Cucumber.class) 8 | @CucumberOptions( 9 | plugin = { "pretty", "html:report.html", "com.epam.reportportal.example.cucumber6.attributes.AttributeReporter", 10 | "rerun:rerun.txt" }, 11 | features = "src/test/resources/features", 12 | tags = "not @ignore", 13 | glue = "com.epam.reportportal.example.cucumber6.glue") 14 | public class BasicRunTest { 15 | } 16 | -------------------------------------------------------------------------------- /example-cucumber6/src/test/resources/features/attributes/belly.feature: -------------------------------------------------------------------------------- 1 | Feature: Belly 2 | 3 | @JIRA-1234 4 | @ok 5 | Scenario: a few cukes 6 | Given I have 42 cukes in my belly 7 | When I wait 1 hour 8 | Then my belly should growl 9 | -------------------------------------------------------------------------------- /example-cucumber6/src/test/resources/features/attributes/key-value.feature: -------------------------------------------------------------------------------- 1 | Feature: Belly with key-value attributes 2 | 3 | @MyAttribute:MyValue 4 | Scenario: a few cukes 5 | Given I have 42 cukes in my belly 6 | When I wait 1 hour 7 | Then my belly should growl 8 | -------------------------------------------------------------------------------- /example-cucumber6/src/test/resources/features/logging/launchIdLogging.feature: -------------------------------------------------------------------------------- 1 | Feature: Logging the Launch ID 2 | 3 | Scenario: Launch ID log 4 | Given I log the Launch ID 5 | -------------------------------------------------------------------------------- /example-cucumber6/src/test/resources/features/logging/launchUrlLogging.feature: -------------------------------------------------------------------------------- 1 | Feature: Logging the Launch link 2 | 3 | Scenario: Launch link log 4 | Given I log the Launch link 5 | -------------------------------------------------------------------------------- /example-cucumber6/src/test/resources/features/selenium/screenshot.feature: -------------------------------------------------------------------------------- 1 | Feature: Screenshot reporting 2 | 3 | @selenium 4 | Scenario: Screenshot 5 | Given I report scenario with screenshot 6 | -------------------------------------------------------------------------------- /example-cucumber6/src/test/resources/reportportal.properties: -------------------------------------------------------------------------------- 1 | rp.endpoint=http://example.com 2 | rp.api.key=api-key 3 | rp.launch=launch-name 4 | rp.project=project-name 5 | rp.attributes=key:value;value 6 | rp.reporting.async=true 7 | -------------------------------------------------------------------------------- /example-jbehave/src/main/java/com/epam/reportportal/example/jbehave/steps/ReportsStepWithDefectTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.jbehave.steps; 2 | 3 | import org.jbehave.core.annotations.Given; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import static org.junit.jupiter.api.Assertions.assertEquals; 8 | 9 | public class ReportsStepWithDefectTest { 10 | 11 | private static final Logger LOGGER = LoggerFactory.getLogger(ReportsStepWithDefectTest.class); 12 | 13 | @Given("Test is skipped") 14 | public void testSkipped() { 15 | LOGGER.info("I must be skipped"); 16 | } 17 | 18 | @Given("Test is failed") 19 | public void testFailure() { 20 | assertEquals(2, 1); 21 | } 22 | 23 | @Given("Test is failed with message") 24 | public void testFailureWithMessage() { 25 | assertEquals(2, 1, "Failure msg"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /example-jbehave/src/main/java/com/epam/reportportal/example/jbehave/steps/ReportsTestWithParameters.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.jbehave.steps; 2 | 3 | import org.jbehave.core.annotations.Given; 4 | import org.jbehave.core.annotations.Named; 5 | import org.jbehave.core.annotations.Then; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | public class ReportsTestWithParameters { 10 | 11 | private static final Logger LOGGER = LoggerFactory.getLogger(ReportsTestWithParameters.class); 12 | 13 | @Given("It is test with parameters") 14 | public void infoLevel() { 15 | LOGGER.info("It is test with parameters"); 16 | } 17 | 18 | @Then("I emit number on level info") 19 | public void infoLevel(@Named("number") int parameters) { 20 | LOGGER.info("Test with parameters: " + parameters); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /example-jbehave/src/main/java/com/epam/reportportal/example/jbehave/util/AttachmentHelper.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.jbehave.util; 2 | 3 | import com.epam.reportportal.utils.files.ByteSource; 4 | import com.epam.reportportal.utils.files.Utils; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | 11 | /** 12 | * Utility file to copy / read resource files. 13 | */ 14 | public class AttachmentHelper { 15 | public static File getFileFromResources(String path, String name, String extension) { 16 | File file = null; 17 | try { 18 | file = File.createTempFile("rp-test", "." + extension); 19 | ByteSource source = Utils.getFileAsByteSource(new File(String.format("%s/%s.%s", path, name, extension))); 20 | try (InputStream is = source.openStream()) { 21 | try (OutputStream os = java.nio.file.Files.newOutputStream(file.toPath())) { 22 | Utils.copyStreams(is, os); 23 | } 24 | } 25 | } catch (IOException ignored) { 26 | } 27 | return file; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /example-jbehave/src/main/java/com/epam/reportportal/example/jbehave/util/LoggingUtils.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.jbehave.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.File; 7 | import java.util.Base64; 8 | 9 | /** 10 | * Useful utility class for binary data logging (e.g. sending files to ReportPortal). You can disable console output for 11 | * `binary_data_logger` to avoid redundant verbose output. 12 | */ 13 | public class LoggingUtils { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger("binary_data_logger"); 16 | 17 | private LoggingUtils() { 18 | //statics only 19 | } 20 | 21 | public static void log(File file, String message) { 22 | LOGGER.info("RP_MESSAGE#FILE#{}#{}", file.getAbsolutePath(), message); 23 | } 24 | 25 | public static void logBase64(String base64, String message) { 26 | LOGGER.info("RP_MESSAGE#BASE64#{}#{}", base64, message); 27 | } 28 | 29 | public static void log(byte[] bytes, String message) { 30 | logBase64(Base64.getEncoder().encodeToString(bytes), message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-jbehave/src/main/java/com/epam/reportportal/example/jbehave/util/MagicRandomizer.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.jbehave.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.util.Random; 7 | 8 | /** 9 | * Just a randomizer 10 | * 11 | * @author Andrei Varabyeu 12 | */ 13 | public class MagicRandomizer { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(MagicRandomizer.class); 16 | 17 | private static final Random RANDOM = new Random(); 18 | private static final int UPPER_LIMIT = 100; 19 | 20 | private MagicRandomizer() { 21 | //statics only 22 | } 23 | 24 | public static int luckyInt(int bound) { 25 | return RANDOM.nextInt(bound); 26 | } 27 | 28 | /** 29 | * Just put probability and check your luckiness 30 | * 31 | * @param probability value [0--100] 32 | * @return TRUE if you are really lucky! 33 | */ 34 | public static boolean checkYourLucky(int probability) { 35 | boolean lucky = luckyInt(UPPER_LIMIT + 1) <= probability; 36 | LOGGER.debug("Generating [TRUE/FALSE] with probability {}%. Result {}", probability, lucky); 37 | return lucky; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/files/Test.cmd: -------------------------------------------------------------------------------- 1 | title Batch File Testing 2 | echo Hello World 3 | echo. 4 | echo Starting Notepad 5 | start notepad 6 | echo. 7 | echo Starting Wordpad 8 | start Wordpad 9 | echo. 10 | pause 11 | exit -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/files/Test.csv: -------------------------------------------------------------------------------- 1 | 1997,Ford,E350,"ac, abs, moon",3000.00 2 | 1999,Chevy,"Venture ""Extended Edition""","",4900.00 3 | 1996,Jeep,Grand Cherokee,"MUST SELL! air, moon roof, loaded",4799.00 -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/files/css.css: -------------------------------------------------------------------------------- 1 | p { 2 | font-family: arial, helvetica, sans-serif; 3 | } 4 | 5 | h2 { 6 | font-size: 20pt; 7 | color: red; 8 | background: white; 9 | } 10 | 11 | .note { 12 | color: red; 13 | background-color: yellow; 14 | font-weight: bold; 15 | } 16 | 17 | p#paragraph1 { 18 | padding-left: 10px; 19 | } 20 | 21 | a:hover { 22 | text-decoration: none; 23 | } 24 | 25 | #news p { 26 | color: blue; 27 | } 28 | 29 | [type="button"] { 30 | background-color: green; 31 | } -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/files/demo.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-jbehave/src/main/resources/files/demo.zip -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/files/file.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | p { 18 | font-family: arial, helvetica, sans-serif; 19 | } 20 | 21 | h2 { 22 | font-size: 20pt; 23 | color: red; 24 | background: white; 25 | } 26 | 27 | .note { 28 | color: red; 29 | background-color: yellow; 30 | font-weight: bold; 31 | } 32 | 33 | p#paragraph1 { 34 | padding-left: 10px; 35 | } 36 | 37 | a:hover { 38 | text-decoration: none; 39 | } 40 | 41 | #news p { 42 | color: blue; 43 | } 44 | 45 | [type="button"] { 46 | background-color: green; 47 | } -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/files/file.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | Here is some xml content 20 | 21 | -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/files/har.har: -------------------------------------------------------------------------------- 1 | { 2 | "log": { 3 | "version": "1.2", 4 | "creator": { 5 | "name": "WebInspector", 6 | "version": "537.36" 7 | }, 8 | "pages": [ 9 | { 10 | "startedDateTime": "2017-12-13T11:21:18.288Z", 11 | "id": "page_2", 12 | "title": "http://localhost:8080/", 13 | "pageTimings": { 14 | "onContentLoad": 330.9420000005048, 15 | "onLoad": 464.73599999808357 16 | } 17 | } 18 | ] 19 | } 20 | } -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/files/php.php: -------------------------------------------------------------------------------- 1 | a = $a; 11 | $this->b = $b; 12 | } 13 | 14 | public function plus() 15 | { 16 | return $this->a + $this->b; 17 | } 18 | /* ............... */ 19 | } 20 | 21 | $d = new C1(1, 2); 22 | echo $d->plus(); // 3 23 | ?> -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/files/plain.txt: -------------------------------------------------------------------------------- 1 | Copyright 2016 EPAM Systems 2 | This file is part of EPAM Report Portal. 3 | https://github.com/reportportal/service-ui 4 | Report Portal is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | Report Portal is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License 13 | along with Report Portal. If not, see . -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/files/test.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-jbehave/src/main/resources/files/test.pdf -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/pug/lucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-jbehave/src/main/resources/pug/lucky.jpg -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/pug/unlucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-jbehave/src/main/resources/pug/unlucky.jpg -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/reportportal.properties: -------------------------------------------------------------------------------- 1 | rp.endpoint=http://example.com 2 | rp.api.key=api-key 3 | rp.launch=launch-name 4 | rp.project=project-name 5 | rp.attributes=key:value;value 6 | rp.reporting.async=true 7 | -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/story/logLevelTest.story: -------------------------------------------------------------------------------- 1 | Scenario: DebugLevelTest 2 | Given I emit log on level debug 3 | 4 | Scenario: InfoLevelTest 5 | Given I emit log on level info 6 | 7 | Scenario: TraceLevelTest 8 | Given I emit log on level trace 9 | 10 | Scenario: WarnLevelTest 11 | Given I emit log on level warn 12 | 13 | Scenario: ErrorLevelTest 14 | Given I emit log on level error 15 | -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/story/precondition.story: -------------------------------------------------------------------------------- 1 | Verify API calls related to Precondition functionality 2 | 3 | Meta: 4 | @author Ostapenko Ievgen 5 | @precondition 6 | Narrative: 7 | 8 | In order to show the advance Precondition functionality 9 | As a user 10 | I want to perform CRUD operations 11 | 12 | Scenario: Precondition 13 | Given Precondition 14 | -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/story/reportAttachmentsTest.story: -------------------------------------------------------------------------------- 1 | Meta: 2 | Description for story 3 | Scenario: ReportAttachmentsTest 4 | Meta: 5 | Description for scenario 6 | Given I attach logCmd 7 | Given I attach logCss 8 | Given I attach logCsv 9 | Given I attach logHar 10 | Given I attach logHtml 11 | Given I attach logImageBase64 12 | Given I attach logJavascript 13 | Given I attach logBase64 14 | Given I attach logJsonFile 15 | Given I attach logPdf 16 | Given I attach logPhp 17 | Given I attach logPlain 18 | Given I attach logXmlBase64 19 | Given I attach logXmlFile 20 | Given I attach logZip 21 | -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/story/reportsTestWithParametrs.story: -------------------------------------------------------------------------------- 1 | Scenario: Test with different parameters 2 | Given It is test with parameters 3 | Then I emit number on level info 4 | Examples: 5 | | number | 6 | | 123 | 7 | | 12345 | 8 | | 12312345678 | 9 | -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/story/testWithDefects.story: -------------------------------------------------------------------------------- 1 | Scenario: Test is skipped 2 | Meta: 3 | @skip 4 | @ignored true 5 | Given Test is skipped 6 | 7 | Scenario: Test is failed 8 | Given Test is failed 9 | 10 | Scenario: Test is failed with custom message 11 | Given Test is failed with message 12 | -------------------------------------------------------------------------------- /example-jbehave/src/main/resources/xml/file.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Here is some xml content 4 | 5 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/ExpectToFail.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class ExpectToFail { 7 | 8 | @Test 9 | public void testFailure() { 10 | Assert.assertEquals(2, 1); 11 | } 12 | 13 | @Test 14 | public void testFailureWithCustomMessage() { 15 | Assert.assertEquals("Failure msg", 2, 1); 16 | } 17 | 18 | @Test(expected = AssertionError.class) 19 | public void expectedFailureAbsent() { 20 | Assert.assertEquals(1, 1); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/FailedTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Ignore; 5 | import org.junit.Test; 6 | import org.junit.runner.JUnitCore; 7 | import org.junit.runner.Result; 8 | 9 | public class FailedTest { 10 | 11 | @Test(expected = AssertionError.class) 12 | public void expectedFailureThrown() { 13 | Assert.assertEquals(2, 1); 14 | } 15 | 16 | @Test 17 | @Ignore 18 | public void testIgnore() { 19 | Assert.assertEquals(1, 1); 20 | } 21 | 22 | @Test 23 | public void expectToFail() { 24 | JUnitCore core = new JUnitCore(); 25 | Result result = core.run(ExpectToFail.class); 26 | Assert.assertEquals(3, result.getFailureCount()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/LoggingSuite.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit; 2 | 3 | import com.epam.reportportal.example.junit.logging.*; 4 | import org.junit.runner.RunWith; 5 | import org.junit.runners.Suite; 6 | 7 | @RunWith(Suite.class) 8 | @Suite.SuiteClasses({ JsonLoggingTest.class, LoggingTest.class, LuckyPugTest.class, XmlLoggingTest.class }) 9 | public class LoggingSuite { 10 | } 11 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/annotated/TestCaseIdTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit.annotated; 2 | 3 | import com.epam.reportportal.annotations.TestCaseId; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | 7 | public class TestCaseIdTest { 8 | 9 | @TestCaseId("JU4.1.0") 10 | @Test 11 | public void simpleTest() { 12 | Assert.assertEquals(1, 1); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/attribute/ItemAttributeTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit.attribute; 2 | 3 | import com.epam.reportportal.annotations.attribute.Attribute; 4 | import com.epam.reportportal.annotations.attribute.Attributes; 5 | import com.epam.reportportal.annotations.attribute.MultiKeyAttribute; 6 | import com.epam.reportportal.annotations.attribute.MultiValueAttribute; 7 | import org.junit.Assert; 8 | import org.junit.Test; 9 | 10 | /** 11 | * @author Ivan Budayeu 12 | */ 13 | public class ItemAttributeTest { 14 | 15 | @Test 16 | @Attributes(attributes = { @Attribute(key = "key", value = "value") }) 17 | public void first() { 18 | Assert.assertEquals(1, 1); 19 | } 20 | 21 | @Test 22 | @Attributes(attributes = { @Attribute(key = "key1", value = "value1"), 23 | @Attribute(key = "key2", value = "value2") }, multiKeyAttributes = { @MultiKeyAttribute(keys = { "k1", "k2" }, value = "v") }) 24 | public void second() { 25 | Assert.assertEquals(1, 1); 26 | } 27 | 28 | @Test 29 | @Attributes(multiValueAttributes = { @MultiValueAttribute(isNullKey = true, values = { "v1", "v2" }) }) 30 | public void third() { 31 | Assert.assertEquals(1, 1); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/extension/JUnitRetryImpl.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit.extension; 2 | 3 | import com.nordstrom.automation.junit.JUnitRetryAnalyzer; 4 | import org.junit.runners.model.FrameworkMethod; 5 | 6 | public class JUnitRetryImpl implements JUnitRetryAnalyzer { 7 | 8 | @Override 9 | public boolean retry(FrameworkMethod method, Throwable thrown) { 10 | return true; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/extension/RetryTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit.extension; 2 | 3 | import com.nordstrom.automation.junit.JUnitConfig.JUnitSettings; 4 | import org.junit.AfterClass; 5 | import org.junit.Assert; 6 | import org.junit.BeforeClass; 7 | import org.junit.Test; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import java.util.concurrent.atomic.AtomicInteger; 12 | 13 | public class RetryTest { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(RetryTest.class); 16 | 17 | private static final int RETRY_NUMBER = 2; 18 | private static final AtomicInteger COUNTER = new AtomicInteger(0); 19 | 20 | @BeforeClass 21 | public static void beforeClass() { 22 | System.setProperty(JUnitSettings.MAX_RETRY.key(), "3"); 23 | } 24 | 25 | @AfterClass 26 | public static void afterClass() { 27 | System.clearProperty(JUnitSettings.MAX_RETRY.key()); 28 | } 29 | 30 | @Test 31 | public void failOne() { 32 | String errorMsg = "Ooops"; 33 | if (RETRY_NUMBER > COUNTER.incrementAndGet()) { 34 | for (int i = 0; i < 10; i++) { 35 | LOGGER.error(errorMsg); 36 | } 37 | Assert.fail(errorMsg); 38 | } 39 | LOGGER.info("Test passed!"); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/logging/AfterAndBeforeMethodTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit.logging; 2 | 3 | import com.epam.reportportal.example.junit.util.AttachmentHelper; 4 | import com.epam.reportportal.example.junit.util.LoggingUtils; 5 | import org.junit.*; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import java.io.File; 10 | 11 | import static org.junit.Assert.assertTrue; 12 | 13 | public class AfterAndBeforeMethodTest { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(AfterAndBeforeMethodTest.class); 16 | 17 | @BeforeClass 18 | public static void beforeClass() { 19 | LOGGER.info("Inside AfterAndBeforeMethodTest beforeClass "); 20 | } 21 | 22 | @Before 23 | public void before() { 24 | LOGGER.info("Inside AfterAndBeforeMethodTest beforeEach "); 25 | } 26 | 27 | @Test 28 | public void test1() { 29 | LOGGER.info("Inside AfterAndBeforeMethodTest test "); 30 | // Report launch log 31 | File file = AttachmentHelper.getFileFromResources("src/test/resources", "logback", "xml"); 32 | int n = 5; 33 | while (n-- > 0) { 34 | LoggingUtils.log(file, "LAUNCH LOG MESSAGE WITH ATTACHMENT"); 35 | } 36 | 37 | assertTrue(true); 38 | } 39 | 40 | @AfterClass 41 | public static void afterClass() { 42 | LOGGER.info("Inside AfterAndBeforeMethodTest afterClass"); 43 | } 44 | 45 | @After 46 | public void after() { 47 | LOGGER.info("Inside AfterAndBeforeMethodTest after"); 48 | } 49 | } -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/logging/LuckyPugTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit.logging; 2 | 3 | import com.epam.reportportal.example.junit.util.LoggingUtils; 4 | import com.epam.reportportal.example.junit.util.MagicRandomizer; 5 | import com.epam.reportportal.utils.files.Utils; 6 | import org.junit.Test; 7 | 8 | import java.io.File; 9 | import java.io.IOException; 10 | 11 | /** 12 | * Logs image 13 | * 14 | * @author Andrei Varabyeu 15 | */ 16 | public class LuckyPugTest { 17 | @Test 18 | public void logImageBase64() throws IOException { 19 | 20 | /* Generate 10 logs with pugs. Pug may be lucky or unlucky based on randomizer */ 21 | for (int i = 0; i < 20; i++) { 22 | /* 50 percents. So we should have approximately same count of lucky and unlucky pugs */ 23 | boolean happy = MagicRandomizer.checkYourLucky(30); 24 | String image = getImageResource(happy); 25 | LoggingUtils.log(Utils.getFileAsByteSource(new File(image)).read(), "Pug is " + (happy ? "HAPPY" : "NOT HAPPY")); 26 | } 27 | } 28 | 29 | private String getImageResource(boolean lucky) { 30 | return "src/test/resources/pug/" + (lucky ? "lucky.jpg" : "unlucky.jpg"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/logging/XmlLoggingTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit.logging; 2 | 3 | import com.epam.reportportal.example.junit.util.AttachmentHelper; 4 | import com.epam.reportportal.example.junit.util.LoggingUtils; 5 | import com.epam.reportportal.utils.files.Utils; 6 | import org.junit.Test; 7 | 8 | import java.io.File; 9 | import java.io.IOException; 10 | 11 | /** 12 | * JUST an example of file logging 13 | * 14 | * @author Andrei Varabyeu 15 | */ 16 | public class XmlLoggingTest { 17 | public static final String XML_FILE_FOLDER_PATH = "src/test/resources/xml"; 18 | public static final String XML_FILE_PATH = XML_FILE_FOLDER_PATH + "/file.xml"; 19 | 20 | @Test 21 | public void logXmlBase64() throws IOException { 22 | /* here we are logging some binary data as BASE64 string */ 23 | LoggingUtils.log(Utils.getFileAsByteSource(new File(XML_FILE_PATH)).read(), "I'm logging content via BASE64"); 24 | } 25 | 26 | @Test 27 | public void logXmlFile() { 28 | /* here we are logging some binary data as file (useful for selenium) */ 29 | File file = AttachmentHelper.getFileFromResources(XML_FILE_FOLDER_PATH, "file", "xml"); 30 | LoggingUtils.log(file, "I'm logging content via BASE64"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/suites/SuiteOfSuiteTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit.suites; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | import org.junit.runners.Suite.SuiteClasses; 6 | 7 | @RunWith(Suite.class) 8 | @SuiteClasses({ SuiteTest.class }) 9 | public class SuiteOfSuiteTest { 10 | 11 | static { 12 | System.out.println(" SuiteOfSuiteTest"); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/suites/SuiteTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit.suites; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | import org.junit.runners.Suite.SuiteClasses; 6 | 7 | @RunWith(Suite.class) 8 | @SuiteClasses({ com.epam.reportportal.example.junit.DummyTest.class }) 9 | public class SuiteTest { 10 | 11 | static { 12 | System.out.println(" SuiteTest"); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/util/Attachment.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit.util; 2 | 3 | public enum Attachment { 4 | CMD("cmd"), 5 | CSS("css"), 6 | CSV("csv"), 7 | HAR("har"), 8 | HTML("html"), 9 | JPG("jpg"), 10 | JS("js"), 11 | JSON("json"), 12 | PDF("pdf"), 13 | PHP("php"), 14 | PNG("png"), 15 | TAR("tar"), 16 | TAR_GZ("tar.gz"), 17 | TXT("txt"), 18 | XML("xml"), 19 | ZIP("zip"); 20 | 21 | private final String extension; 22 | 23 | public String getExtension() { 24 | return extension; 25 | } 26 | 27 | Attachment(String extension) { 28 | this.extension = extension; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/util/AttachmentHelper.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit.util; 2 | 3 | import com.epam.reportportal.utils.files.ByteSource; 4 | import com.epam.reportportal.utils.files.Utils; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | 11 | /** 12 | * Utility file to copy / read resource files. 13 | */ 14 | public class AttachmentHelper { 15 | public static final String FILE_NAME = "file"; 16 | 17 | public static File getFileFromResources(String path, String name, String extension) { 18 | File file = null; 19 | try { 20 | file = File.createTempFile("rp-test", "." + extension); 21 | ByteSource source = Utils.getFileAsByteSource(new File(String.format("%s/%s.%s", path, name, extension))); 22 | try (InputStream is = source.openStream()) { 23 | try (OutputStream os = java.nio.file.Files.newOutputStream(file.toPath())) { 24 | Utils.copyStreams(is, os); 25 | } 26 | } 27 | } catch (IOException ignored) { 28 | } 29 | return file; 30 | } 31 | 32 | public static File getFileFromResources(String name, String extension) { 33 | return getFileFromResources("src/test/resources/files", name, extension); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/util/LoggingUtils.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.File; 7 | import java.util.Base64; 8 | 9 | /** 10 | * Useful utility class for binary data logging (e.g. sending files to ReportPortal). You can disable console output for 11 | * `binary_data_logger` to avoid redundant verbose output. 12 | */ 13 | public class LoggingUtils { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger("binary_data_logger"); 16 | 17 | private LoggingUtils() { 18 | //statics only 19 | } 20 | 21 | public static void log(File file, String message) { 22 | LOGGER.info("RP_MESSAGE#FILE#{}#{}", file.getAbsolutePath(), message); 23 | } 24 | 25 | public static void logBase64(String base64, String message) { 26 | LOGGER.info("RP_MESSAGE#BASE64#{}#{}", base64, message); 27 | } 28 | 29 | public static void log(byte[] bytes, String message) { 30 | logBase64(Base64.getEncoder().encodeToString(bytes), message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-junit/src/test/java/com/epam/reportportal/example/junit/util/MagicRandomizer.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.util.Random; 7 | 8 | /** 9 | * Just a randomizer 10 | * 11 | * @author Andrei Varabyeu 12 | */ 13 | public class MagicRandomizer { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(MagicRandomizer.class); 16 | 17 | private static final Random RANDOM = new Random(); 18 | private static final int UPPER_LIMIT = 100; 19 | 20 | private MagicRandomizer() { 21 | //statics only 22 | } 23 | 24 | public static int luckyInt(int bound) { 25 | return RANDOM.nextInt(bound); 26 | } 27 | 28 | /** 29 | * Just put probability and check your luckiness 30 | * 31 | * @param probability value [0--100] 32 | * @return TRUE if you are really lucky! 33 | */ 34 | public static boolean checkYourLucky(int probability) { 35 | boolean lucky = luckyInt(UPPER_LIMIT + 1) <= probability; 36 | LOGGER.debug("Generating [TRUE/FALSE] with probability {}%. Result {}", probability, lucky); 37 | return lucky; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example-junit/src/test/resources/META-INF/aop-ajc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example-junit/src/test/resources/META-INF/services/com.nordstrom.automation.junit.JUnitRetryAnalyzer: -------------------------------------------------------------------------------- 1 | com.epam.reportportal.example.junit.extension.JUnitRetryImpl 2 | -------------------------------------------------------------------------------- /example-junit/src/test/resources/META-INF/services/com.nordstrom.automation.junit.JUnitWatcher: -------------------------------------------------------------------------------- 1 | com.epam.reportportal.junit.ReportPortalListener 2 | -------------------------------------------------------------------------------- /example-junit/src/test/resources/files/file.cmd: -------------------------------------------------------------------------------- 1 | title Batch File Testing 2 | echo Hello World 3 | echo. 4 | echo Starting Notepad 5 | start notepad 6 | echo. 7 | echo Starting Wordpad 8 | start Wordpad 9 | echo. 10 | pause 11 | exit -------------------------------------------------------------------------------- /example-junit/src/test/resources/files/file.css: -------------------------------------------------------------------------------- 1 | p { 2 | font-family: arial, helvetica, sans-serif; 3 | } 4 | 5 | h2 { 6 | font-size: 20pt; 7 | color: red; 8 | background: white; 9 | } 10 | 11 | .note { 12 | color: red; 13 | background-color: yellow; 14 | font-weight: bold; 15 | } 16 | 17 | p#paragraph1 { 18 | padding-left: 10px; 19 | } 20 | 21 | a:hover { 22 | text-decoration: none; 23 | } 24 | 25 | #news p { 26 | color: blue; 27 | } 28 | 29 | [type="button"] { 30 | background-color: green; 31 | } -------------------------------------------------------------------------------- /example-junit/src/test/resources/files/file.csv: -------------------------------------------------------------------------------- 1 | 1997,Ford,E350,"ac, abs, moon",3000.00 2 | 1999,Chevy,"Venture ""Extended Edition""","",4900.00 3 | 1996,Jeep,Grand Cherokee,"MUST SELL! air, moon roof, loaded",4799.00 -------------------------------------------------------------------------------- /example-junit/src/test/resources/files/file.har: -------------------------------------------------------------------------------- 1 | { 2 | "log": { 3 | "version": "1.2", 4 | "creator": { 5 | "name": "WebInspector", 6 | "version": "537.36" 7 | }, 8 | "pages": [ 9 | { 10 | "startedDateTime": "2017-12-13T11:21:18.288Z", 11 | "id": "page_2", 12 | "title": "http://localhost:8080/", 13 | "pageTimings": { 14 | "onContentLoad": 330.9420000005048, 15 | "onLoad": 464.73599999808357 16 | } 17 | } 18 | ] 19 | } 20 | } -------------------------------------------------------------------------------- /example-junit/src/test/resources/files/file.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-junit/src/test/resources/files/file.jpg -------------------------------------------------------------------------------- /example-junit/src/test/resources/files/file.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-junit/src/test/resources/files/file.pdf -------------------------------------------------------------------------------- /example-junit/src/test/resources/files/file.php: -------------------------------------------------------------------------------- 1 | a = $a; 11 | $this->b = $b; 12 | } 13 | 14 | public function plus() 15 | { 16 | return $this->a + $this->b; 17 | } 18 | /* ............... */ 19 | } 20 | 21 | $d = new C1(1, 2); 22 | echo $d->plus(); // 3 23 | ?> -------------------------------------------------------------------------------- /example-junit/src/test/resources/files/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-junit/src/test/resources/files/file.png -------------------------------------------------------------------------------- /example-junit/src/test/resources/files/file.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-junit/src/test/resources/files/file.tar.gz -------------------------------------------------------------------------------- /example-junit/src/test/resources/files/file.txt: -------------------------------------------------------------------------------- 1 | Copyright 2019 EPAM Systems 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /example-junit/src/test/resources/files/file.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Here is some xml content 4 | 5 | -------------------------------------------------------------------------------- /example-junit/src/test/resources/files/file.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-junit/src/test/resources/files/file.zip -------------------------------------------------------------------------------- /example-junit/src/test/resources/pug/lucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-junit/src/test/resources/pug/lucky.jpg -------------------------------------------------------------------------------- /example-junit/src/test/resources/pug/unlucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-junit/src/test/resources/pug/unlucky.jpg -------------------------------------------------------------------------------- /example-junit/src/test/resources/reportportal.properties: -------------------------------------------------------------------------------- 1 | rp.endpoint=http://example.com 2 | rp.api.key=api-key 3 | rp.launch=launch-name 4 | rp.project=project-name 5 | rp.attributes=one;two; 6 | rp.reporting.async=true 7 | rp.reporting.callback=true 8 | -------------------------------------------------------------------------------- /example-junit/src/test/resources/xml/file.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Here is some xml content 4 | 5 | -------------------------------------------------------------------------------- /example-junit5/src/main/java/com/epam/reportportal/example/junit5/util/Attachment.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit5.util; 2 | 3 | public enum Attachment { 4 | CMD("cmd"), 5 | CSS("css"), 6 | CSV("csv"), 7 | HAR("har"), 8 | HTML("html"), 9 | JPG("jpg"), 10 | JS("js"), 11 | JSON("json"), 12 | PDF("pdf"), 13 | PHP("php"), 14 | PNG("png"), 15 | TAR("tar"), 16 | TAR_GZ("tar.gz"), 17 | TXT("txt"), 18 | XML("xml"), 19 | ZIP("zip"); 20 | 21 | private final String extension; 22 | 23 | public String getExtension() { 24 | return extension; 25 | } 26 | 27 | Attachment(String extension) { 28 | this.extension = extension; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /example-junit5/src/main/java/com/epam/reportportal/example/junit5/util/AttachmentHelper.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit5.util; 2 | 3 | import com.epam.reportportal.utils.files.ByteSource; 4 | import com.epam.reportportal.utils.files.Utils; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | 11 | /** 12 | * Utility file to copy / read resource files. 13 | */ 14 | public class AttachmentHelper { 15 | public static final String FILE_NAME = "file"; 16 | 17 | public static File getFileFromResources(String path, String name, String extension) { 18 | File file = null; 19 | try { 20 | file = File.createTempFile("rp-test", "." + extension); 21 | ByteSource source = Utils.getFileAsByteSource(new File(String.format("%s/%s.%s", path, name, extension))); 22 | try (InputStream is = source.openStream()) { 23 | try (OutputStream os = java.nio.file.Files.newOutputStream(file.toPath())) { 24 | Utils.copyStreams(is, os); 25 | } 26 | } 27 | } catch (IOException ignored) { 28 | } 29 | return file; 30 | } 31 | 32 | public static File getFileFromResources(String name, String extension) { 33 | return getFileFromResources("src/test/resources/files", name, extension); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example-junit5/src/main/java/com/epam/reportportal/example/junit5/util/LoggingUtils.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit5.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.File; 7 | import java.util.Base64; 8 | 9 | /** 10 | * Useful utility class for binary data logging (e.g. sending files to ReportPortal). You can disable console output for 11 | * `binary_data_logger` to avoid redundant verbose output. 12 | */ 13 | public class LoggingUtils { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger("binary_data_logger"); 16 | 17 | private LoggingUtils() { 18 | //statics only 19 | } 20 | 21 | public static void log(File file, String message) { 22 | LOGGER.info("RP_MESSAGE#FILE#{}#{}", file.getAbsolutePath(), message); 23 | } 24 | 25 | public static void logBase64(String base64, String message) { 26 | LOGGER.info("RP_MESSAGE#BASE64#{}#{}", base64, message); 27 | } 28 | 29 | public static void log(byte[] bytes, String message) { 30 | logBase64(Base64.getEncoder().encodeToString(bytes), message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-junit5/src/test/java/com/epam/reportportal/example/junit5/LogTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit5; 2 | 3 | import com.epam.reportportal.example.junit5.util.Attachment; 4 | import com.epam.reportportal.example.junit5.util.LoggingUtils; 5 | import org.junit.jupiter.api.Test; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import java.util.Arrays; 10 | 11 | import static com.epam.reportportal.example.junit5.util.AttachmentHelper.FILE_NAME; 12 | import static com.epam.reportportal.example.junit5.util.AttachmentHelper.getFileFromResources; 13 | 14 | public class LogTest { 15 | 16 | private static final Logger LOGGER = LoggerFactory.getLogger(LogTest.class); 17 | 18 | @Test 19 | void logTest() { 20 | LOGGER.trace("Trace level log"); 21 | LOGGER.debug("Debug level log"); 22 | LOGGER.info("Info level log"); 23 | LOGGER.warn("Warn level log"); 24 | LOGGER.error("Error level log"); 25 | throw new IllegalArgumentException("Critical exception"); 26 | } 27 | 28 | @Test 29 | void logWithAttachmentTest() { 30 | Arrays.stream(Attachment.values()).forEach(it -> LoggingUtils.log(getFileFromResources(FILE_NAME, it.getExtension()), 31 | String.format("I'm logging content via temp %s file", it.name()))); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example-junit5/src/test/java/com/epam/reportportal/example/junit5/RetryTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit5; 2 | 3 | import org.junit.jupiter.api.RepeatedTest; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.util.Random; 8 | 9 | import static org.junit.jupiter.api.Assertions.fail; 10 | 11 | /** 12 | * @author Ihar Kahadouski 13 | */ 14 | public class RetryTest { 15 | 16 | private static final Logger LOGGER = LoggerFactory.getLogger(RetryTest.class); 17 | private static Random RANDOM = new Random(); 18 | 19 | @RepeatedTest(3) 20 | void retry() { 21 | if (RANDOM.nextBoolean()) { 22 | LOGGER.info("passed"); 23 | } else { 24 | LOGGER.info("failed"); 25 | fail(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /example-junit5/src/test/java/com/epam/reportportal/example/junit5/annotated/DescriptionTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit5.annotated; 2 | 3 | import com.epam.reportportal.annotations.Description; 4 | import org.junit.jupiter.api.DynamicTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.TestFactory; 7 | 8 | import java.util.stream.Stream; 9 | 10 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 11 | 12 | @Description("Description from Description annotation on class level") 13 | public class DescriptionTest { 14 | 15 | @Test 16 | @Description("Description from Description annotation on method level overrides Description set at class level") 17 | public void testDescriptionTestMethod() { 18 | System.out.println("Inside testDescriptionTestMethod"); 19 | } 20 | 21 | @Test 22 | public void testDescriptionTestClass() { 23 | System.out.println("Inside testDescriptionTestClass"); 24 | } 25 | 26 | @TestFactory 27 | @Description("Description from Description annotation on dynamic test factory") 28 | public Stream testForTestFactory() { 29 | return Stream.of(dynamicTest("My dynamic test", () -> System.out.println("Inside dynamic test"))); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /example-junit5/src/test/java/com/epam/reportportal/example/junit5/annotated/DisplayNameTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit5.annotated; 2 | 3 | import com.epam.reportportal.annotations.DisplayName; 4 | import org.junit.jupiter.api.DynamicTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.TestFactory; 7 | 8 | import java.util.stream.Stream; 9 | 10 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 11 | 12 | @DisplayName("Display name from DisplayName annotation on class level") 13 | public class DisplayNameTest { 14 | @Test 15 | @DisplayName("Display name from DisplayName annotation on method level") 16 | public void testDisplayName() { 17 | System.out.println("Inside testDisplayName"); 18 | } 19 | 20 | @TestFactory 21 | @DisplayName("Display name from DisplayName annotation on dynamic test factory") 22 | public Stream testForTestFactory() { 23 | return Stream.of(dynamicTest("My dynamic test", () -> System.out.println("Inside dynamic test"))); 24 | } 25 | 26 | @Test 27 | @org.junit.jupiter.api.DisplayName("Display name from JUnit's annotation on method level") 28 | @DisplayName("Display name from ReportPortal's annotation overrides JUnit's annotation") 29 | public void testDisplayNameOverride() { 30 | System.out.println("Inside testDisplayNameOverride"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-junit5/src/test/java/com/epam/reportportal/example/junit5/annotated/JUnit5Tests.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit5.annotated; 2 | 3 | import com.epam.reportportal.annotations.TestCaseId; 4 | import com.epam.reportportal.annotations.TestCaseIdKey; 5 | import com.epam.reportportal.junit5.ReportPortalExtension; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | import org.junit.jupiter.params.ParameterizedTest; 9 | import org.junit.jupiter.params.provider.CsvSource; 10 | 11 | @ExtendWith(ReportPortalExtension.class) 12 | class JUnit5Tests { 13 | 14 | @TestCaseId(value = "JU5.1.0") 15 | @Test 16 | void baseClassTest() { 17 | 18 | } 19 | 20 | @TestCaseId(parametrized = true) 21 | @ParameterizedTest 22 | @CsvSource({ "first", "second", "third" }) 23 | void parameterizedTestWithCsvSource(@TestCaseIdKey String value) { 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /example-junit5/src/test/java/com/epam/reportportal/example/junit5/annotated/SimpleIssueTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.junit5.annotated; 18 | 19 | import com.epam.reportportal.annotations.Issue; 20 | import org.junit.jupiter.api.Test; 21 | 22 | public class SimpleIssueTest { 23 | 24 | public static final String FAILURE_MESSAGE = "This test is expected to fail"; 25 | 26 | @Test 27 | @Issue(value = "pb001", comment = FAILURE_MESSAGE) 28 | public void failureTest() { 29 | throw new IllegalStateException(FAILURE_MESSAGE); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /example-junit5/src/test/java/com/epam/reportportal/example/junit5/attribute/ItemAttributeTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit5.attribute; 2 | 3 | import com.epam.reportportal.annotations.attribute.Attribute; 4 | import com.epam.reportportal.annotations.attribute.Attributes; 5 | import com.epam.reportportal.annotations.attribute.MultiKeyAttribute; 6 | import com.epam.reportportal.annotations.attribute.MultiValueAttribute; 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Tag; 9 | import org.junit.jupiter.api.Test; 10 | 11 | import static org.junit.jupiter.api.Assertions.assertTrue; 12 | 13 | /** 14 | * @author Ivan Budayeu 15 | */ 16 | //@ExtendWith(ReportPortalExtension.class) 17 | public class ItemAttributeTest { 18 | 19 | @Test 20 | @Attributes(attributes = { @Attribute(key = "key", value = "value") }) 21 | public void first() { 22 | Assertions.assertEquals(1, 1); 23 | } 24 | 25 | @Test 26 | @Attributes(attributes = { @Attribute(key = "key1", value = "value1"), 27 | @Attribute(key = "key2", value = "value2") }, multiKeyAttributes = { @MultiKeyAttribute(keys = { "k1", "k2" }, value = "v") }) 28 | public void second() { 29 | Assertions.assertEquals(1, 1); 30 | } 31 | 32 | @Test 33 | @Attributes(multiValueAttributes = { @MultiValueAttribute(isNullKey = true, values = { "v1", "v2" }) }) 34 | public void third() { 35 | Assertions.assertEquals(1, 1); 36 | } 37 | 38 | @Tag("fourth") 39 | @Test 40 | void fourth() { 41 | assertTrue(true); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /example-junit5/src/test/java/com/epam/reportportal/example/junit5/logging/ReportsStepWithDefectTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.junit5.logging; 2 | 3 | import org.junit.jupiter.api.Disabled; 4 | import org.junit.jupiter.api.DisplayName; 5 | import org.junit.jupiter.api.Test; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import static org.junit.jupiter.api.Assertions.assertEquals; 10 | import static org.junit.jupiter.api.Assertions.assertThrows; 11 | 12 | public class ReportsStepWithDefectTest { 13 | 14 | private static final Logger LOGGER = LoggerFactory.getLogger(ReportsStepWithDefectTest.class); 15 | 16 | @Test 17 | @Disabled("for demonstration purposes") 18 | @DisplayName("DisabledTest") 19 | public void testSkipped() { 20 | LOGGER.info("I'm disabled test"); 21 | } 22 | 23 | @Test 24 | public void testFailure() { 25 | assertEquals(2, 1); 26 | } 27 | 28 | @Test 29 | public void testFailureWithCustomMessage() { 30 | assertEquals(2, 1, "Failure msg"); 31 | } 32 | 33 | @Test 34 | public void expectedFailureAbsent() { 35 | assertThrows(AssertionError.class, () -> assertEquals(1, 1)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /example-junit5/src/test/java/com/epam/reportportal/example/junit5/nested/step/pattern/Container.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.junit5.nested.step.pattern; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * @author Ivan Budayeu 23 | */ 24 | public class Container { 25 | 26 | private List items; 27 | 28 | private String name; 29 | 30 | public Container(List items, String name) { 31 | this.items = items; 32 | this.name = name; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "Container"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example-junit5/src/test/java/com/epam/reportportal/example/junit5/nested/step/pattern/Item.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.junit5.nested.step.pattern; 18 | 19 | /** 20 | * @author Ivan Budayeu 21 | */ 22 | public class Item { 23 | private String name; 24 | 25 | public Item(String name) { 26 | this.name = name; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "Item"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example-junit5/src/test/resources/META-INF/aop-ajc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /example-junit5/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension: -------------------------------------------------------------------------------- 1 | com.epam.reportportal.junit5.ReportPortalExtension 2 | -------------------------------------------------------------------------------- /example-junit5/src/test/resources/files/file.cmd: -------------------------------------------------------------------------------- 1 | title Batch File Testing 2 | echo Hello World 3 | echo. 4 | echo Starting Notepad 5 | start notepad 6 | echo. 7 | echo Starting Wordpad 8 | start Wordpad 9 | echo. 10 | pause 11 | exit -------------------------------------------------------------------------------- /example-junit5/src/test/resources/files/file.css: -------------------------------------------------------------------------------- 1 | p { 2 | font-family: arial, helvetica, sans-serif; 3 | } 4 | 5 | h2 { 6 | font-size: 20pt; 7 | color: red; 8 | background: white; 9 | } 10 | 11 | .note { 12 | color: red; 13 | background-color: yellow; 14 | font-weight: bold; 15 | } 16 | 17 | p#paragraph1 { 18 | padding-left: 10px; 19 | } 20 | 21 | a:hover { 22 | text-decoration: none; 23 | } 24 | 25 | #news p { 26 | color: blue; 27 | } 28 | 29 | [type="button"] { 30 | background-color: green; 31 | } -------------------------------------------------------------------------------- /example-junit5/src/test/resources/files/file.csv: -------------------------------------------------------------------------------- 1 | 1997,Ford,E350,"ac, abs, moon",3000.00 2 | 1999,Chevy,"Venture ""Extended Edition""","",4900.00 3 | 1996,Jeep,Grand Cherokee,"MUST SELL! air, moon roof, loaded",4799.00 -------------------------------------------------------------------------------- /example-junit5/src/test/resources/files/file.har: -------------------------------------------------------------------------------- 1 | { 2 | "log": { 3 | "version": "1.2", 4 | "creator": { 5 | "name": "WebInspector", 6 | "version": "537.36" 7 | }, 8 | "pages": [ 9 | { 10 | "startedDateTime": "2017-12-13T11:21:18.288Z", 11 | "id": "page_2", 12 | "title": "http://localhost:8080/", 13 | "pageTimings": { 14 | "onContentLoad": 330.9420000005048, 15 | "onLoad": 464.73599999808357 16 | } 17 | } 18 | ] 19 | } 20 | } -------------------------------------------------------------------------------- /example-junit5/src/test/resources/files/file.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-junit5/src/test/resources/files/file.jpg -------------------------------------------------------------------------------- /example-junit5/src/test/resources/files/file.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-junit5/src/test/resources/files/file.pdf -------------------------------------------------------------------------------- /example-junit5/src/test/resources/files/file.php: -------------------------------------------------------------------------------- 1 | a = $a; 11 | $this->b = $b; 12 | } 13 | 14 | public function plus() 15 | { 16 | return $this->a + $this->b; 17 | } 18 | /* ............... */ 19 | } 20 | 21 | $d = new C1(1, 2); 22 | echo $d->plus(); // 3 23 | ?> -------------------------------------------------------------------------------- /example-junit5/src/test/resources/files/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-junit5/src/test/resources/files/file.png -------------------------------------------------------------------------------- /example-junit5/src/test/resources/files/file.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-junit5/src/test/resources/files/file.tar.gz -------------------------------------------------------------------------------- /example-junit5/src/test/resources/files/file.txt: -------------------------------------------------------------------------------- 1 | Copyright 2019 EPAM Systems 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /example-junit5/src/test/resources/files/file.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Here is some xml content 4 | 5 | -------------------------------------------------------------------------------- /example-junit5/src/test/resources/files/file.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-junit5/src/test/resources/files/file.zip -------------------------------------------------------------------------------- /example-junit5/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.extensions.autodetection.enabled=true 2 | junit.jupiter.execution.parallel.enabled=true 3 | junit.jupiter.execution.parallel.config.strategy=dynamic 4 | -------------------------------------------------------------------------------- /example-junit5/src/test/resources/reportportal.properties: -------------------------------------------------------------------------------- 1 | rp.endpoint=http://example.com 2 | rp.api.key=api-key 3 | rp.launch=launch-name 4 | rp.project=project-name 5 | rp.attributes=key:value;value 6 | rp.reporting.async=true 7 | rp.reporting.callback=true -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/HelloLoggingSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock 18 | 19 | import org.slf4j.LoggerFactory 20 | import spock.lang.Specification 21 | 22 | class HelloLoggingSpec extends Specification { 23 | def LOGGER = LoggerFactory.getLogger(HelloLoggingSpec.class) 24 | 25 | 26 | def "logging in a test example"() { 27 | LOGGER.info("Hello! I'm logging from a test") 28 | 29 | expect: true 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/HelloSpockSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock 18 | 19 | import spock.lang.Specification 20 | 21 | class HelloSpockSpec extends Specification { 22 | def "length of Spock's and his friends' names"() { 23 | expect: 24 | name.size() == length 25 | 26 | where: 27 | name | length 28 | "Spock" | 5 29 | "Kirk" | 4 30 | "Scotty" | 6 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/HelloSpockSpecInherited.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock 18 | 19 | class HelloSpockSpecInherited extends HelloSpockSpecUnroll { 20 | public static final String INHERITED_TEST_NAME = "simple test" 21 | 22 | def "simple test"() { 23 | expect: 24 | //noinspection GroovyPointlessBoolean 25 | true == true 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/HelloSpockSpecUnroll.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock 18 | 19 | import spock.lang.Specification 20 | import spock.lang.Unroll 21 | 22 | class HelloSpockSpecUnroll extends Specification { 23 | public static final String TEST_NAME = "length of Spock's and his friends' names" 24 | 25 | @Unroll 26 | def "length of Spock's and his friends' names" () { 27 | expect: 28 | name.size() == length 29 | 30 | where: 31 | name | length 32 | "Spock" | 5 33 | "Kirk" | 4 34 | "Scotty" | 6 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/OrderedInteractionsSpec.groovy: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2021 EPAM Systems 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.epam.reportportal.example.spock 19 | 20 | import spock.lang.Specification 21 | 22 | class OrderedInteractionsSpec extends Specification { 23 | def "collaborators must be invoked in order"() { 24 | def coll1 = Mock(Collaborator) 25 | def coll2 = Mock(Collaborator) 26 | 27 | when: 28 | // try to reverse the order of these invocations and see what happens 29 | coll1.collaborate() 30 | coll2.collaborate() 31 | 32 | then: 33 | 1 * coll1.collaborate() 34 | 35 | then: 36 | 1 * coll2.collaborate() 37 | } 38 | } 39 | 40 | interface Collaborator { 41 | def collaborate() 42 | } 43 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/attributes/FixtureAttributesSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.attributes 18 | 19 | import com.epam.reportportal.annotations.attribute.Attribute 20 | import com.epam.reportportal.annotations.attribute.Attributes 21 | import spock.lang.Specification 22 | 23 | class FixtureAttributesSpec extends Specification { 24 | 25 | @Attributes(attributes = @Attribute(key = "key", value = "value")) 26 | def "my empty fixture"() { 27 | expect: 28 | //noinspection GroovyPointlessBoolean 29 | true == true 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/attributes/SpecAttributes.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.attributes 18 | 19 | import com.epam.reportportal.annotations.attribute.Attribute 20 | import com.epam.reportportal.annotations.attribute.Attributes 21 | import spock.lang.Specification 22 | 23 | @SuppressWarnings('UnnecessaryQualifiedReference') 24 | @Attributes(attributes = @Attribute(key = SpecAttributes.KEY, value = SpecAttributes.VALUE)) 25 | class SpecAttributes extends Specification { 26 | public static final String KEY = "attribute_test_key" 27 | public static final String VALUE = "attribute_test_value" 28 | 29 | def "my empty fixture"() { 30 | expect: 31 | //noinspection GroovyPointlessBoolean 32 | true == true 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fail/FailsInDifferentMethodSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fail 18 | 19 | import spock.lang.Specification 20 | 21 | class FailsInDifferentMethodSpec extends Specification { 22 | 23 | def anotherFailedMethod() { 24 | throw new IllegalStateException("Some test flow failure") 25 | } 26 | 27 | def failedMethod() { 28 | anotherFailedMethod() 29 | } 30 | 31 | def "failing test 1"() { 32 | given: 33 | failedMethod() 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fail/FailsWithAnnotationFailSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fail 18 | 19 | import spock.lang.FailsWith 20 | import spock.lang.Specification 21 | 22 | class FailsWithAnnotationFailSpec extends Specification { 23 | 24 | @FailsWith(IllegalArgumentException.class) 25 | def "simple test 1"() { 26 | expect: 27 | throw new IllegalStateException("Fail!") 28 | } 29 | 30 | def "simple test 2"() { 31 | expect: 32 | //noinspection GroovyPointlessBoolean 33 | true == true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fail/HelloSpockSpecFailed.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fail 18 | 19 | import spock.lang.Rollup 20 | import spock.lang.Specification 21 | 22 | class HelloSpockSpecFailed extends Specification { 23 | @Rollup 24 | def "length of Spock's and his friends' names failed"() { 25 | expect: 26 | name.size() == length 27 | 28 | where: 29 | name | length 30 | "Spock" | 5 31 | "Kirk" | 4 32 | "Scotty" | 7 // failed case 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fail/HelloSpockSpecUnrollFailed.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fail 18 | 19 | 20 | import spock.lang.Specification 21 | 22 | class HelloSpockSpecUnrollFailed extends Specification { 23 | 24 | def "length of Spock's and his friends' names failed"() { 25 | expect: 26 | name.size() == length 27 | 28 | where: 29 | name | length 30 | "Spock" | 5 31 | "Kirk" | 4 32 | "Scotty" | 7 // failed case 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fixtures/CleanupFixtureFailedSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fixtures 18 | 19 | 20 | import spock.lang.Specification 21 | 22 | class CleanupFixtureFailedSpec extends Specification { 23 | 24 | def cleanup() { 25 | throw new IllegalStateException("Fail!") 26 | } 27 | 28 | def "simple test"() { 29 | expect: 30 | //noinspection GroovyPointlessBoolean 31 | true == true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fixtures/CleanupFixtureSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fixtures 18 | 19 | 20 | import spock.lang.Specification 21 | 22 | class CleanupFixtureSpec extends Specification { 23 | 24 | def cleanup() { 25 | 26 | } 27 | 28 | def "simple test"() { 29 | expect: 30 | //noinspection GroovyPointlessBoolean 31 | true == true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fixtures/CleanupSpecFixture.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fixtures 18 | 19 | 20 | import spock.lang.Specification 21 | 22 | class CleanupSpecFixture extends Specification { 23 | 24 | def cleanupSpec() { 25 | 26 | } 27 | 28 | def "simple test"() { 29 | expect: 30 | //noinspection GroovyPointlessBoolean 31 | true == true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fixtures/CleanupSpecFixtureFailed.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fixtures 18 | 19 | 20 | import spock.lang.Specification 21 | 22 | class CleanupSpecFixtureFailed extends Specification { 23 | 24 | def cleanupSpec() { 25 | throw new IllegalStateException("Fail!") 26 | } 27 | 28 | def "simple test"() { 29 | expect: 30 | //noinspection GroovyPointlessBoolean 31 | true == true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fixtures/SetupFixtureFailedParametersSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fixtures 18 | 19 | import spock.lang.Rollup 20 | import spock.lang.Specification 21 | 22 | class SetupFixtureFailedParametersSpec extends Specification { 23 | 24 | def setup() { 25 | throw new IllegalStateException("Fail!") 26 | } 27 | 28 | @Rollup 29 | def "length of Spock's and his friends' names"() { 30 | expect: 31 | name.size() == length 32 | 33 | where: 34 | name | length 35 | "Spock" | 5 36 | "Kirk" | 4 37 | "Scotty" | 6 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fixtures/SetupFixtureFailedParametersUnrollSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fixtures 18 | 19 | 20 | import spock.lang.Specification 21 | 22 | class SetupFixtureFailedParametersUnrollSpec extends Specification { 23 | 24 | def setup() { 25 | throw new IllegalStateException("Fail!") 26 | } 27 | 28 | def "length of Spock's and his friends' names"() { 29 | expect: 30 | name.size() == length 31 | 32 | where: 33 | name | length 34 | "Spock" | 5 35 | "Kirk" | 4 36 | "Scotty" | 6 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fixtures/SetupFixtureFailedSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fixtures 18 | 19 | 20 | import spock.lang.Specification 21 | 22 | class SetupFixtureFailedSpec extends Specification { 23 | 24 | def setup() { 25 | throw new IllegalStateException("Fail!") 26 | } 27 | 28 | def "simple test"() { 29 | expect: 30 | //noinspection GroovyPointlessBoolean 31 | true == true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fixtures/SetupFixtureSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fixtures 18 | 19 | 20 | import spock.lang.Specification 21 | 22 | class SetupFixtureSpec extends Specification { 23 | 24 | def setup() { 25 | 26 | } 27 | 28 | def "simple test"() { 29 | expect: 30 | //noinspection GroovyPointlessBoolean 31 | true == true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fixtures/SetupSpecFixture.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fixtures 18 | 19 | 20 | import spock.lang.Specification 21 | 22 | class SetupSpecFixture extends Specification { 23 | 24 | def setupSpec() { 25 | 26 | } 27 | 28 | def "simple test"() { 29 | expect: 30 | //noinspection GroovyPointlessBoolean 31 | true == true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fixtures/SetupSpecFixtureFailed.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fixtures 18 | 19 | 20 | import spock.lang.Specification 21 | 22 | class SetupSpecFixtureFailed extends Specification { 23 | 24 | def setupSpec() { 25 | throw new IllegalStateException("Fail!") 26 | } 27 | 28 | def "simple test 1"() { 29 | expect: 30 | //noinspection GroovyPointlessBoolean 31 | true == true 32 | } 33 | 34 | def "simple test 2"() { 35 | expect: 36 | //noinspection GroovyPointlessBoolean 37 | true == true 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/fixtures/SetupSpecFixtureFailedParametersUnroll.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.fixtures 18 | 19 | 20 | import spock.lang.Specification 21 | 22 | class SetupSpecFixtureFailedParametersUnroll extends Specification { 23 | 24 | def setupSpec() { 25 | throw new IllegalStateException("Fail!") 26 | } 27 | 28 | def "length of Spock's and his friends' names"() { 29 | expect: 30 | name.size() == length 31 | 32 | where: 33 | name | length 34 | "Spock" | 5 35 | "Kirk" | 4 36 | "Scotty" | 6 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/ignore/TestOneFeatureIgnoreSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.ignore 18 | 19 | import spock.lang.Ignore 20 | import spock.lang.Specification 21 | 22 | class TestOneFeatureIgnoreSpec extends Specification { 23 | 24 | @Ignore 25 | def "simple test 1"() { 26 | expect: 27 | //noinspection GroovyPointlessBoolean 28 | true == true 29 | } 30 | 31 | def "simple test 2"() { 32 | expect: 33 | //noinspection GroovyPointlessBoolean 34 | true == true 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/ignore/TestRestFeaturesIgnoreSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.ignore 18 | 19 | 20 | import spock.lang.IgnoreRest 21 | import spock.lang.Specification 22 | 23 | class TestRestFeaturesIgnoreSpec extends Specification { 24 | 25 | @IgnoreRest 26 | def "simple test 1"() { 27 | expect: 28 | //noinspection GroovyPointlessBoolean 29 | true == true 30 | } 31 | 32 | def "simple test 2"() { 33 | expect: 34 | //noinspection GroovyPointlessBoolean 35 | true == true 36 | } 37 | 38 | def "simple test 3"() { 39 | expect: 40 | //noinspection GroovyPointlessBoolean 41 | true == true 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/params/NullParamSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.params 18 | 19 | import spock.lang.Rollup 20 | import spock.lang.Specification 21 | 22 | class NullParamSpec extends Specification { 23 | @Rollup 24 | def "length of Spock's and his friends' names"() { 25 | expect: 26 | (param == null) == value 27 | 28 | where: 29 | param | value 30 | null | true 31 | "Kirk" | false 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/params/NullParamSpecUnroll.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.params 18 | 19 | 20 | import spock.lang.Specification 21 | 22 | class NullParamSpecUnroll extends Specification { 23 | def "length of Spock's and his friends' names"() { 24 | expect: 25 | (param == null) == value 26 | 27 | where: 28 | param | value 29 | null | true 30 | "Kirk" | false 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-spock/src/test/groovy/com/epam/reportportal/example/spock/testcaseid/PlainTestCaseIdSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.spock.testcaseid 18 | 19 | import com.epam.reportportal.annotations.TestCaseId 20 | import spock.lang.Specification 21 | 22 | class PlainTestCaseIdSpec extends Specification { 23 | 24 | public static final String TEST_CASE_ID = "my_test_case_id" 25 | 26 | @TestCaseId(TEST_CASE_ID) 27 | def "simple named test case id test"() { 28 | expect: 29 | //noinspection GroovyPointlessBoolean 30 | true == true 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-spock/src/test/resources/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021 EPAM Systems 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | com.epam.reportportal.spock.ReportPortalSpockExtension 18 | -------------------------------------------------------------------------------- /example-spock/src/test/resources/reportportal.properties: -------------------------------------------------------------------------------- 1 | rp.endpoint=http://example.com 2 | rp.api.key=api-key 3 | rp.launch=launch-name 4 | rp.project=project-name 5 | rp.attributes=key:value;value 6 | rp.reporting.async=true 7 | -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/java/com/epam/reportportal/example/testng/logback/logging/LuckyPugTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.logback.logging; 2 | 3 | import com.epam.reportportal.example.testng.logback.util.LoggingUtils; 4 | import com.epam.reportportal.example.testng.logback.util.MagicRandomizer; 5 | import com.epam.reportportal.utils.files.Utils; 6 | import org.testng.annotations.Test; 7 | 8 | import java.io.File; 9 | import java.io.IOException; 10 | 11 | /** 12 | * Logs image 13 | * 14 | * @author Andrei Varabyeu 15 | */ 16 | public class LuckyPugTest { 17 | @Test 18 | public void logImageBase64() throws IOException { 19 | /* Generate 10 logs with pugs. Pug may be lucky or unlucky based on randomizer */ 20 | for (int i = 0; i < 20; i++) { 21 | /* 50 percents. So we should have approximately same count of lucky and unlucky pugs */ 22 | boolean happy = MagicRandomizer.checkYourLucky(30); 23 | String image = getImageResource(happy); 24 | 25 | LoggingUtils.log(Utils.getFile(new File(image)).read(), "Pug is " + (happy ? "HAPPY" : "NOT HAPPY")); 26 | } 27 | } 28 | 29 | private String getImageResource(boolean lucky) { 30 | return "src/main/resources/pug/" + (lucky ? "lucky.jpg" : "unlucky.jpg"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/java/com/epam/reportportal/example/testng/logback/logging/XmlLoggingTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.logback.logging; 2 | 3 | import com.epam.reportportal.example.testng.logback.util.AttachmentHelper; 4 | import com.epam.reportportal.example.testng.logback.util.LoggingUtils; 5 | import com.epam.reportportal.utils.files.Utils; 6 | import org.testng.annotations.Test; 7 | 8 | import java.io.File; 9 | import java.io.IOException; 10 | 11 | /** 12 | * JUST an example of file logging 13 | * 14 | * @author Andrei Varabyeu 15 | */ 16 | public class XmlLoggingTest { 17 | public static final String XML_FILE_FOLDER_PATH = "src/main/resources/xml"; 18 | public static final String XML_FILE_PATH = XML_FILE_FOLDER_PATH + "/file.xml"; 19 | 20 | @Test 21 | public void logXmlBase64() throws IOException { 22 | /* here we are logging some binary data as BASE64 string */ 23 | LoggingUtils.log(Utils.getFileAsByteSource(new File(XML_FILE_PATH)).read(), "I'm logging content via BASE64"); 24 | } 25 | 26 | @Test 27 | public void logXmlFile() { 28 | /* here we are logging some binary data as file (useful for selenium) */ 29 | File file = AttachmentHelper.getFileFromResources(XML_FILE_FOLDER_PATH, "file", "xml"); 30 | LoggingUtils.log(file, "I'm logging content via BASE64"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/java/com/epam/reportportal/example/testng/logback/util/AttachmentHelper.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.logback.util; 2 | 3 | import com.epam.reportportal.utils.files.ByteSource; 4 | import com.epam.reportportal.utils.files.Utils; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | 11 | /** 12 | * Utility file to copy / read resource files. 13 | */ 14 | public class AttachmentHelper { 15 | public static File getFileFromResources(String path, String name, String extension) { 16 | File file = null; 17 | try { 18 | file = File.createTempFile("rp-test", "." + extension); 19 | ByteSource source = Utils.getFileAsByteSource(new File(String.format("%s/%s.%s", path, name, extension))); 20 | try (InputStream is = source.openStream()) { 21 | try (OutputStream os = java.nio.file.Files.newOutputStream(file.toPath())) { 22 | Utils.copyStreams(is, os); 23 | } 24 | } 25 | } catch (IOException ignored) { 26 | } 27 | return file; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/java/com/epam/reportportal/example/testng/logback/util/LoggingUtils.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.logback.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.File; 7 | import java.util.Base64; 8 | 9 | /** 10 | * Useful utility class for binary data logging (e.g. sending files to ReportPortal). You can disable console output for 11 | * `binary_data_logger` to avoid redundant verbose output. 12 | */ 13 | public class LoggingUtils { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger("binary_data_logger"); 16 | 17 | private LoggingUtils() { 18 | //statics only 19 | } 20 | 21 | public static void log(File file, String message) { 22 | LOGGER.info("RP_MESSAGE#FILE#{}#{}", file.getAbsolutePath(), message); 23 | } 24 | 25 | public static void logBase64(String base64, String message) { 26 | LOGGER.info("RP_MESSAGE#BASE64#{}#{}", base64, message); 27 | } 28 | 29 | public static void log(byte[] bytes, String message) { 30 | logBase64(Base64.getEncoder().encodeToString(bytes), message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/java/com/epam/reportportal/example/testng/logback/util/MagicRandomizer.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.logback.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.util.Random; 7 | 8 | /** 9 | * Just a randomizer 10 | * 11 | * @author Andrei Varabyeu 12 | */ 13 | public class MagicRandomizer { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(MagicRandomizer.class); 16 | 17 | private static final Random RANDOM = new Random(); 18 | private static final int UPPER_LIMIT = 100; 19 | 20 | private MagicRandomizer() { 21 | //statics only 22 | } 23 | 24 | public static int luckyInt(int bound) { 25 | return RANDOM.nextInt(bound); 26 | } 27 | 28 | /** 29 | * Just put probability and check your luckiness 30 | * 31 | * @param probability value [0--100] 32 | * @return TRUE if you are really lucky! 33 | */ 34 | public static boolean checkYourLucky(int probability) { 35 | boolean lucky = luckyInt(UPPER_LIMIT + 1) <= probability; 36 | LOGGER.debug("Generating [TRUE/FALSE] with probability {}%. Result {}", probability, lucky); 37 | return lucky; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/resources/META-INF/aop-ajc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/resources/META-INF/services/org.testng.ITestNGListener: -------------------------------------------------------------------------------- 1 | com.epam.reportportal.testng.ReportPortalTestNGListener 2 | -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/resources/files/Test.cmd: -------------------------------------------------------------------------------- 1 | title Batch File Testing 2 | echo Hello World 3 | echo. 4 | echo Starting Notepad 5 | start notepad 6 | echo. 7 | echo Starting Wordpad 8 | start Wordpad 9 | echo. 10 | pause 11 | exit -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/resources/files/Test.csv: -------------------------------------------------------------------------------- 1 | 1997,Ford,E350,"ac, abs, moon",3000.00 2 | 1999,Chevy,"Venture ""Extended Edition""","",4900.00 3 | 1996,Jeep,Grand Cherokee,"MUST SELL! air, moon roof, loaded",4799.00 -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/resources/files/css.css: -------------------------------------------------------------------------------- 1 | p { 2 | font-family: arial, helvetica, sans-serif; 3 | } 4 | 5 | h2 { 6 | font-size: 20pt; 7 | color: red; 8 | background: white; 9 | } 10 | 11 | .note { 12 | color: red; 13 | background-color: yellow; 14 | font-weight: bold; 15 | } 16 | 17 | p#paragraph1 { 18 | padding-left: 10px; 19 | } 20 | 21 | a:hover { 22 | text-decoration: none; 23 | } 24 | 25 | #news p { 26 | color: blue; 27 | } 28 | 29 | [type="button"] { 30 | background-color: green; 31 | } -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/resources/files/demo.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-fork-execution/src/main/resources/files/demo.zip -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/resources/files/har.har: -------------------------------------------------------------------------------- 1 | { 2 | "log": { 3 | "version": "1.2", 4 | "creator": { 5 | "name": "WebInspector", 6 | "version": "537.36" 7 | }, 8 | "pages": [ 9 | { 10 | "startedDateTime": "2017-12-13T11:21:18.288Z", 11 | "id": "page_2", 12 | "title": "http://localhost:8080/", 13 | "pageTimings": { 14 | "onContentLoad": 330.9420000005048, 15 | "onLoad": 464.73599999808357 16 | } 17 | } 18 | ] 19 | } 20 | } -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/resources/files/php.php: -------------------------------------------------------------------------------- 1 | a = $a; 11 | $this->b = $b; 12 | } 13 | 14 | public function plus() 15 | { 16 | return $this->a + $this->b; 17 | } 18 | /* ............... */ 19 | } 20 | 21 | $d = new C1(1, 2); 22 | echo $d->plus(); // 3 23 | ?> -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/resources/files/plain.txt: -------------------------------------------------------------------------------- 1 | Copyright 2016 EPAM Systems 2 | This file is part of EPAM Report Portal. 3 | https://github.com/reportportal/service-ui 4 | Report Portal is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | Report Portal is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License 13 | along with Report Portal. If not, see . -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/resources/files/test.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-fork-execution/src/main/resources/files/test.pdf -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/resources/pug/lucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-fork-execution/src/main/resources/pug/lucky.jpg -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/resources/pug/unlucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-fork-execution/src/main/resources/pug/unlucky.jpg -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/resources/reportportal.properties: -------------------------------------------------------------------------------- 1 | rp.endpoint=http://example.com 2 | rp.api.key=api-key 3 | rp.launch = superadmin_TEST_EXAMPLE 4 | rp.project = superadmin_personal 5 | rp.reporting.async=true 6 | rp.client.join=true 7 | rp.client.join.lock.file.name=rp.lock 8 | rp.client.join.sync.file.name=rp.sync -------------------------------------------------------------------------------- /example-testng-fork-execution/src/main/resources/xml/file.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Here is some xml content 4 | 5 | -------------------------------------------------------------------------------- /example-testng-fork-execution/suites/logging_tests.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /example-testng-fork-execution/suites/logging_xml_tests.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example-testng-log4j/src/main/java/com/epam/reportportal/example/testng/log4j/logging/LuckyPugTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.log4j.logging; 2 | 3 | import com.epam.reportportal.example.testng.log4j.util.LoggingUtils; 4 | import com.epam.reportportal.example.testng.log4j.util.MagicRandomizer; 5 | import com.epam.reportportal.utils.files.Utils; 6 | import org.testng.annotations.Test; 7 | 8 | import java.io.File; 9 | import java.io.IOException; 10 | 11 | /** 12 | * Logs image 13 | * 14 | * @author Andrei Varabyeu 15 | */ 16 | public class LuckyPugTest { 17 | @Test 18 | public void logImageBase64() throws IOException { 19 | /* Generate 10 logs with pugs. Pug may be lucky or unlucky based on randomizer */ 20 | for (int i = 0; i < 20; i++) { 21 | /* 50 percents. So we should have approximately same count of lucky and unlucky pugs */ 22 | boolean happy = MagicRandomizer.checkYourLucky(30); 23 | String image = getImageResource(happy); 24 | 25 | LoggingUtils.log(Utils.getFile(new File(image)).read(), "Pug is " + (happy ? "HAPPY" : "NOT HAPPY")); 26 | } 27 | } 28 | 29 | private String getImageResource(boolean lucky) { 30 | return "src/main/resources/pug/" + (lucky ? "lucky.jpg" : "unlucky.jpg"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-testng-log4j/src/main/java/com/epam/reportportal/example/testng/log4j/logging/XmlLoggingTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.log4j.logging; 2 | 3 | import com.epam.reportportal.example.testng.log4j.util.LoggingUtils; 4 | import com.epam.reportportal.utils.files.Utils; 5 | import org.testng.annotations.Test; 6 | 7 | import java.io.File; 8 | import java.io.IOException; 9 | 10 | /** 11 | * JUST an example of file logging 12 | * 13 | * @author Andrei Varabyeu 14 | */ 15 | public class XmlLoggingTest { 16 | public static final String XML_FILE_PATH = "xml/file.xml"; 17 | 18 | @Test 19 | public void logXmlBase64() throws IOException { 20 | /* here we are logging some binary data as BASE64 string */ 21 | LoggingUtils.log(Utils.getFileAsByteSource(new File(XML_FILE_PATH)).read(), "I'm logging content via BASE64"); 22 | } 23 | 24 | @Test 25 | public void logXmlFile() { 26 | /* here we are logging some binary data as file (useful for selenium) */ 27 | LoggingUtils.log(new File(XML_FILE_PATH), "I'm logging content via temp file"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /example-testng-log4j/src/main/java/com/epam/reportportal/example/testng/log4j/step/pattern/Container.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.testng.log4j.step.pattern; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * @author Ivan Budayeu 23 | */ 24 | public class Container { 25 | 26 | private List items; 27 | 28 | private String name; 29 | 30 | public Container(List items, String name) { 31 | this.items = items; 32 | this.name = name; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "Container"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example-testng-log4j/src/main/java/com/epam/reportportal/example/testng/log4j/step/pattern/Item.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.testng.log4j.step.pattern; 18 | 19 | /** 20 | * @author Ivan Budayeu 21 | */ 22 | public class Item { 23 | private String name; 24 | 25 | public Item(String name) { 26 | this.name = name; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "Item"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example-testng-log4j/src/main/java/com/epam/reportportal/example/testng/log4j/util/AttachmentHelper.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.log4j.util; 2 | 3 | import com.epam.reportportal.utils.files.ByteSource; 4 | import com.epam.reportportal.utils.files.Utils; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | 11 | /** 12 | * Utility file to copy / read resource files. 13 | */ 14 | public class AttachmentHelper { 15 | public static File getFileFromResources(String path, String name, String extension) { 16 | File file = null; 17 | try { 18 | file = File.createTempFile("rp-test", "." + extension); 19 | ByteSource source = Utils.getFileAsByteSource(new File(String.format("%s/%s.%s", path, name, extension))); 20 | try (InputStream is = source.openStream()) { 21 | try (OutputStream os = java.nio.file.Files.newOutputStream(file.toPath())) { 22 | Utils.copyStreams(is, os); 23 | } 24 | } 25 | } catch (IOException ignored) { 26 | } 27 | return file; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /example-testng-log4j/src/main/java/com/epam/reportportal/example/testng/log4j/util/LoggingUtils.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.log4j.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.File; 7 | import java.util.Base64; 8 | 9 | /** 10 | * Useful utility class for binary data logging (e.g. sending files to ReportPortal). You can disable console output for 11 | * `binary_data_logger` to avoid redundant verbose output. 12 | */ 13 | public class LoggingUtils { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger("binary_data_logger"); 16 | 17 | private LoggingUtils() { 18 | //statics only 19 | } 20 | 21 | public static void log(File file, String message) { 22 | LOGGER.info("RP_MESSAGE#FILE#{}#{}", file.getAbsolutePath(), message); 23 | } 24 | 25 | public static void logBase64(String base64, String message) { 26 | LOGGER.info("RP_MESSAGE#BASE64#{}#{}", base64, message); 27 | } 28 | 29 | public static void log(byte[] bytes, String message) { 30 | logBase64(Base64.getEncoder().encodeToString(bytes), message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-testng-log4j/src/main/java/com/epam/reportportal/example/testng/log4j/util/MagicRandomizer.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.log4j.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.util.Random; 7 | 8 | /** 9 | * Just a randomizer 10 | * 11 | * @author Andrei Varabyeu 12 | */ 13 | public class MagicRandomizer { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(MagicRandomizer.class); 16 | 17 | private static final Random RANDOM = new Random(); 18 | private static final int UPPER_LIMIT = 100; 19 | 20 | private MagicRandomizer() { 21 | //statics only 22 | } 23 | 24 | public static int luckyInt(int bound) { 25 | return RANDOM.nextInt(bound); 26 | } 27 | 28 | /** 29 | * Just put probability and check your luckiness 30 | * 31 | * @param probability value [0--100] 32 | * @return TRUE if you are really lucky! 33 | */ 34 | public static boolean checkYourLucky(int probability) { 35 | boolean lucky = luckyInt(UPPER_LIMIT + 1) <= probability; 36 | LOGGER.debug("Generating [TRUE/FALSE] with probability {}%. Result {}", probability, lucky); 37 | return lucky; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/META-INF/aop-ajc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/META-INF/services/org.testng.ITestNGListener: -------------------------------------------------------------------------------- 1 | com.epam.reportportal.testng.ReportPortalTestNGListener 2 | -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/files/Test.cmd: -------------------------------------------------------------------------------- 1 | title Batch File Testing 2 | echo Hello World 3 | echo. 4 | echo Starting Notepad 5 | start notepad 6 | echo. 7 | echo Starting Wordpad 8 | start Wordpad 9 | echo. 10 | pause 11 | exit -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/files/Test.csv: -------------------------------------------------------------------------------- 1 | 1997,Ford,E350,"ac, abs, moon",3000.00 2 | 1999,Chevy,"Venture ""Extended Edition""","",4900.00 3 | 1996,Jeep,Grand Cherokee,"MUST SELL! air, moon roof, loaded",4799.00 -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/files/css.css: -------------------------------------------------------------------------------- 1 | p { 2 | font-family: arial, helvetica, sans-serif; 3 | } 4 | 5 | h2 { 6 | font-size: 20pt; 7 | color: red; 8 | background: white; 9 | } 10 | 11 | .note { 12 | color: red; 13 | background-color: yellow; 14 | font-weight: bold; 15 | } 16 | 17 | p#paragraph1 { 18 | padding-left: 10px; 19 | } 20 | 21 | a:hover { 22 | text-decoration: none; 23 | } 24 | 25 | #news p { 26 | color: blue; 27 | } 28 | 29 | [type="button"] { 30 | background-color: green; 31 | } -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/files/demo.zip/demo.txt: -------------------------------------------------------------------------------- 1 | hello world 2 | -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/files/php.php: -------------------------------------------------------------------------------- 1 | a = $a; 11 | $this->b = $b; 12 | } 13 | 14 | public function plus() 15 | { 16 | return $this->a + $this->b; 17 | } 18 | /* ............... */ 19 | } 20 | 21 | $d = new C1(1, 2); 22 | echo $d->plus(); // 3 23 | ?> -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/files/plain.txt: -------------------------------------------------------------------------------- 1 | Copyright 2016 EPAM Systems 2 | This file is part of EPAM Report Portal. 3 | https://github.com/reportportal/service-ui 4 | Report Portal is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | Report Portal is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License 13 | along with Report Portal. If not, see . -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/files/test.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-log4j/src/main/resources/files/test.pdf -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/files/yaml.yml: -------------------------------------------------------------------------------- 1 | - name: "Batman" 2 | power: "Money" 3 | race: "Human" 4 | 5 | - name: "Flash" 6 | power: "Speed" 7 | race: "Human" 8 | 9 | - name: "Deadpool" 10 | power: "Human" 11 | race: "???" -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/pug/lucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-log4j/src/main/resources/pug/lucky.jpg -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/pug/unlucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-log4j/src/main/resources/pug/unlucky.jpg -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/reportportal.properties: -------------------------------------------------------------------------------- 1 | rp.endpoint=http://example.com 2 | rp.api.key=api-key 3 | rp.launch=launch-name 4 | rp.project=project-name 5 | rp.attributes=key:value;value 6 | rp.reporting.async=true -------------------------------------------------------------------------------- /example-testng-log4j/src/main/resources/xml/file.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Here is some xml content 4 | 5 | -------------------------------------------------------------------------------- /example-testng-log4j/suites/logging_tests.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /example-testng-log4j/suites/nested_steps_tests.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example-testng-logback/screenshots/fifth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-logback/screenshots/fifth.png -------------------------------------------------------------------------------- /example-testng-logback/screenshots/first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-logback/screenshots/first.png -------------------------------------------------------------------------------- /example-testng-logback/screenshots/fourth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-logback/screenshots/fourth.png -------------------------------------------------------------------------------- /example-testng-logback/screenshots/second.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-logback/screenshots/second.png -------------------------------------------------------------------------------- /example-testng-logback/screenshots/sixth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-logback/screenshots/sixth.png -------------------------------------------------------------------------------- /example-testng-logback/screenshots/third.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-logback/screenshots/third.png -------------------------------------------------------------------------------- /example-testng-logback/src/main/java/com/epam/reportportal/example/testng/logback/annotated/DescriptionTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.logback.annotated; 2 | 3 | import com.epam.reportportal.annotations.Description; 4 | import org.testng.annotations.Test; 5 | 6 | public class DescriptionTest { 7 | 8 | @Test(description = "Description from Test annotation") 9 | public void testDescription() { 10 | System.out.println("In testDescriptionTest"); 11 | } 12 | 13 | @Test 14 | @Description("Description from Description annotation") 15 | public void testDescriptionAnnotation() { 16 | System.out.println("In testDescriptionAnnotation"); 17 | } 18 | 19 | @Test(description = "Description from Test annotation should be ignored") 20 | @Description("Description from Description annotation should override description from Test annotation") 21 | public void testDescriptionAnnotationOverridesTestAnnotation() { 22 | System.out.println("In testDescriptionAnnotationOverridesTestAnnotation"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example-testng-logback/src/main/java/com/epam/reportportal/example/testng/logback/annotated/DisplayNameTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.logback.annotated; 2 | 3 | import com.epam.reportportal.annotations.DisplayName; 4 | import org.testng.annotations.Test; 5 | 6 | @Test(testName = "Name from Test annotation") 7 | public class DisplayNameTest { 8 | @Test 9 | public void testDisplayNameFromTest() { 10 | System.out.println("The Test annotation on class level should add name to the test"); 11 | } 12 | 13 | @Test 14 | @DisplayName("Name from DisplayName annotation") 15 | public void testDisplayNameOverride() { 16 | System.out.println("The DisplayName annotation should override name from Test annotation"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /example-testng-logback/src/main/java/com/epam/reportportal/example/testng/logback/annotated/SimpleIssueTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.testng.logback.annotated; 18 | 19 | import com.epam.reportportal.annotations.Issue; 20 | import org.testng.annotations.Test; 21 | 22 | public class SimpleIssueTest { 23 | 24 | public static final String FAILURE_MESSAGE = "This test is expected to fail"; 25 | 26 | @Test 27 | @Issue(value = "pb001", comment = FAILURE_MESSAGE) 28 | public void failureTest() { 29 | throw new IllegalStateException(FAILURE_MESSAGE); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /example-testng-logback/src/main/java/com/epam/reportportal/example/testng/logback/step/pattern/Container.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.testng.logback.step.pattern; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * @author Ivan Budayeu 23 | */ 24 | public class Container { 25 | 26 | private List items; 27 | 28 | private String name; 29 | 30 | public Container(List items, String name) { 31 | this.items = items; 32 | this.name = name; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "Container"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example-testng-logback/src/main/java/com/epam/reportportal/example/testng/logback/step/pattern/Item.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 EPAM Systems 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.epam.reportportal.example.testng.logback.step.pattern; 18 | 19 | /** 20 | * @author Ivan Budayeu 21 | */ 22 | public class Item { 23 | private String name; 24 | 25 | public Item(String name) { 26 | this.name = name; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "Item"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example-testng-logback/src/main/java/com/epam/reportportal/example/testng/logback/util/AttachmentHelper.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.logback.util; 2 | 3 | import com.epam.reportportal.utils.files.ByteSource; 4 | import com.epam.reportportal.utils.files.Utils; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | 11 | /** 12 | * Utility file to copy / read resource files. 13 | */ 14 | public class AttachmentHelper { 15 | public static File getFileFromResources(String path, String name, String extension) { 16 | File file = null; 17 | try { 18 | file = File.createTempFile("rp-test", "." + extension); 19 | ByteSource source = Utils.getFileAsByteSource(new File(String.format("%s/%s.%s", path, name, extension))); 20 | try (InputStream is = source.openStream()) { 21 | try (OutputStream os = java.nio.file.Files.newOutputStream(file.toPath())) { 22 | Utils.copyStreams(is, os); 23 | } 24 | } 25 | } catch (IOException ignored) { 26 | } 27 | return file; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /example-testng-logback/src/main/java/com/epam/reportportal/example/testng/logback/util/LoggingUtils.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.logback.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.File; 7 | import java.util.Base64; 8 | 9 | /** 10 | * Useful utility class for binary data logging (e.g. sending files to ReportPortal). You can disable console output for 11 | * `binary_data_logger` to avoid redundant verbose output. 12 | */ 13 | public class LoggingUtils { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger("binary_data_logger"); 16 | 17 | private LoggingUtils() { 18 | //statics only 19 | } 20 | 21 | public static void log(File file, String message) { 22 | LOGGER.info("RP_MESSAGE#FILE#{}#{}", file.getAbsolutePath(), message); 23 | } 24 | 25 | public static void logBase64(String base64, String message) { 26 | LOGGER.info("RP_MESSAGE#BASE64#{}#{}", base64, message); 27 | } 28 | 29 | public static void log(byte[] bytes, String message) { 30 | logBase64(Base64.getEncoder().encodeToString(bytes), message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example-testng-logback/src/main/java/com/epam/reportportal/example/testng/logback/util/MagicRandomizer.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.example.testng.logback.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.util.Random; 7 | 8 | /** 9 | * Just a randomizer 10 | * 11 | * @author Andrei Varabyeu 12 | */ 13 | public class MagicRandomizer { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(MagicRandomizer.class); 16 | 17 | private static final Random RANDOM = new Random(); 18 | private static final int UPPER_LIMIT = 100; 19 | 20 | private MagicRandomizer() { 21 | //statics only 22 | } 23 | 24 | public static int luckyInt(int bound) { 25 | return RANDOM.nextInt(bound); 26 | } 27 | 28 | /** 29 | * Just put probability and check your luckiness 30 | * 31 | * @param probability value [0--100] 32 | * @return TRUE if you are really lucky! 33 | */ 34 | public static boolean checkYourLucky(int probability) { 35 | boolean lucky = luckyInt(UPPER_LIMIT + 1) <= probability; 36 | LOGGER.debug("Generating [TRUE/FALSE] with probability {}%. Result {}", probability, lucky); 37 | return lucky; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example-testng-logback/src/main/resources/META-INF/aop-ajc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /example-testng-logback/src/main/resources/META-INF/services/org.testng.ITestNGListener: -------------------------------------------------------------------------------- 1 | com.epam.reportportal.testng.ReportPortalTestNGListener 2 | -------------------------------------------------------------------------------- /example-testng-logback/src/main/resources/files/Test.cmd: -------------------------------------------------------------------------------- 1 | title Batch File Testing 2 | echo Hello World 3 | echo. 4 | echo Starting Notepad 5 | start notepad 6 | echo. 7 | echo Starting Wordpad 8 | start Wordpad 9 | echo. 10 | pause 11 | exit -------------------------------------------------------------------------------- /example-testng-logback/src/main/resources/files/Test.csv: -------------------------------------------------------------------------------- 1 | 1997,Ford,E350,"ac, abs, moon",3000.00 2 | 1999,Chevy,"Venture ""Extended Edition""","",4900.00 3 | 1996,Jeep,Grand Cherokee,"MUST SELL! air, moon roof, loaded",4799.00 -------------------------------------------------------------------------------- /example-testng-logback/src/main/resources/files/css.css: -------------------------------------------------------------------------------- 1 | p { 2 | font-family: arial, helvetica, sans-serif; 3 | } 4 | 5 | h2 { 6 | font-size: 20pt; 7 | color: red; 8 | background: white; 9 | } 10 | 11 | .note { 12 | color: red; 13 | background-color: yellow; 14 | font-weight: bold; 15 | } 16 | 17 | p#paragraph1 { 18 | padding-left: 10px; 19 | } 20 | 21 | a:hover { 22 | text-decoration: none; 23 | } 24 | 25 | #news p { 26 | color: blue; 27 | } 28 | 29 | [type="button"] { 30 | background-color: green; 31 | } -------------------------------------------------------------------------------- /example-testng-logback/src/main/resources/files/demo.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-logback/src/main/resources/files/demo.zip -------------------------------------------------------------------------------- /example-testng-logback/src/main/resources/files/har.har: -------------------------------------------------------------------------------- 1 | { 2 | "log": { 3 | "version": "1.2", 4 | "creator": { 5 | "name": "WebInspector", 6 | "version": "537.36" 7 | }, 8 | "pages": [ 9 | { 10 | "startedDateTime": "2017-12-13T11:21:18.288Z", 11 | "id": "page_2", 12 | "title": "http://localhost:8080/", 13 | "pageTimings": { 14 | "onContentLoad": 330.9420000005048, 15 | "onLoad": 464.73599999808357 16 | } 17 | } 18 | ] 19 | } 20 | } -------------------------------------------------------------------------------- /example-testng-logback/src/main/resources/files/php.php: -------------------------------------------------------------------------------- 1 | a = $a; 11 | $this->b = $b; 12 | } 13 | 14 | public function plus() 15 | { 16 | return $this->a + $this->b; 17 | } 18 | /* ............... */ 19 | } 20 | 21 | $d = new C1(1, 2); 22 | echo $d->plus(); // 3 23 | ?> -------------------------------------------------------------------------------- /example-testng-logback/src/main/resources/files/plain.txt: -------------------------------------------------------------------------------- 1 | Copyright 2020 EPAM Systems 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /example-testng-logback/src/main/resources/files/test.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-logback/src/main/resources/files/test.pdf -------------------------------------------------------------------------------- /example-testng-logback/src/main/resources/pug/lucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-logback/src/main/resources/pug/lucky.jpg -------------------------------------------------------------------------------- /example-testng-logback/src/main/resources/pug/unlucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/examples-java/26ef151fdd495eabd5a9631c8012c64b714b0a79/example-testng-logback/src/main/resources/pug/unlucky.jpg -------------------------------------------------------------------------------- /example-testng-logback/src/main/resources/reportportal.properties: -------------------------------------------------------------------------------- 1 | rp.endpoint=http://example.com 2 | rp.api.key=api-key 3 | rp.launch=launch-name 4 | rp.project=project-name 5 | rp.attributes=one;two; 6 | rp.reporting.async=true 7 | rp.reporting.callback=true 8 | -------------------------------------------------------------------------------- /example-testng-logback/src/main/resources/xml/file.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Here is some xml content 4 | 5 | -------------------------------------------------------------------------------- /example-testng-logback/suites/attribute.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example-testng-logback/suites/callback_suite.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example-testng-logback/suites/custom_annotations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /example-testng-logback/suites/issue27.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example-testng-logback/suites/logging_inner_tests.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example-testng-logback/suites/nested_steps_tests.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example-testng-logback/suites/parameterized_tests.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example-testng-logback/suites/preconditions_suite.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /example-testng-logback/suites/randomizer_suite.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.epam.reportportal 8 | examples-java 9 | 1.0-SNAPSHOT 10 | pom 11 | 12 | 13 | UTF-8 14 | ${project.build.sourceEncoding} 15 | ${project.build.sourceEncoding} 16 | 1.8 17 | ${maven.compiler.source} 18 | 19 | 20 | 21 | example-cucumber 22 | example-cucumber4 23 | example-cucumber6 24 | example-cucumber6-testng 25 | example-jbehave 26 | example-testng-logback 27 | example-testng-log4j 28 | example-junit5 29 | example-junit 30 | example-testng-fork-execution 31 | example-spock 32 | 33 | 34 | --------------------------------------------------------------------------------