├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── ci.yml │ ├── maven-publish.yml │ └── release.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── README_TEMPLATE.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── integration_manual_files ├── note_junit5_properties.png ├── step_add_project.png ├── step_add_project2.png ├── step_add_run_configuration.png ├── step_add_user.png ├── step_group_and_artifact_id.png ├── step_launches.png ├── step_new_maven_project.png ├── step_project_name.png ├── step_project_structure.png ├── step_test_results.png └── step_user_profile.png ├── settings.gradle └── src ├── main ├── java │ └── com │ │ └── epam │ │ └── reportportal │ │ └── junit5 │ │ ├── ItemType.java │ │ ├── ReportPortalExtension.java │ │ ├── SystemAttributesFetcher.java │ │ └── utils │ │ └── ItemTreeUtils.java └── resources │ ├── META-INF │ └── aop-ajc.xml │ └── agent.properties └── test ├── java └── com │ └── epam │ └── reportportal │ └── junit5 │ ├── AssumptionsTest.java │ ├── AttributesTest.java │ ├── BasicTest.java │ ├── BeforeAfterAllTest.java │ ├── CallbackReportingTest.java │ ├── CodeReferenceTest.java │ ├── DescriptionTest.java │ ├── DisabledTestTest.java │ ├── DisplayNameTest.java │ ├── ErrorLastLogTest.java │ ├── IssueReportingTest.java │ ├── JunitNestedTestTest.java │ ├── NestedStepTest.java │ ├── ParametersTest.java │ ├── StepReporterTest.java │ ├── SystemAttributesFetcherTest.java │ ├── TestCaseIdTest.java │ ├── TestInitTest.java │ ├── bugs │ ├── BeforeEachFailedDuplicationTest.java │ └── LaunchStartTimeTest.java │ ├── features │ ├── JUnit5Tests.java │ ├── TestFailure.java │ ├── attributes │ │ ├── ClassLevelAttributesTest.java │ │ └── MethodLevelAttributesTest.java │ ├── beforeafterall │ │ ├── AfterAllTest.java │ │ ├── BeforeAfterAllBeforeAfterEachTwoTestsTest.java │ │ ├── BeforeAfterAllFailedTest.java │ │ ├── BeforeAfterAllTest.java │ │ ├── BeforeAfterAllTwoTestsTest.java │ │ ├── BeforeAllAfterAllFailedTest.java │ │ ├── BeforeAllFailedTest.java │ │ ├── BeforeAllTest.java │ │ ├── FailedAfterEachTest.java │ │ ├── FailedConstructorTest.java │ │ └── NonStaticBeforeAfterAllTest.java │ ├── bug │ │ ├── BeforeEachFailedDuplicateTest.java │ │ └── TestIncorrectStartTime.java │ ├── callback │ │ ├── CallbackFeatureTest.java │ │ └── CallbackLogFeatureTest.java │ ├── coderef │ │ ├── SingleDynamicTest.java │ │ └── SingleTest.java │ ├── configname │ │ ├── ConfigurationMethodsDefaultDisplayNameTest.java │ │ ├── ConfigurationMethodsDisplayNameGeneratorTest.java │ │ ├── ConfigurationMethodsDisplayNameTest.java │ │ └── CustomDisplayNameGenerator.java │ ├── description │ │ ├── DescriptionAnnotatedClassDynamicTest.java │ │ ├── DescriptionAnnotatedClassTest.java │ │ ├── DescriptionAnnotatedMethodAndClassDynamicTest.java │ │ ├── DescriptionAnnotatedMethodAndClassTest.java │ │ ├── DescriptionAnnotatedMethodDynamicTest.java │ │ └── DescriptionAnnotatedMethodTest.java │ ├── disabled │ │ ├── OneDisabledOneEnabledTest.java │ │ ├── OneDisabledTest.java │ │ ├── OneDisabledWithReasonDescriptionTest.java │ │ └── OneDisabledWithReasonTest.java │ ├── displayname │ │ ├── DisplayNameAnnotatedClassDynamicTest.java │ │ ├── DisplayNameAnnotatedClassTest.java │ │ ├── DisplayNameAnnotatedClassWithEmptyValueTest.java │ │ ├── DisplayNameAnnotatedMethodAndClassDynamicTest.java │ │ ├── DisplayNameAnnotatedMethodAndClassTest.java │ │ ├── DisplayNameAnnotatedMethodDynamicTest.java │ │ ├── DisplayNameAnnotatedMethodTest.java │ │ ├── DisplayNameAnnotatedMethodWithEmptyValueTest.java │ │ ├── DisplayNameBothJunitAndRPAnnotatedClassDynamicTest.java │ │ ├── DisplayNameBothJunitAndRPAnnotatedClassTest.java │ │ ├── DisplayNameBothJunitAndRPAnnotatedMethodAndClassDynamicTest.java │ │ ├── DisplayNameBothJunitAndRPAnnotatedMethodAndClassTest.java │ │ ├── DisplayNameBothJunitAndRPAnnotatedMethodDynamicTest.java │ │ └── DisplayNameBothJunitAndRPAnnotatedMethodTest.java │ ├── issue │ │ ├── DynamicIssueTest.java │ │ ├── ParameterizedWithOneIssueTest.java │ │ ├── ParameterizedWithTwoIssueTest.java │ │ ├── SimpleIssueTest.java │ │ ├── SimpleSkippedIssueTest.java │ │ ├── SimpleTwoIssuesTest.java │ │ ├── TwoDynamicIssueTest.java │ │ └── TwoDynamicTwoIssueTest.java │ ├── lasterrorlog │ │ ├── ErrorLastLogFeatureWithAssertionErrorTest.java │ │ ├── ErrorLastLogFeatureWithAssertionPassedTest.java │ │ ├── ErrorLastLogFeatureWithExceptionTest.java │ │ └── ErrorLastLogFeatureWithStepTest.java │ ├── nested │ │ ├── JunitClassNestedTests.java │ │ ├── JunitClassNestedTestsLongDepth.java │ │ ├── JunitDynamicNestedTest.java │ │ ├── NestedStepFeatureFailedTest.java │ │ ├── NestedStepFeaturePassedTest.java │ │ ├── NestedStepMultiLevelTest.java │ │ └── NestedStepWithBeforeEachTest.java │ ├── parameters │ │ ├── CsvParametersTest.java │ │ ├── EnumParametersFailedTest.java │ │ ├── EnumParametersTest.java │ │ ├── NullParameterTest.java │ │ ├── ParameterNamesNotAllNamedTest.java │ │ ├── ParameterNamesTest.java │ │ └── TwoParametersTest.java │ ├── skipped │ │ ├── AfterEachFailedTest.java │ │ ├── AssertJAssumptionFailedTest.java │ │ ├── AssumptionFailedTest.java │ │ ├── BeforeEachAssumptionFailedTest.java │ │ ├── BeforeEachFailedParametrizedTest.java │ │ ├── BeforeEachFailedTest.java │ │ ├── BeforeEachFailedWithAfterEachTest.java │ │ ├── Junit4AssumptionFailedTest.java │ │ └── Junit4ExtendedAssumptionFailedTest.java │ ├── step │ │ ├── ManualStepReporterFeatureTest.java │ │ └── ManualStepReporterSimpleTest.java │ └── testcaseid │ │ ├── SingleDynamicAnnotatedTest.java │ │ ├── SingleDynamicTest.java │ │ ├── TestCaseIdFromAnnotationTest.java │ │ ├── TestCaseIdFromCodeRefAndParamsTest.java │ │ ├── TestCaseIdFromCodeRefTest.java │ │ ├── TestCaseIdFromParametrizedAnnotationTest.java │ │ └── TestCaseIdTemplateTest.java │ ├── miscellaneous │ ├── DisplayNamesForConfigurationItemsTest.java │ ├── FailedBeforeEachReportsSkippedTestTest.java │ └── FailedBeforeEachSkippedTestOrderTest.java │ ├── util │ ├── TestUtils.java │ └── Verifications.java │ └── utils │ └── ItemTreeUtilsTest.java └── resources ├── META-INF └── aop-ajc.xml ├── agent.properties ├── files └── css.css ├── logback-test.xml └── pug └── unlucky.jpg /.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-java-junit5 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 2022 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 | # https://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 | - '!master' 21 | - '!v4-hotfix' 22 | paths-ignore: 23 | - README.md 24 | - README_TEMPLATE.md 25 | - CHANGELOG.md 26 | 27 | pull_request: 28 | branches: 29 | - master 30 | - v4-hotfix 31 | 32 | jobs: 33 | build: 34 | runs-on: ubuntu-latest 35 | 36 | steps: 37 | - name: Checkout repository 38 | uses: actions/checkout@v4 39 | 40 | - name: Set up JDK 11 41 | uses: actions/setup-java@v4 42 | with: 43 | distribution: 'temurin' 44 | java-version: '11' 45 | 46 | - name: Build with Gradle 47 | run: ./gradlew build 48 | 49 | - name: Codecov upload 50 | uses: codecov/codecov-action@v4 51 | with: 52 | token: ${{ secrets.CODECOV_TOKEN }} 53 | -------------------------------------------------------------------------------- /.github/workflows/maven-publish.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2025 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: Publish to Maven Central 15 | 16 | on: 17 | workflow_dispatch: 18 | inputs: 19 | version: 20 | description: 'Release version (e.g., 5.3.14)' 21 | required: true 22 | type: string 23 | 24 | jobs: 25 | publish: 26 | uses: reportportal/.github/.github/workflows/maven-publish.yml@main 27 | with: 28 | version: ${{ github.event.inputs.version }} 29 | artifact: agent-java-junit5 30 | package_suffixes: '-javadoc.jar,-javadoc.jar.asc,-javadoc.jar.md5,-javadoc.jar.sha1,-javadoc.jar.sha256,-javadoc.jar.sha512,-sources.jar,-sources.jar.asc,-sources.jar.md5,-sources.jar.sha1,-sources.jar.sha256,-sources.jar.sha512,.jar,.jar.asc,.jar.md5,.jar.sha1,.jar.sha256,.jar.sha512,.pom,.pom.asc,.pom.md5,.pom.sha1,.pom.sha256,.pom.sha512,.module,.module.asc,.module.md5,.module.sha1,.module.sha256,.module.sha512' 31 | secrets: 32 | SONATYPE_USER: ${{ secrets.SONATYPE_USER }} 33 | SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} 34 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2022 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 | # https://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: Release 15 | 16 | on: 17 | push: 18 | branches: 19 | - master 20 | - v4-hotfix 21 | 22 | paths-ignore: 23 | - '.github/**' 24 | - README.md 25 | - README_TEMPLATE.md 26 | - CHANGELOG.md 27 | 28 | env: 29 | VERSION_FILE: gradle.properties 30 | VERSION_EXTRACT_PATTERN: '(?<=version=).+' 31 | CHANGE_LOG_FILE: CHANGELOG.md 32 | CHANGE_LOG_TMP_FILE: CHANGELOG_updated.md 33 | REPOSITORY_URL: 'https://maven.pkg.github.com/' 34 | README_FILE: README.md 35 | README_TEMPLATE_FILE: README_TEMPLATE.md 36 | README_VERSION_PLACEHOLDER: $LATEST_VERSION 37 | 38 | jobs: 39 | release: 40 | runs-on: ubuntu-latest 41 | steps: 42 | - name: Checkout repository 43 | uses: actions/checkout@v4 44 | 45 | - name: Generate versions 46 | uses: HardNorth/github-version-generate@v1 47 | with: 48 | version-source: file 49 | version-file: ${{ env.VERSION_FILE }} 50 | version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }} 51 | 52 | - name: Set up JDK 11 53 | uses: actions/setup-java@v4 54 | with: 55 | distribution: 'temurin' 56 | java-version: '11' 57 | 58 | - name: Setup git credentials 59 | uses: oleksiyrudenko/gha-git-credentials@v2-latest 60 | with: 61 | name: 'reportportal.io' 62 | email: 'support@reportportal.io' 63 | token: ${{ secrets.GITHUB_TOKEN }} 64 | 65 | - name: Release with Gradle 66 | id: release 67 | run: | 68 | ./gradlew release -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${{ env.RELEASE_VERSION }} \ 69 | -Prelease.newVersion=${{ env.NEXT_VERSION }} -PpublishRepo=${{ env.REPOSITORY_URL }}${{ github.repository }} \ 70 | -PgithubUserName=${{ github.actor }} -PgithubToken=${{ secrets.GITHUB_TOKEN }} \ 71 | -PgpgPassphrase=${{ secrets.GPG_PASSPHRASE }} -PgpgPrivateKey="${{ secrets.GPG_PRIVATE_KEY }}" 72 | 73 | - name: Update README.md 74 | id: readmeUpdate 75 | run: | 76 | sed 's/${{ env.README_VERSION_PLACEHOLDER }}/${{ env.RELEASE_VERSION }}/g' ${{ env.README_TEMPLATE_FILE }} > ${{ env.README_FILE }} 77 | git add ${{ env.README_FILE }} 78 | git commit -m "Readme update" 79 | 80 | - name: Update CHANGELOG.md 81 | id: changelogUpdate 82 | run: | 83 | sed '/\[Unreleased\]/q' ${{ env.CHANGE_LOG_FILE }} >> ${{ env.CHANGE_LOG_TMP_FILE }} 84 | sed -E '1,/#?#\s*\[Unreleased\]/d' ${{ env.CHANGE_LOG_FILE }} | sed -E '/#?#\s*\[/q' | \ 85 | { echo -e '\n## [${{env.RELEASE_VERSION}}]'; sed '$d'; } >> ${{ env.CHANGE_LOG_TMP_FILE }} 86 | grep -E '#?#\s*\[[0-9]' ${{ env.CHANGE_LOG_FILE }} | head -n1 >> ${{ env.CHANGE_LOG_TMP_FILE }} 87 | sed -E '1,/#?#\s*\[[0-9]/d' ${{ env.CHANGE_LOG_FILE }} >> ${{ env.CHANGE_LOG_TMP_FILE }} 88 | rm ${{ env.CHANGE_LOG_FILE }} 89 | mv ${{ env.CHANGE_LOG_TMP_FILE }} ${{ env.CHANGE_LOG_FILE }} 90 | git add ${{ env.CHANGE_LOG_FILE }} 91 | git commit -m "Changelog update" 92 | git push 93 | 94 | - name: Read changelog Entry 95 | id: readChangelogEntry 96 | uses: mindsers/changelog-reader-action@v2 97 | with: 98 | version: ${{ env.RELEASE_VERSION }} 99 | path: ./${{ env.CHANGE_LOG_FILE }} 100 | 101 | - name: Create Release 102 | id: createRelease 103 | uses: ncipollo/release-action@v1 104 | with: 105 | tag: ${{ env.RELEASE_VERSION }} 106 | name: Release ${{ env.RELEASE_VERSION }} 107 | body: ${{ steps.readChangelogEntry.outputs.changes }} 108 | 109 | - name: Checkout develop branch 110 | uses: actions/checkout@v4 111 | with: 112 | ref: 'develop' 113 | fetch-depth: 0 114 | 115 | - name: Merge release branch into develop 116 | id: mergeIntoDevelop 117 | run: | 118 | git merge -m 'Merge master branch into develop after a release' origin/master 119 | git status | (! grep -Fq 'both modified:') || git status | grep -F 'both modified:' \ 120 | | { echo -e 'Unable to merge master into develop, merge conflicts:'; (! grep -Eo '[^ ]+$') } 121 | git push origin develop 122 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | !gradle/wrapper/** 9 | *.war 10 | *.ear 11 | 12 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 13 | hs_err_pid* 14 | 15 | .DS_Store 16 | 17 | .gradle/ 18 | build/ 19 | .idea/ 20 | .classpath 21 | .project 22 | .settings 23 | *.iml 24 | /bin/ 25 | /out 26 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 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 | apply plugin: 'java-library' 17 | 18 | apply from: "${project.scripts_url}/${project.scripts_branch}/build-quality.gradle" 19 | apply from: "${project.scripts_url}/${project.scripts_branch}/release-commons.gradle" 20 | apply from: "${project.scripts_url}/${project.scripts_branch}/signing.gradle" 21 | apply from: "${project.scripts_url}/${project.scripts_branch}/jacoco.gradle" 22 | 23 | project.ext.limits = [ 24 | 'instruction': 70, 25 | 'branch' : 53, 26 | 'line' : 75, 27 | 'complexity' : 60, 28 | 'method' : 65, 29 | 'class' : 87 30 | ] 31 | 32 | sourceCompatibility = JavaVersion.VERSION_11 33 | targetCompatibility = JavaVersion.VERSION_11 34 | 35 | repositories { 36 | mavenCentral() 37 | } 38 | 39 | dependencies { 40 | api 'com.epam.reportportal:client-java:5.4.3' 41 | 42 | compileOnly "org.junit.jupiter:junit-jupiter-api:${junit_version}" 43 | implementation 'org.slf4j:slf4j-api:2.0.7' 44 | implementation 'org.apache.commons:commons-lang3:3.19.0' 45 | 46 | testImplementation 'com.epam.reportportal:agent-java-test-utils:0.1.0' 47 | testImplementation "org.junit.platform:junit-platform-runner:${junit_runner_version}" // We need runner for JUnit 4 compatibility tests 48 | testImplementation "org.junit.jupiter:junit-jupiter-engine:${junit_version}" // Required for tests to run 49 | testImplementation "org.junit.jupiter:junit-jupiter-params:${junit_version}" 50 | testImplementation 'org.aspectj:aspectjweaver:1.9.19' 51 | testImplementation 'org.hamcrest:hamcrest:2.2' 52 | testImplementation 'org.mockito:mockito-core:3.3.3' 53 | testImplementation 'ch.qos.logback:logback-classic:1.5.18' 54 | testImplementation 'com.epam.reportportal:logger-java-logback:5.4.0' 55 | testImplementation 'org.assertj:assertj-core:3.23.1' 56 | testImplementation 'com.squareup.okhttp3:okhttp:4.12.0' 57 | } 58 | 59 | test { 60 | outputs.upToDateWhen { return false } 61 | useJUnitPlatform() 62 | exclude("com/epam/reportportal/junit5/features/**") 63 | maxParallelForks(5) // it's forks - separate JVMs, should not interfere each other 64 | forkEvery(1) 65 | doFirst { 66 | def weaver = configurations.testRuntimeClasspath.find { it.name.contains("aspectjweaver") } 67 | jvmArgs += "-javaagent:$weaver" 68 | } 69 | environment "AGENT_NO_ANALYTICS", "1" 70 | testLogging { 71 | events "failed" 72 | exceptionFormat "full" 73 | } 74 | } 75 | 76 | wrapper { 77 | gradleVersion = '5.4.1' 78 | } 79 | 80 | processResources { 81 | filesMatching('agent.properties') { 82 | expand(project.properties) 83 | } 84 | } 85 | 86 | release { 87 | git { 88 | requireBranch = 'master' 89 | } 90 | } 91 | 92 | build.dependsOn jacocoTestReport 93 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | version=5.5.3-SNAPSHOT 2 | description=JUnit5 integration for ReportPortal 3 | junit_version=5.9.3 4 | # We need runner for JUnit 4 compatibility tests 5 | junit_runner_version=1.9.3 6 | scripts_url=https://raw.githubusercontent.com/reportportal/gradle-scripts 7 | scripts_branch=master 8 | excludeTests= 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/agent-java-junit5/8bb8181518a0894ed700bccd4c49c5602e55d944/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin, switch paths to Windows format before running java 129 | if $cygwin ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=$((i+1)) 158 | done 159 | case $i in 160 | (0) set -- ;; 161 | (1) set -- "$args0" ;; 162 | (2) set -- "$args0" "$args1" ;; 163 | (3) set -- "$args0" "$args1" "$args2" ;; 164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=$(save "$@") 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 185 | cd "$(dirname "$0")" 186 | fi 187 | 188 | exec "$JAVACMD" "$@" 189 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem http://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /integration_manual_files/note_junit5_properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/agent-java-junit5/8bb8181518a0894ed700bccd4c49c5602e55d944/integration_manual_files/note_junit5_properties.png -------------------------------------------------------------------------------- /integration_manual_files/step_add_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/agent-java-junit5/8bb8181518a0894ed700bccd4c49c5602e55d944/integration_manual_files/step_add_project.png -------------------------------------------------------------------------------- /integration_manual_files/step_add_project2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/agent-java-junit5/8bb8181518a0894ed700bccd4c49c5602e55d944/integration_manual_files/step_add_project2.png -------------------------------------------------------------------------------- /integration_manual_files/step_add_run_configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/agent-java-junit5/8bb8181518a0894ed700bccd4c49c5602e55d944/integration_manual_files/step_add_run_configuration.png -------------------------------------------------------------------------------- /integration_manual_files/step_add_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/agent-java-junit5/8bb8181518a0894ed700bccd4c49c5602e55d944/integration_manual_files/step_add_user.png -------------------------------------------------------------------------------- /integration_manual_files/step_group_and_artifact_id.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/agent-java-junit5/8bb8181518a0894ed700bccd4c49c5602e55d944/integration_manual_files/step_group_and_artifact_id.png -------------------------------------------------------------------------------- /integration_manual_files/step_launches.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/agent-java-junit5/8bb8181518a0894ed700bccd4c49c5602e55d944/integration_manual_files/step_launches.png -------------------------------------------------------------------------------- /integration_manual_files/step_new_maven_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/agent-java-junit5/8bb8181518a0894ed700bccd4c49c5602e55d944/integration_manual_files/step_new_maven_project.png -------------------------------------------------------------------------------- /integration_manual_files/step_project_name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/agent-java-junit5/8bb8181518a0894ed700bccd4c49c5602e55d944/integration_manual_files/step_project_name.png -------------------------------------------------------------------------------- /integration_manual_files/step_project_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/agent-java-junit5/8bb8181518a0894ed700bccd4c49c5602e55d944/integration_manual_files/step_project_structure.png -------------------------------------------------------------------------------- /integration_manual_files/step_test_results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/agent-java-junit5/8bb8181518a0894ed700bccd4c49c5602e55d944/integration_manual_files/step_test_results.png -------------------------------------------------------------------------------- /integration_manual_files/step_user_profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/agent-java-junit5/8bb8181518a0894ed700bccd4c49c5602e55d944/integration_manual_files/step_user_profile.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'agent-java-junit5' 2 | -------------------------------------------------------------------------------- /src/main/java/com/epam/reportportal/junit5/ItemType.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2019 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.junit5; 19 | 20 | /** 21 | * JUnit 5's item types set 22 | */ 23 | public enum ItemType { 24 | BEFORE_CLASS, 25 | BEFORE_METHOD, 26 | AFTER_CLASS, 27 | AFTER_METHOD, 28 | TEMPLATE, 29 | SUITE, 30 | STEP 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/epam/reportportal/junit5/SystemAttributesFetcher.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2019 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.junit5; 19 | 20 | import com.epam.reportportal.utils.properties.SystemAttributesExtractor; 21 | import com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ; 22 | 23 | import java.util.Set; 24 | 25 | /** 26 | * Util class that retrieves useful info about agent environment and composes it in Report Portal system attributes 27 | */ 28 | public class SystemAttributesFetcher { 29 | 30 | private static final String SKIPPED_ISSUE_KEY = "skippedIssue"; 31 | private static final String AGENT_PROPERTIES = "agent.properties"; 32 | 33 | private static ItemAttributesRQ skippedAnIssue(Boolean fromParams) { 34 | ItemAttributesRQ skippedIssueAttr = new ItemAttributesRQ(); 35 | skippedIssueAttr.setKey(SKIPPED_ISSUE_KEY); 36 | skippedIssueAttr.setValue(fromParams == null ? "true" : fromParams.toString()); 37 | skippedIssueAttr.setSystem(true); 38 | return skippedIssueAttr; 39 | } 40 | 41 | static Set collectSystemAttributes(Boolean skippedAnIssue) { 42 | Set systemAttributes = SystemAttributesExtractor.extract(AGENT_PROPERTIES, SystemAttributesFetcher.class.getClassLoader()); 43 | systemAttributes.add(skippedAnIssue(skippedAnIssue)); 44 | return systemAttributes; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/epam/reportportal/junit5/utils/ItemTreeUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 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.junit5.utils; 18 | 19 | import com.epam.reportportal.service.tree.TestItemTree; 20 | import io.reactivex.annotations.Nullable; 21 | import org.junit.jupiter.api.TestInfo; 22 | import org.junit.jupiter.api.extension.ExtensionContext; 23 | 24 | /** 25 | * Util class for creating {@link com.epam.reportportal.service.tree.TestItemTree.ItemTreeKey} objects from JUnit5 test-related entities. 26 | * {@link com.epam.reportportal.service.tree.TestItemTree.ItemTreeKey} is required for accessing {@link TestItemTree} entries which 27 | * are used in {@link com.epam.reportportal.service.tree.ItemTreeReporter} that provides possibility to send requests to the Report Portal 28 | * instance right from the end-user code 29 | * 30 | * @author Ivan Budayeu 31 | */ 32 | public class ItemTreeUtils { 33 | 34 | private ItemTreeUtils() { 35 | //static only 36 | } 37 | 38 | public static TestItemTree.ItemTreeKey createItemTreeKey(String name) { 39 | return TestItemTree.ItemTreeKey.of(name); 40 | } 41 | 42 | public static TestItemTree.ItemTreeKey createItemTreeKey(String name, int hash) { 43 | return TestItemTree.ItemTreeKey.of(name, hash); 44 | } 45 | 46 | public static TestItemTree.ItemTreeKey createItemTreeKey(TestInfo testInfo) { 47 | return TestItemTree.ItemTreeKey.of(testInfo.getDisplayName()); 48 | } 49 | 50 | public static TestItemTree.ItemTreeKey createItemTreeKey(TestInfo testInfo, int hash) { 51 | return TestItemTree.ItemTreeKey.of(testInfo.getDisplayName(), hash); 52 | } 53 | 54 | public static TestItemTree.ItemTreeKey createItemTreeKey(ExtensionContext extensionContext) { 55 | return TestItemTree.ItemTreeKey.of(extensionContext.getDisplayName()); 56 | } 57 | 58 | public static TestItemTree.ItemTreeKey createItemTreeKey(ExtensionContext extensionContext, int hash) { 59 | return TestItemTree.ItemTreeKey.of(extensionContext.getDisplayName(), hash); 60 | } 61 | 62 | @Nullable 63 | public static TestItemTree.TestItemLeaf retrieveLeaf(String name, TestItemTree testItemTree) { 64 | return testItemTree.getTestItems().get(createItemTreeKey(name)); 65 | } 66 | 67 | @Nullable 68 | public static TestItemTree.TestItemLeaf retrieveLeaf(TestInfo testInfo, TestItemTree testItemTree) { 69 | return retrieveLeaf(testInfo.getDisplayName(), testItemTree); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/aop-ajc.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/resources/agent.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019 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 | agent.name=${name} 17 | agent.version=${version} 18 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/AssumptionsTest.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.junit5; 18 | 19 | import com.epam.reportportal.junit5.features.skipped.*; 20 | import com.epam.reportportal.junit5.util.TestUtils; 21 | import com.epam.reportportal.listeners.ItemStatus; 22 | import com.epam.reportportal.service.Launch; 23 | import com.epam.reportportal.service.step.StepReporter; 24 | import com.epam.reportportal.util.test.CommonUtils; 25 | import com.epam.ta.reportportal.ws.model.FinishTestItemRQ; 26 | import com.epam.ta.reportportal.ws.model.StartTestItemRQ; 27 | import io.reactivex.Maybe; 28 | import org.junit.jupiter.api.BeforeEach; 29 | import org.junit.jupiter.api.Test; 30 | import org.junit.jupiter.api.TestInstance; 31 | import org.junit.jupiter.api.extension.ExtensionContext; 32 | import org.junit.jupiter.params.ParameterizedTest; 33 | import org.junit.jupiter.params.provider.ValueSource; 34 | import org.mockito.ArgumentCaptor; 35 | import org.mockito.stubbing.Answer; 36 | 37 | import java.util.List; 38 | 39 | import static org.hamcrest.MatcherAssert.assertThat; 40 | import static org.hamcrest.Matchers.equalTo; 41 | import static org.hamcrest.Matchers.nullValue; 42 | import static org.mockito.ArgumentMatchers.any; 43 | import static org.mockito.ArgumentMatchers.notNull; 44 | import static org.mockito.Mockito.*; 45 | 46 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 47 | public class AssumptionsTest { 48 | 49 | public static class AssumptionsTestExtension extends ReportPortalExtension { 50 | static Launch LAUNCH; 51 | 52 | @Override 53 | protected Launch getLaunch(ExtensionContext context) { 54 | return LAUNCH; 55 | } 56 | } 57 | 58 | @BeforeEach 59 | public void setupMock() { 60 | AssumptionsTestExtension.LAUNCH = mock(Launch.class); 61 | Launch launch = AssumptionsTestExtension.LAUNCH; 62 | when(launch.getStepReporter()).thenReturn(StepReporter.NOOP_STEP_REPORTER); 63 | when(launch.startTestItem(any())).thenAnswer((Answer>) invocation -> CommonUtils.createMaybeUuid()); 64 | when(launch.startTestItem(any(), any())).thenAnswer((Answer>) invocation -> CommonUtils.createMaybeUuid()); 65 | } 66 | 67 | @ParameterizedTest 68 | @ValueSource(classes = { AssumptionFailedTest.class, Junit4AssumptionFailedTest.class, AssertJAssumptionFailedTest.class, 69 | Junit4ExtendedAssumptionFailedTest.class }) 70 | public void verify_assumption_failure_marks_test_as_skipped(Class testClass) { 71 | TestUtils.runClasses(testClass); 72 | 73 | Launch launch = AssumptionsTestExtension.LAUNCH; 74 | 75 | verify(launch).startTestItem(any(StartTestItemRQ.class)); // Start parent Suite 76 | verify(launch, times(1)).startTestItem(notNull(), any(StartTestItemRQ.class)); // Start a test 77 | 78 | ArgumentCaptor finishCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class); 79 | verify(launch, times(2)).finishTestItem(any(), finishCaptor.capture()); 80 | List finishItems = finishCaptor.getAllValues(); 81 | assertThat(finishItems.get(0).getStatus(), equalTo(ItemStatus.SKIPPED.name())); 82 | assertThat(finishItems.get(1).getStatus(), nullValue()); 83 | } 84 | 85 | @Test 86 | public void verify_before_each_assumption_failure_marks_test_as_skipped() { 87 | TestUtils.runClasses(BeforeEachAssumptionFailedTest.class); 88 | 89 | Launch launch = AssumptionsTestExtension.LAUNCH; 90 | 91 | verify(launch).startTestItem(any(StartTestItemRQ.class)); // Start parent Suite 92 | verify(launch, times(2)).startTestItem(notNull(), any(StartTestItemRQ.class)); // Start a test 93 | 94 | ArgumentCaptor finishCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class); 95 | verify(launch, times(3)).finishTestItem(any(), finishCaptor.capture()); 96 | List finishItems = finishCaptor.getAllValues(); 97 | assertThat(finishItems.get(0).getStatus(), equalTo(ItemStatus.SKIPPED.name())); 98 | assertThat(finishItems.get(1).getStatus(), equalTo(ItemStatus.SKIPPED.name())); 99 | assertThat(finishItems.get(2).getStatus(), nullValue()); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/AttributesTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5; 2 | 3 | import com.epam.reportportal.junit5.features.attributes.ClassLevelAttributesTest; 4 | import com.epam.reportportal.junit5.features.attributes.MethodLevelAttributesTest; 5 | import com.epam.reportportal.junit5.util.TestUtils; 6 | import com.epam.reportportal.service.Launch; 7 | import com.epam.reportportal.util.test.CommonUtils; 8 | import com.epam.ta.reportportal.ws.model.OperationCompletionRS; 9 | import com.epam.ta.reportportal.ws.model.StartTestItemRQ; 10 | import com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ; 11 | import io.reactivex.Maybe; 12 | import org.junit.jupiter.api.BeforeEach; 13 | import org.junit.jupiter.api.Test; 14 | import org.junit.jupiter.api.TestInstance; 15 | import org.junit.jupiter.api.extension.ExtensionContext; 16 | import org.mockito.ArgumentCaptor; 17 | import org.mockito.stubbing.Answer; 18 | 19 | import static com.epam.reportportal.junit5.util.TestUtils.extractRequest; 20 | import static org.hamcrest.MatcherAssert.assertThat; 21 | import static org.hamcrest.Matchers.*; 22 | import static org.mockito.ArgumentMatchers.any; 23 | import static org.mockito.Mockito.*; 24 | 25 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 26 | public class AttributesTest { 27 | 28 | public static class AttributesTestExtension extends ReportPortalExtension { 29 | static Launch LAUNCH; 30 | 31 | @Override 32 | protected Launch getLaunch(ExtensionContext context) { 33 | return LAUNCH; 34 | } 35 | } 36 | 37 | @BeforeEach 38 | public void setupMock() { 39 | AttributesTestExtension.LAUNCH = mock(Launch.class); 40 | when(AttributesTestExtension.LAUNCH.startTestItem(any())).thenAnswer((Answer>) invocation -> CommonUtils.createMaybeUuid()); 41 | when(AttributesTestExtension.LAUNCH.startTestItem( 42 | any(), 43 | any() 44 | )).thenAnswer((Answer>) invocation -> CommonUtils.createMaybeUuid()); 45 | when(AttributesTestExtension.LAUNCH.finishTestItem(any(), any())).thenAnswer(invocation -> Maybe.just(new OperationCompletionRS())); 46 | } 47 | 48 | @Test 49 | public void verify_class_level_attributes() { 50 | TestUtils.runClasses(ClassLevelAttributesTest.class); 51 | 52 | Launch launch = AttributesTestExtension.LAUNCH; 53 | 54 | ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); 55 | verify(launch).startTestItem(captor.capture()); // Start test 56 | verify(launch).startTestItem(any(), captor.capture()); // Start step 57 | 58 | StartTestItemRQ testRequest = extractRequest(captor, "suite"); 59 | 60 | assertThat(testRequest.getAttributes(), hasSize(1)); 61 | ItemAttributesRQ attribute = testRequest.getAttributes().iterator().next(); 62 | assertThat(attribute.getKey(), equalTo(ClassLevelAttributesTest.KEY)); 63 | assertThat(attribute.getValue(), equalTo(ClassLevelAttributesTest.VALUE)); 64 | 65 | StartTestItemRQ stepRequest = extractRequest(captor, "step"); 66 | assertThat(stepRequest.getAttributes(), anyOf(nullValue(), emptyIterable())); 67 | } 68 | 69 | @Test 70 | public void verify_method_level_attributes() { 71 | TestUtils.runClasses(MethodLevelAttributesTest.class); 72 | 73 | Launch launch = AttributesTestExtension.LAUNCH; 74 | 75 | ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); 76 | verify(launch).startTestItem(captor.capture()); // Start test 77 | verify(launch).startTestItem(any(), captor.capture()); // Start step 78 | 79 | StartTestItemRQ testRequest = extractRequest(captor, "suite"); 80 | assertThat(testRequest.getAttributes(), anyOf(nullValue(), emptyIterable())); 81 | 82 | StartTestItemRQ stepRequest = extractRequest(captor, "step"); 83 | assertThat(stepRequest.getAttributes(), hasSize(1)); 84 | ItemAttributesRQ attribute = stepRequest.getAttributes().iterator().next(); 85 | assertThat(attribute.getKey(), equalTo("myKey")); 86 | assertThat(attribute.getValue(), equalTo("myValue")); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/BasicTest.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.junit5; 18 | 19 | import com.epam.reportportal.junit5.features.TestFailure; 20 | import com.epam.reportportal.junit5.util.TestUtils; 21 | import com.epam.reportportal.listeners.ItemStatus; 22 | import com.epam.reportportal.service.Launch; 23 | import com.epam.reportportal.service.ReportPortal; 24 | import com.epam.reportportal.service.ReportPortalClient; 25 | import com.epam.ta.reportportal.ws.model.FinishTestItemRQ; 26 | import com.epam.ta.reportportal.ws.model.StartTestItemRQ; 27 | import com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ; 28 | import org.hamcrest.Matchers; 29 | import org.junit.jupiter.api.Test; 30 | import org.junit.jupiter.api.TestInstance; 31 | import org.junit.jupiter.api.extension.ExtensionContext; 32 | import org.junit.platform.engine.TestExecutionResult; 33 | import org.junit.platform.launcher.TestExecutionListener; 34 | import org.junit.platform.launcher.TestIdentifier; 35 | import org.mockito.ArgumentCaptor; 36 | 37 | import java.util.Deque; 38 | import java.util.List; 39 | import java.util.concurrent.ConcurrentLinkedDeque; 40 | 41 | import static com.epam.reportportal.util.test.CommonUtils.namedId; 42 | import static org.hamcrest.MatcherAssert.assertThat; 43 | import static org.hamcrest.Matchers.*; 44 | import static org.mockito.Mockito.*; 45 | 46 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 47 | public class BasicTest { 48 | 49 | public static class BasicTestExtension extends ReportPortalExtension { 50 | static final String testClassUuid = namedId("class"); 51 | static final String testMethodUuid = namedId("test"); 52 | 53 | static final ThreadLocal client = new ThreadLocal<>(); 54 | static final ThreadLocal launch = new ThreadLocal<>(); 55 | 56 | public static void init() { 57 | client.set(mock(ReportPortalClient.class)); 58 | TestUtils.mockLaunch(client.get(), "launchUuid", testClassUuid, testMethodUuid); 59 | TestUtils.mockLogging(client.get()); 60 | ReportPortal reportPortal = ReportPortal.create(client.get(), TestUtils.standardParameters()); 61 | launch.set(reportPortal.newLaunch(TestUtils.launchRQ(reportPortal.getParameters()))); 62 | } 63 | 64 | @Override 65 | protected Launch getLaunch(ExtensionContext context) { 66 | return launch.get(); 67 | } 68 | } 69 | 70 | public static class Listener implements TestExecutionListener { 71 | public Deque results = new ConcurrentLinkedDeque<>(); 72 | 73 | @Override 74 | public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) { 75 | if (testIdentifier.isTest()) { 76 | results.add(testExecutionResult); 77 | } 78 | } 79 | } 80 | 81 | @Test 82 | public void verify_test_failure_report() { 83 | BasicTestExtension.init(); 84 | Listener listener = new Listener(); 85 | TestUtils.runClasses(listener, TestFailure.class); 86 | 87 | ReportPortalClient client = BasicTestExtension.client.get(); 88 | ArgumentCaptor launchCaptor = ArgumentCaptor.forClass(StartLaunchRQ.class); 89 | verify(client, timeout(1000)).startLaunch(launchCaptor.capture()); 90 | 91 | ArgumentCaptor suiteCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); 92 | verify(client, timeout(1000)).startTestItem(suiteCaptor.capture()); 93 | 94 | ArgumentCaptor testCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); 95 | verify(client, timeout(1000)).startTestItem(anyString(), testCaptor.capture()); 96 | 97 | ArgumentCaptor testFinishCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class); 98 | verify(client, timeout(1000).times(2)).finishTestItem(anyString(), testFinishCaptor.capture()); 99 | 100 | assertThat(listener.results.remove().getStatus(), sameInstance(TestExecutionResult.Status.FAILED)); 101 | 102 | StartLaunchRQ launchStart = launchCaptor.getValue(); 103 | assertThat(launchStart.getName(), allOf(notNullValue(), Matchers.startsWith("My-test-launch-"))); 104 | 105 | List itemFinish = testFinishCaptor.getAllValues(); 106 | assertThat(itemFinish.get(0).getStatus(), equalTo(ItemStatus.FAILED.name())); 107 | assertThat(itemFinish.get(1).getStatus(), nullValue()); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/CodeReferenceTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5; 2 | 3 | import com.epam.reportportal.junit5.features.coderef.SingleDynamicTest; 4 | import com.epam.reportportal.junit5.features.coderef.SingleTest; 5 | import com.epam.reportportal.junit5.util.TestUtils; 6 | import com.epam.reportportal.service.Launch; 7 | import com.epam.reportportal.util.test.CommonUtils; 8 | import com.epam.ta.reportportal.ws.model.StartTestItemRQ; 9 | import io.reactivex.Maybe; 10 | import org.junit.jupiter.api.BeforeEach; 11 | import org.junit.jupiter.api.Test; 12 | import org.junit.jupiter.api.TestInstance; 13 | import org.junit.jupiter.api.extension.ExtensionContext; 14 | import org.mockito.ArgumentCaptor; 15 | import org.mockito.stubbing.Answer; 16 | 17 | import java.util.List; 18 | 19 | import static org.hamcrest.MatcherAssert.assertThat; 20 | import static org.hamcrest.Matchers.equalTo; 21 | import static org.mockito.ArgumentMatchers.any; 22 | import static org.mockito.Mockito.*; 23 | 24 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 25 | public class CodeReferenceTest { 26 | 27 | public static class CodeReferenceTestExtension extends ReportPortalExtension { 28 | static Launch LAUNCH; 29 | 30 | @Override 31 | protected Launch getLaunch(ExtensionContext context) { 32 | return LAUNCH; 33 | } 34 | } 35 | 36 | @BeforeEach 37 | public void setupMock() { 38 | CodeReferenceTestExtension.LAUNCH = mock(Launch.class); 39 | when(CodeReferenceTestExtension.LAUNCH.startTestItem(any())).thenAnswer((Answer>) invocation -> CommonUtils.createMaybeUuid()); 40 | when(CodeReferenceTestExtension.LAUNCH.startTestItem( 41 | any(), 42 | any() 43 | )).thenAnswer((Answer>) invocation -> CommonUtils.createMaybeUuid()); 44 | } 45 | 46 | @Test 47 | public void verify_static_test_code_reference_generation() { 48 | TestUtils.runClasses(SingleTest.class); 49 | 50 | Launch launch = CodeReferenceTestExtension.LAUNCH; 51 | 52 | ArgumentCaptor suiteCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); 53 | verify(launch, times(1)).startTestItem(suiteCaptor.capture()); // Start parent Suite 54 | 55 | ArgumentCaptor testCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); 56 | verify(launch, times(1)).startTestItem(notNull(), testCaptor.capture()); // Start a test 57 | 58 | String className = SingleTest.class.getCanonicalName(); 59 | StartTestItemRQ suiteRq = suiteCaptor.getValue(); 60 | assertThat(suiteRq.getCodeRef(), equalTo(className)); 61 | 62 | StartTestItemRQ testRq = testCaptor.getValue(); 63 | assertThat(testRq.getCodeRef(), equalTo(className + ".singleTest")); 64 | } 65 | 66 | @Test 67 | public void verify_dynamic_test_code_reference_generation() { 68 | TestUtils.runClasses(SingleDynamicTest.class); 69 | 70 | Launch launch = CodeReferenceTestExtension.LAUNCH; 71 | 72 | ArgumentCaptor suiteCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); 73 | verify(launch, times(1)).startTestItem(suiteCaptor.capture()); // Start parent Suite 74 | 75 | ArgumentCaptor testCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); 76 | verify(launch, times(2)).startTestItem(notNull(), testCaptor.capture()); // Start a test class and a test 77 | 78 | String className = SingleDynamicTest.class.getCanonicalName(); 79 | StartTestItemRQ suiteRq = suiteCaptor.getValue(); 80 | assertThat(suiteRq.getCodeRef(), equalTo(className)); 81 | 82 | List rqValues = testCaptor.getAllValues(); 83 | String testName = className + ".testForTestFactory"; 84 | assertThat(rqValues.get(0).getCodeRef(), equalTo(testName)); 85 | assertThat(rqValues.get(1).getCodeRef(), equalTo(testName + "$" + SingleDynamicTest.TEST_CASE_DISPLAY_NAME)); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/DescriptionTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5; 2 | 3 | import com.epam.reportportal.junit5.features.description.*; 4 | import com.epam.reportportal.junit5.util.TestUtils; 5 | import com.epam.reportportal.service.Launch; 6 | import com.epam.reportportal.util.test.CommonUtils; 7 | import com.epam.ta.reportportal.ws.model.StartTestItemRQ; 8 | import io.reactivex.Maybe; 9 | import org.junit.jupiter.api.BeforeEach; 10 | import org.junit.jupiter.api.Test; 11 | import org.junit.jupiter.api.extension.ExtensionContext; 12 | import org.mockito.ArgumentCaptor; 13 | import org.mockito.stubbing.Answer; 14 | 15 | import java.util.List; 16 | import java.util.stream.Collectors; 17 | 18 | import static org.hamcrest.MatcherAssert.assertThat; 19 | import static org.hamcrest.Matchers.equalTo; 20 | import static org.hamcrest.Matchers.hasItem; 21 | import static org.mockito.ArgumentMatchers.any; 22 | import static org.mockito.Mockito.*; 23 | 24 | /** 25 | * @author Oleksandr Fomenko 26 | */ 27 | public class DescriptionTest { 28 | public static class TestExtension extends ReportPortalExtension { 29 | static Launch LAUNCH; 30 | 31 | @Override 32 | protected Launch getLaunch(ExtensionContext context) { 33 | return LAUNCH; 34 | } 35 | } 36 | 37 | @BeforeEach 38 | public void setupMock() { 39 | TestExtension.LAUNCH = mock(Launch.class); 40 | when(TestExtension.LAUNCH.startTestItem(any())).thenAnswer((Answer>) invocation -> CommonUtils.createMaybeUuid()); 41 | when(TestExtension.LAUNCH.startTestItem( 42 | any(), 43 | any() 44 | )).thenAnswer((Answer>) invocation -> CommonUtils.createMaybeUuid()); 45 | } 46 | 47 | @Test 48 | void descriptionFromMethodAnnotationTest() { 49 | TestUtils.runClasses(DescriptionAnnotatedMethodTest.class); 50 | 51 | Launch launch = TestExtension.LAUNCH; 52 | 53 | verify(launch, times(1)).startTestItem(any()); // Start parent Suite 54 | 55 | ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); 56 | verify(launch, times(1)).startTestItem(notNull(), captor.capture()); // Start a test 57 | 58 | StartTestItemRQ request = captor.getValue(); 59 | assertThat(request.getDescription(), equalTo(DescriptionAnnotatedMethodTest.TEST_DESCRIPTION_METHOD)); 60 | } 61 | 62 | @Test 63 | void descriptionFromClassAnnotationTest() { 64 | TestUtils.runClasses(DescriptionAnnotatedClassTest.class); 65 | 66 | Launch launch = TestExtension.LAUNCH; 67 | 68 | verify(launch, times(1)).startTestItem(any()); // Start parent Suite 69 | 70 | ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); 71 | verify(launch, times(1)).startTestItem(notNull(), captor.capture()); // Start a test 72 | 73 | StartTestItemRQ request = captor.getValue(); 74 | assertThat(request.getDescription(), equalTo(DescriptionAnnotatedClassTest.TEST_DESCRIPTION_CLASS)); 75 | } 76 | 77 | @Test 78 | void descriptionFromBothMethodAndClassAnnotationTest() { 79 | TestUtils.runClasses(DescriptionAnnotatedMethodAndClassTest.class); 80 | 81 | Launch launch = TestExtension.LAUNCH; 82 | 83 | verify(launch, times(1)).startTestItem(any()); // Start parent Suite 84 | 85 | ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); 86 | verify(launch, times(1)).startTestItem(notNull(), captor.capture()); // Start a test 87 | 88 | StartTestItemRQ request = captor.getValue(); 89 | //from both annotations the expected one should be taken from the method 90 | assertThat(request.getDescription(), equalTo(DescriptionAnnotatedMethodTest.TEST_DESCRIPTION_METHOD)); 91 | } 92 | 93 | @Test 94 | void descriptionFromMethodAnnotationDynamicTest() { 95 | TestUtils.runClasses(DescriptionAnnotatedMethodDynamicTest.class); 96 | 97 | Launch launch = TestExtension.LAUNCH; 98 | verify(launch, times(1)).startTestItem(any()); // Start parent Suite 99 | 100 | ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); 101 | verify(launch, times(2)).startTestItem(notNull(), captor.capture()); // Start a test 102 | 103 | List testStepsDescription = captor.getAllValues() 104 | .stream() 105 | .filter(e -> e.getType().equals(ItemType.STEP.name())) 106 | .map(StartTestItemRQ::getDescription) 107 | .collect(Collectors.toList()); 108 | 109 | assertThat(testStepsDescription, hasItem(DescriptionAnnotatedMethodDynamicTest.TEST_DESCRIPTION_DYNAMIC_METHOD)); 110 | } 111 | 112 | @Test 113 | void descriptionFromClassAnnotationDynamicTest() { 114 | TestUtils.runClasses(DescriptionAnnotatedClassDynamicTest.class); 115 | 116 | Launch launch = TestExtension.LAUNCH; 117 | verify(launch, times(1)).startTestItem(any()); // Start parent Suite 118 | 119 | ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); 120 | verify(launch, times(2)).startTestItem(notNull(), captor.capture()); // Start a test 121 | 122 | List testStepsDescription = captor.getAllValues() 123 | .stream() 124 | .filter(e -> e.getType().equals(ItemType.STEP.name())) 125 | .map(StartTestItemRQ::getDescription) 126 | .collect(Collectors.toList()); 127 | 128 | assertThat(testStepsDescription, hasItem(DescriptionAnnotatedClassDynamicTest.TEST_DESCRIPTION_DYNAMIC_CLASS)); 129 | } 130 | 131 | @Test 132 | void descriptionFromBothMethodAndClassAnnotationDynamicTest() { 133 | TestUtils.runClasses(DescriptionAnnotatedMethodAndClassDynamicTest.class); 134 | 135 | Launch launch = TestExtension.LAUNCH; 136 | verify(launch, times(1)).startTestItem(any()); // Start parent Suite 137 | 138 | ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); 139 | verify(launch, times(2)).startTestItem(notNull(), captor.capture()); // Start a test 140 | 141 | List testStepsDescription = captor.getAllValues() 142 | .stream() 143 | .filter(e -> e.getType().equals(ItemType.STEP.name())) 144 | .map(StartTestItemRQ::getDescription) 145 | .collect(Collectors.toList()); 146 | //from both annotations the expected one should be taken from the method 147 | assertThat(testStepsDescription, hasItem(DescriptionAnnotatedMethodDynamicTest.TEST_DESCRIPTION_DYNAMIC_METHOD)); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/StepReporterTest.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.junit5; 18 | 19 | import com.epam.reportportal.junit5.features.step.ManualStepReporterFeatureTest; 20 | import com.epam.reportportal.junit5.features.step.ManualStepReporterSimpleTest; 21 | import com.epam.reportportal.junit5.util.TestUtils; 22 | import com.epam.reportportal.listeners.ItemStatus; 23 | import com.epam.reportportal.service.Launch; 24 | import com.epam.reportportal.service.ReportPortal; 25 | import com.epam.reportportal.service.ReportPortalClient; 26 | import com.epam.ta.reportportal.ws.model.FinishTestItemRQ; 27 | import org.apache.commons.lang3.tuple.Pair; 28 | import org.junit.jupiter.api.Test; 29 | import org.junit.jupiter.api.extension.ExtensionContext; 30 | import org.junit.platform.engine.TestExecutionResult; 31 | import org.junit.platform.launcher.TestExecutionListener; 32 | import org.junit.platform.launcher.TestIdentifier; 33 | import org.mockito.ArgumentCaptor; 34 | 35 | import java.util.Deque; 36 | import java.util.List; 37 | import java.util.concurrent.ConcurrentLinkedDeque; 38 | import java.util.stream.Collectors; 39 | import java.util.stream.Stream; 40 | 41 | import static com.epam.reportportal.junit5.util.TestUtils.runClasses; 42 | import static com.epam.reportportal.util.test.CommonUtils.namedId; 43 | import static org.hamcrest.MatcherAssert.assertThat; 44 | import static org.hamcrest.Matchers.equalTo; 45 | import static org.hamcrest.Matchers.sameInstance; 46 | import static org.mockito.ArgumentMatchers.any; 47 | import static org.mockito.Mockito.*; 48 | 49 | /** 50 | * @author Ivan Budayeu 51 | */ 52 | public class StepReporterTest { 53 | 54 | public static class TestExtension extends ReportPortalExtension { 55 | static final String testClassUuid = namedId("class"); 56 | static final String testMethodUuid = namedId("test"); 57 | static final List stepUuidList = Stream.generate(() -> namedId("step")).limit(3).collect(Collectors.toList()); 58 | static final List> testStepUuidOrder = stepUuidList.stream() 59 | .map(u -> Pair.of(testMethodUuid, u)) 60 | .collect(Collectors.toList()); 61 | 62 | static final ThreadLocal client = new ThreadLocal<>(); 63 | static final ThreadLocal launch = new ThreadLocal<>(); 64 | 65 | public static void init() { 66 | client.set(mock(ReportPortalClient.class)); 67 | TestUtils.mockLaunch(client.get(), "launchUuid", testClassUuid, testMethodUuid); 68 | TestUtils.mockNestedSteps(client.get(), testStepUuidOrder); 69 | TestUtils.mockLogging(client.get()); 70 | ReportPortal reportPortal = ReportPortal.create(client.get(), TestUtils.standardParameters()); 71 | launch.set(reportPortal.newLaunch(TestUtils.launchRQ(reportPortal.getParameters()))); 72 | } 73 | 74 | @Override 75 | protected Launch getLaunch(ExtensionContext context) { 76 | return launch.get(); 77 | } 78 | } 79 | 80 | public static class Listener implements TestExecutionListener { 81 | public Deque results = new ConcurrentLinkedDeque<>(); 82 | 83 | @Override 84 | public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) { 85 | results.add(testExecutionResult); 86 | } 87 | } 88 | 89 | @Test 90 | public void verify_failed_nested_step_not_fails_test_run() { 91 | TestExtension.init(); 92 | Listener listener = new Listener(); 93 | runClasses(listener, ManualStepReporterFeatureTest.class); 94 | 95 | ReportPortalClient client = TestExtension.client.get(); 96 | ArgumentCaptor finishNestedStep = ArgumentCaptor.forClass(FinishTestItemRQ.class); 97 | verify(client, timeout(1000)).finishTestItem(eq(TestExtension.stepUuidList.get(2)), finishNestedStep.capture()); 98 | 99 | ArgumentCaptor finishTestStep = ArgumentCaptor.forClass(FinishTestItemRQ.class); 100 | verify(client, timeout(1000)).finishTestItem(eq(TestExtension.testMethodUuid), finishTestStep.capture()); 101 | 102 | assertThat(finishNestedStep.getValue().getStatus(), equalTo(ItemStatus.FAILED.name())); 103 | assertThat(finishTestStep.getValue().getStatus(), equalTo(ItemStatus.FAILED.name())); 104 | 105 | assertThat(listener.results.remove().getStatus(), sameInstance(TestExecutionResult.Status.SUCCESSFUL)); 106 | } 107 | 108 | @Test 109 | public void verify_listener_finishes_unfinished_step() { 110 | TestExtension.init(); 111 | runClasses(ManualStepReporterSimpleTest.class); 112 | 113 | ReportPortalClient client = TestExtension.client.get(); 114 | verify(client, timeout(1000)).finishTestItem(eq(TestExtension.stepUuidList.get(0)), any()); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/SystemAttributesFetcherTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 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.junit5; 18 | 19 | import com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource; 20 | import com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ; 21 | import org.apache.commons.lang3.StringUtils; 22 | import org.junit.jupiter.api.Assertions; 23 | import org.junit.jupiter.api.Test; 24 | 25 | import java.util.Arrays; 26 | import java.util.List; 27 | import java.util.Set; 28 | import java.util.stream.Collectors; 29 | 30 | import static org.junit.jupiter.api.Assertions.*; 31 | 32 | /** 33 | * @author Ihar Kahadouski 34 | */ 35 | class SystemAttributesFetcherTest { 36 | 37 | private static final List expectedKeys = Arrays.asList("jvm", "os", "agent", "skippedIssue"); 38 | 39 | @Test 40 | void systemAttributesRetrievingTest() { 41 | Set systemAttributes = SystemAttributesFetcher.collectSystemAttributes(false); 42 | assertNotNull(systemAttributes); 43 | assertEquals(expectedKeys.size(), systemAttributes.size()); 44 | systemAttributes.stream().map(ItemAttributesRQ::isSystem).forEach(Assertions::assertTrue); 45 | assertTrue(systemAttributes.stream().map(ItemAttributeResource::getKey).collect(Collectors.toList()).containsAll(expectedKeys)); 46 | assertEquals( 47 | expectedKeys.size(), 48 | (int) systemAttributes.stream().map(ItemAttributeResource::getValue).filter(StringUtils::isNotBlank).count() 49 | ); 50 | } 51 | } -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/TestInitTest.java: -------------------------------------------------------------------------------- 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.junit5; 18 | 19 | import com.epam.reportportal.junit5.features.beforeafterall.FailedConstructorTest; 20 | import com.epam.reportportal.junit5.util.TestUtils; 21 | import com.epam.reportportal.listeners.ItemStatus; 22 | import com.epam.reportportal.service.Launch; 23 | import com.epam.reportportal.service.step.StepReporter; 24 | import com.epam.reportportal.util.test.CommonUtils; 25 | import com.epam.ta.reportportal.ws.model.FinishTestItemRQ; 26 | import com.epam.ta.reportportal.ws.model.OperationCompletionRS; 27 | import com.epam.ta.reportportal.ws.model.StartTestItemRQ; 28 | import io.reactivex.Maybe; 29 | import org.junit.jupiter.api.BeforeEach; 30 | import org.junit.jupiter.api.Test; 31 | import org.junit.jupiter.api.TestInstance; 32 | import org.junit.jupiter.api.extension.ExtensionContext; 33 | import org.mockito.ArgumentCaptor; 34 | import org.mockito.stubbing.Answer; 35 | 36 | import java.util.List; 37 | import java.util.Map; 38 | import java.util.concurrent.ConcurrentHashMap; 39 | import java.util.stream.Collectors; 40 | 41 | import static com.epam.reportportal.junit5.TestInitTest.TestInitTestExtension.LAUNCH; 42 | import static org.hamcrest.MatcherAssert.assertThat; 43 | import static org.hamcrest.Matchers.equalTo; 44 | import static org.hamcrest.Matchers.hasSize; 45 | import static org.mockito.ArgumentMatchers.any; 46 | import static org.mockito.ArgumentMatchers.notNull; 47 | import static org.mockito.Mockito.*; 48 | 49 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 50 | public class TestInitTest { 51 | public static class TestInitTestExtension extends ReportPortalExtension { 52 | static Launch LAUNCH; 53 | 54 | @Override 55 | protected Launch getLaunch(ExtensionContext context) { 56 | return LAUNCH; 57 | } 58 | } 59 | 60 | private Map> itemStartMap; 61 | private Map, FinishTestItemRQ> itemFinishMap; 62 | 63 | @BeforeEach 64 | public void setupMock() { 65 | itemStartMap = new ConcurrentHashMap<>(); 66 | itemFinishMap = new ConcurrentHashMap<>(); 67 | LAUNCH = mock(Launch.class); 68 | when(LAUNCH.getStepReporter()).thenReturn(StepReporter.NOOP_STEP_REPORTER); 69 | when(LAUNCH.startTestItem(any())).thenAnswer((Answer>) invocation -> CommonUtils.createMaybeUuid()); 70 | when(LAUNCH.startTestItem(any(), any())).thenAnswer((Answer>) invocation -> { 71 | Maybe uuidMaybe = CommonUtils.createMaybeUuid(); 72 | StartTestItemRQ start = invocation.getArgument(1); 73 | itemStartMap.put(start, uuidMaybe); 74 | return uuidMaybe; 75 | }); 76 | when(LAUNCH.finishTestItem(any(), any())).thenAnswer((Answer>) invocation -> { 77 | Maybe uuidMaybe = invocation.getArgument(0); 78 | FinishTestItemRQ finish = invocation.getArgument(1); 79 | itemFinishMap.put(uuidMaybe, finish); 80 | return Maybe.just(new OperationCompletionRS()); 81 | }); 82 | } 83 | 84 | @Test 85 | public void verify_a_test_with_failed_init_in_constructor_reported() { 86 | TestUtils.runClasses(FailedConstructorTest.class); 87 | 88 | verify(LAUNCH, times(1)).startTestItem(any()); // Start parent Suite 89 | ArgumentCaptor captorStart = ArgumentCaptor.forClass(StartTestItemRQ.class); 90 | verify(LAUNCH, times(2)).startTestItem(notNull(), captorStart.capture()); // Start a suite and two methods 91 | 92 | ArgumentCaptor captorFinish = ArgumentCaptor.forClass(FinishTestItemRQ.class); 93 | verify(LAUNCH, times(3)).finishTestItem(notNull(), captorFinish.capture()); // finish tests and suites 94 | 95 | List beforeAll = captorStart.getAllValues() 96 | .stream() 97 | .filter(e -> e.getType().equals(ItemType.BEFORE_CLASS.name())) 98 | .collect(Collectors.toList()); 99 | 100 | List beforeEach = captorStart.getAllValues() 101 | .stream() 102 | .filter(e -> e.getType().equals(ItemType.BEFORE_METHOD.name())) 103 | .collect(Collectors.toList()); 104 | 105 | List testSteps = captorStart.getAllValues() 106 | .stream() 107 | .filter(e -> e.getType().equals(ItemType.STEP.name())) 108 | .collect(Collectors.toList()); 109 | 110 | assertThat("There are one @Test methods", testSteps, hasSize(1)); 111 | assertThat("There are no @BeforeEach methods", beforeEach, hasSize(0)); 112 | assertThat("There are one @BeforeAll method", beforeAll, hasSize(1)); 113 | 114 | FinishTestItemRQ finishTest = itemFinishMap.get(itemStartMap.get(testSteps.get(0))); 115 | assertThat(finishTest.getStatus(), equalTo(ItemStatus.FAILED.name())); 116 | 117 | FinishTestItemRQ finishBeforeAll = itemFinishMap.get(itemStartMap.get(beforeAll.get(0))); 118 | assertThat(finishBeforeAll.getStatus(), equalTo(ItemStatus.PASSED.name())); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/bugs/LaunchStartTimeTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.bugs; 2 | 3 | import com.epam.reportportal.junit5.ReportPortalExtension; 4 | import com.epam.reportportal.junit5.features.bug.TestIncorrectStartTime; 5 | import com.epam.reportportal.junit5.util.TestUtils; 6 | import com.epam.reportportal.service.ReportPortal; 7 | import com.epam.reportportal.service.ReportPortalClient; 8 | import com.epam.reportportal.util.test.CommonUtils; 9 | import com.epam.ta.reportportal.ws.model.ApiInfo; 10 | import com.epam.ta.reportportal.ws.model.StartTestItemRQ; 11 | import com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ; 12 | import io.reactivex.Maybe; 13 | import org.junit.jupiter.api.BeforeEach; 14 | import org.junit.jupiter.api.Test; 15 | import org.mockito.ArgumentCaptor; 16 | 17 | import java.time.Instant; 18 | import java.util.concurrent.TimeUnit; 19 | 20 | import static org.hamcrest.MatcherAssert.assertThat; 21 | import static org.hamcrest.Matchers.lessThanOrEqualTo; 22 | import static org.mockito.ArgumentMatchers.any; 23 | import static org.mockito.Mockito.*; 24 | 25 | public class LaunchStartTimeTest { 26 | 27 | private final String launchUuid = CommonUtils.namedId("launch"); 28 | private final String suitedUuid = CommonUtils.namedId("suite"); 29 | private final String testMethodUuid = CommonUtils.namedId("test"); 30 | 31 | public static class TestExtension extends ReportPortalExtension { 32 | static volatile ReportPortal REPORT_PORTAL; 33 | 34 | @Override 35 | protected ReportPortal getReporter() { 36 | return REPORT_PORTAL; 37 | } 38 | } 39 | 40 | private ReportPortalClient client; 41 | 42 | @BeforeEach 43 | public void setupMock() { 44 | client = mock(ReportPortalClient.class); 45 | TestUtils.mockLaunch(client, launchUuid, suitedUuid, testMethodUuid); 46 | TestUtils.mockLogging(client); 47 | ApiInfo info = new ApiInfo(); 48 | ApiInfo.Build build = new ApiInfo.Build(); 49 | info.setBuild(build); 50 | build.setVersion("5.13.2"); 51 | when(client.getApiInfo()).thenReturn(Maybe.just(info)); 52 | TestExtension.REPORT_PORTAL = ReportPortal.create(client, TestUtils.standardParameters()); 53 | } 54 | 55 | @Test 56 | public void verify_start_time_has_correct_order() { 57 | TestUtils.runClasses(TestIncorrectStartTime.class); 58 | 59 | ArgumentCaptor startLaunchCaptor = ArgumentCaptor.forClass(StartLaunchRQ.class); 60 | verify(client, timeout(TimeUnit.SECONDS.toMillis(2)).times(1)).startLaunch(startLaunchCaptor.capture()); 61 | 62 | ArgumentCaptor startSuiteCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); 63 | verify(client, timeout(TimeUnit.SECONDS.toMillis(2)).times(1)).startTestItem(startSuiteCaptor.capture()); 64 | 65 | ArgumentCaptor startTestCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); 66 | verify(client, timeout(TimeUnit.SECONDS.toMillis(2)).times(1)).startTestItem(any(), startTestCaptor.capture()); 67 | 68 | Instant launchStart = (Instant) startLaunchCaptor.getValue().getStartTime(); 69 | Instant suiteStart = (Instant) startSuiteCaptor.getValue().getStartTime(); 70 | Instant itemStart = (Instant) startTestCaptor.getValue().getStartTime(); 71 | 72 | assertThat(launchStart, lessThanOrEqualTo(suiteStart)); 73 | assertThat(suiteStart, lessThanOrEqualTo(itemStart)); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/JUnit5Tests.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features; 2 | 3 | import com.epam.reportportal.service.ReportPortal; 4 | import org.junit.jupiter.api.*; 5 | import org.junit.jupiter.params.ParameterizedTest; 6 | import org.junit.jupiter.params.provider.*; 7 | 8 | import java.io.File; 9 | import java.time.DayOfWeek; 10 | import java.util.Arrays; 11 | import java.util.Date; 12 | import java.util.List; 13 | import java.util.stream.Stream; 14 | 15 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 16 | 17 | class JUnit5Tests { 18 | 19 | @BeforeAll 20 | static void beforeAll() { 21 | System.out.println("before-all"); 22 | } 23 | 24 | @BeforeEach 25 | void initializeBaseClass() { 26 | System.out.println("base-class-before-each"); 27 | } 28 | 29 | @Test 30 | @Tag("tag1") 31 | @Tag("tag2") 32 | void baseClassTest() { 33 | // Report launch log 34 | ReportPortal.emitLaunchLog("LAUNCH LOG MESAGE WITH ATTACHMENT", "error", new Date(), new File("files/css.css")); 35 | System.out.println("base-class-test"); 36 | } 37 | 38 | private static List testData() { 39 | return Arrays.asList("first", "second", "third"); 40 | } 41 | 42 | @Disabled 43 | @Test 44 | void disabledTest() { 45 | System.out.println("disabled"); 46 | } 47 | 48 | @ParameterizedTest 49 | @MethodSource("testData") 50 | void parameterizedTestWithMethodSource(String value) { 51 | System.out.println("parameterized-test-with-method-source, parameter: " + value); 52 | } 53 | 54 | @ParameterizedTest 55 | @CsvSource({ "first", "second", "third" }) 56 | void parameterizedTestWithCsvSource(String value) { 57 | System.out.println("parameterized-test-with-csv-source, parameter: " + value); 58 | } 59 | 60 | @ParameterizedTest 61 | @EnumSource(value = DayOfWeek.class, names = { "MONDAY", "WEDNESDAY", "FRIDAY" }) 62 | void parameterizedTestWithEnumSource(DayOfWeek day) { 63 | System.out.println("parameterized-test-with-enum-source, parameter: " + day); 64 | } 65 | 66 | @ParameterizedTest 67 | @NullSource 68 | void parameterizedTestWithNullSource(String value) { 69 | System.out.println("parameterized-test-with-null-source, parameter: " + value); 70 | } 71 | 72 | @ParameterizedTest 73 | @NullSource 74 | @ValueSource(strings = { "a", "b", "c" }) 75 | void parameterizedTestWithNullSourceAndValueSource(String value) { 76 | System.out.println("parameterized-test-with-null-source-and-value-source, parameter: " + value); 77 | } 78 | 79 | @ParameterizedTest 80 | @EmptySource 81 | void parameterizedTestWithEmptySource(String value) { 82 | System.out.println("parameterized-test-with-empty-source, parameter: " + value); 83 | } 84 | 85 | @ParameterizedTest 86 | @EmptySource 87 | @ValueSource(strings = { "a", "b", "c" }) 88 | void parameterizedTestWithEmptySourceAndValueSource(String value) { 89 | System.out.println("parameterized-test-with-empty-source-and-value-source, parameter: " + value); 90 | } 91 | 92 | @ParameterizedTest 93 | @NullSource 94 | @EmptySource 95 | @ValueSource(strings = { "a", "b", "c" }) 96 | void parameterizedTestWithNullSourceAndEmptySourceAndValueSource(String value) { 97 | System.out.println("parameterized-test-with-null-source-empty-source-and-value-source, parameter: " + value); 98 | } 99 | 100 | @ParameterizedTest 101 | @NullAndEmptySource 102 | void parameterizedTestWithNullAndEmptySource(String value) { 103 | System.out.println("parameterized-test-with-null-and-empty-source, parameter: " + value); 104 | } 105 | 106 | @ParameterizedTest 107 | @NullAndEmptySource 108 | @ValueSource(strings = { "a", "b", "c" }) 109 | void parameterizedTestWithNullAndEmptySourceAndValueSource(String value) { 110 | System.out.println("parameterized-test-with-null-and-empty-source-and-value-source, parameter: " + value); 111 | } 112 | 113 | @ParameterizedTest 114 | @ValueSource(floats = { 1.1f, 2.2f, 3.3f }) 115 | void parameterizedTestWithFloatsValueSource(float value) { 116 | System.out.println("parameterized-test-with-value-source, parameter: " + value); 117 | } 118 | 119 | @ParameterizedTest 120 | @ValueSource(ints = { 1, 2, 3 }) 121 | void parameterizedTestWithIntValueSource(int value) { 122 | System.out.println("parameterized-test-with-value-source, parameter: " + value); 123 | } 124 | 125 | @ParameterizedTest 126 | @ValueSource(shorts = { 1, 2, 3 }) 127 | void parameterizedTestWithShortsValueSource(short value) { 128 | System.out.println("parameterized-test-with-value-source, parameter: " + value); 129 | } 130 | 131 | @ParameterizedTest 132 | @ValueSource(bytes = { 1, 2, 3 }) 133 | void parameterizedTestWithBytesValueSource(byte value) { 134 | System.out.println("parameterized-test-with-value-source, parameter: " + value); 135 | } 136 | 137 | @ParameterizedTest 138 | @ValueSource(chars = { 'a', 'b', 'c' }) 139 | void parameterizedTestWithCharsValueSource(char value) { 140 | System.out.println("parameterized-test-with-value-source, parameter: " + value); 141 | } 142 | 143 | @ParameterizedTest 144 | @ValueSource(doubles = { 1.1, 2.2, 3.3 }) 145 | void parameterizedTestWithDoublesValueSource(double value) { 146 | System.out.println("parameterized-test-with-value-source, parameter: " + value); 147 | } 148 | 149 | @ParameterizedTest 150 | @ValueSource(longs = { 1147483648L, 2147483648L, 3147483648L }) 151 | void parameterizedTestWithLongsValueSource(long value) { 152 | System.out.println("parameterized-test-with-value-source, parameter: " + value); 153 | } 154 | 155 | @ParameterizedTest 156 | @ValueSource(strings = { "a", "b", "c" }) 157 | void parameterizedTestWithStringsValueSource(String value) { 158 | System.out.println("parameterized-test-with-value-source, parameter: " + value); 159 | } 160 | 161 | @TestFactory 162 | Stream testForTestFactory() { 163 | return testData().stream() 164 | .map(testData -> dynamicTest( 165 | "Check Test Factory " + testData, 166 | () -> System.out.println("test-for-test-factory, test " + testData) 167 | )); 168 | } 169 | 170 | @Nested 171 | class FirstContext { 172 | 173 | @BeforeEach 174 | void initializeFirstNesting() { 175 | System.out.println("nested-before-each"); 176 | } 177 | 178 | @RepeatedTest(10) 179 | void firstNestedTest() { 180 | System.out.println("first-nested-test"); 181 | } 182 | 183 | @Test 184 | void secondNestedTest() { 185 | System.out.println("second-nested-test"); 186 | } 187 | 188 | @AfterEach 189 | void afterFirstContext() { 190 | System.out.println("nested-after-each"); 191 | } 192 | 193 | @Nested 194 | class SecondContext { 195 | @BeforeEach 196 | void initializeSecondNesting() { 197 | System.out.println("nested-before-each"); 198 | } 199 | 200 | @RepeatedTest(10) 201 | void firstNestedTest() { 202 | System.out.println("first-nested-test"); 203 | } 204 | 205 | @Test 206 | void secondNestedTest() { 207 | System.out.println("second-nested-test"); 208 | } 209 | 210 | @AfterEach 211 | void afterFirstContext() { 212 | System.out.println("nested-after-each"); 213 | } 214 | } 215 | 216 | } 217 | } 218 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/TestFailure.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.junit5.features; 18 | 19 | import com.epam.reportportal.junit5.BasicTest; 20 | import org.junit.jupiter.api.Assertions; 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | 24 | @ExtendWith(BasicTest.BasicTestExtension.class) 25 | public class TestFailure { 26 | 27 | public static final String FAILURE_MESSAGE = "Test failure"; 28 | 29 | @Test 30 | public void testFailure() { 31 | Assertions.fail(FAILURE_MESSAGE); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/attributes/ClassLevelAttributesTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.attributes; 2 | 3 | import com.epam.reportportal.annotations.attribute.Attribute; 4 | import com.epam.reportportal.annotations.attribute.Attributes; 5 | import com.epam.reportportal.junit5.AttributesTest; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | @ExtendWith(AttributesTest.AttributesTestExtension.class) 12 | @Attributes(attributes = { @Attribute(key = ClassLevelAttributesTest.KEY, value = ClassLevelAttributesTest.VALUE) }) 13 | public class ClassLevelAttributesTest { 14 | public static final String KEY = "attribute_test_key"; 15 | public static final String VALUE = "attribute_test_value"; 16 | 17 | private static final Logger LOGGER = LoggerFactory.getLogger(ClassLevelAttributesTest.class); 18 | 19 | @Test 20 | public void testClassLevelAttributes() { 21 | LOGGER.info("Inside 'testClassLevelAttributes' method"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/attributes/MethodLevelAttributesTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.attributes; 2 | 3 | import com.epam.reportportal.annotations.attribute.Attribute; 4 | import com.epam.reportportal.annotations.attribute.Attributes; 5 | import com.epam.reportportal.junit5.AttributesTest; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | @ExtendWith(AttributesTest.AttributesTestExtension.class) 12 | public class MethodLevelAttributesTest { 13 | private static final Logger LOGGER = LoggerFactory.getLogger(MethodLevelAttributesTest.class); 14 | 15 | @Test 16 | @Attributes(attributes = { @Attribute(key = "myKey", value = "myValue") }) 17 | public void testMethodLevelAttributes() { 18 | LOGGER.info("Inside 'testMethodLevelAttributes' method"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/beforeafterall/AfterAllTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.beforeafterall; 2 | 3 | import org.junit.jupiter.api.AfterAll; 4 | import org.junit.jupiter.api.Test; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | 7 | @ExtendWith(com.epam.reportportal.junit5.BeforeAfterAllTest.BeforeAfterAllTestExtension.class) 8 | public class AfterAllTest { 9 | public static final String CLASS_ID = "3b6f28a9-4988-464e-b07f-17ab9f3abe72"; 10 | 11 | @Test 12 | public void testAfterAll() { 13 | System.out.println("Test: " + CLASS_ID); 14 | } 15 | 16 | @AfterAll 17 | public static void afterAll() { 18 | System.out.println("After all: " + CLASS_ID); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/beforeafterall/BeforeAfterAllBeforeAfterEachTwoTestsTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.beforeafterall; 2 | 3 | import org.junit.jupiter.api.*; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | 6 | @ExtendWith(com.epam.reportportal.junit5.BeforeAfterAllTest.BeforeAfterAllTestExtension.class) 7 | public class BeforeAfterAllBeforeAfterEachTwoTestsTest { 8 | public static final String CLASS_ID = "777a99a9-e9fd-43f2-9ab4-8621cffbebf4"; 9 | 10 | @BeforeAll 11 | public static void beforeAll() { 12 | System.out.println("Before all: " + CLASS_ID); 13 | } 14 | 15 | @BeforeEach 16 | public void beforeEach() { 17 | System.out.println("Before each: " + CLASS_ID); 18 | } 19 | 20 | @Test 21 | public void testFirstBeforeAfterAllBeforeAfterEach() { 22 | System.out.println("First Test: " + CLASS_ID); 23 | } 24 | 25 | @Test 26 | public void testSecondBeforeAfterAllBeforeAfterEach() { 27 | System.out.println("Second Test: " + CLASS_ID); 28 | } 29 | 30 | @AfterEach 31 | public void afterEach() { 32 | System.out.println("After each: " + CLASS_ID); 33 | } 34 | 35 | @AfterAll 36 | public static void afterAll() { 37 | System.out.println("After all: " + CLASS_ID); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/beforeafterall/BeforeAfterAllFailedTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.beforeafterall; 2 | 3 | import org.junit.jupiter.api.AfterAll; 4 | import org.junit.jupiter.api.BeforeAll; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(com.epam.reportportal.junit5.BeforeAfterAllTest.BeforeAfterAllTestExtension.class) 9 | public class BeforeAfterAllFailedTest { 10 | public static final String CLASS_ID = "e3a09449-b508-485d-aa9b-b6b2cf4b4fd5"; 11 | 12 | @BeforeAll 13 | public static void beforeAll() { 14 | System.out.println("Before all: " + CLASS_ID); 15 | } 16 | 17 | @Test 18 | public void testBeforeAfterAllFailed() { 19 | throw new IllegalStateException("Test: " + CLASS_ID); 20 | } 21 | 22 | @AfterAll 23 | public static void afterAll() { 24 | System.out.println("After all: " + CLASS_ID); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/beforeafterall/BeforeAfterAllTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.beforeafterall; 2 | 3 | import org.junit.jupiter.api.AfterAll; 4 | import org.junit.jupiter.api.BeforeAll; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(com.epam.reportportal.junit5.BeforeAfterAllTest.BeforeAfterAllTestExtension.class) 9 | public class BeforeAfterAllTest { 10 | public static final String CLASS_ID = "96a167df-0353-41cf-8d4d-dcba8368ddac"; 11 | 12 | @BeforeAll 13 | public static void beforeAll() { 14 | System.out.println("Before all: " + CLASS_ID); 15 | } 16 | 17 | @Test 18 | public void testBeforeAfterAll() { 19 | System.out.println("Test: " + CLASS_ID); 20 | } 21 | 22 | @AfterAll 23 | public static void afterAll() { 24 | System.out.println("After all: " + CLASS_ID); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/beforeafterall/BeforeAfterAllTwoTestsTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.beforeafterall; 2 | 3 | import org.junit.jupiter.api.AfterAll; 4 | import org.junit.jupiter.api.BeforeAll; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(com.epam.reportportal.junit5.BeforeAfterAllTest.BeforeAfterAllTestExtension.class) 9 | public class BeforeAfterAllTwoTestsTest { 10 | public static final String CLASS_ID = "7a9347b3-4d66-4133-88b7-60d52db61436"; 11 | 12 | @BeforeAll 13 | public static void beforeAll() { 14 | System.out.println("Before all: " + CLASS_ID); 15 | } 16 | 17 | @Test 18 | public void testFirstBeforeAfterAll() { 19 | System.out.println("First Test: " + CLASS_ID); 20 | } 21 | 22 | @Test 23 | public void testSecondBeforeAfterAll() { 24 | System.out.println("Second Test: " + CLASS_ID); 25 | } 26 | 27 | @AfterAll 28 | public static void afterAll() { 29 | System.out.println("After all: " + CLASS_ID); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/beforeafterall/BeforeAllAfterAllFailedTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.beforeafterall; 2 | 3 | import com.epam.reportportal.junit5.BeforeAfterAllTest; 4 | import org.junit.jupiter.api.AfterAll; 5 | import org.junit.jupiter.api.BeforeAll; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | @ExtendWith(BeforeAfterAllTest.BeforeAfterAllTestExtension.class) 10 | public class BeforeAllAfterAllFailedTest { 11 | public static final String CLASS_ID = "28b580fa-a7c0-4a7e-b0bc-54f196565d69"; 12 | 13 | @BeforeAll 14 | public static void beforeAllFailed() { 15 | System.out.println("Before all: " + CLASS_ID); 16 | } 17 | 18 | @Test 19 | public void testBeforeAllFailed() { 20 | System.out.println("Test: " + CLASS_ID); 21 | } 22 | 23 | @AfterAll 24 | public static void afterAllFailed() { 25 | throw new IllegalStateException("After all: " + CLASS_ID); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/beforeafterall/BeforeAllFailedTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.beforeafterall; 2 | 3 | import org.junit.jupiter.api.BeforeAll; 4 | import org.junit.jupiter.api.Test; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | 7 | @ExtendWith(com.epam.reportportal.junit5.BeforeAfterAllTest.BeforeAfterAllTestExtension.class) 8 | public class BeforeAllFailedTest { 9 | public static final String CLASS_ID = "710b184b-4f81-403c-8310-9a54f56b687b"; 10 | 11 | @BeforeAll 12 | public static void beforeAllFailed() { 13 | throw new IllegalStateException("Before all: " + CLASS_ID); 14 | } 15 | 16 | @Test 17 | public void testBeforeAllFailed() { 18 | System.out.println("Test: " + CLASS_ID); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/beforeafterall/BeforeAllTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.beforeafterall; 2 | 3 | import org.junit.jupiter.api.BeforeAll; 4 | import org.junit.jupiter.api.Disabled; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(com.epam.reportportal.junit5.BeforeAfterAllTest.BeforeAfterAllTestExtension.class) 9 | public class BeforeAllTest { 10 | public static final String CLASS_ID = "8b2354a9-4448-4189-ae5d-f74f547f0f66"; 11 | 12 | @BeforeAll 13 | public static void beforeAll() { 14 | System.out.println("Before all: " + CLASS_ID); 15 | } 16 | 17 | @Test 18 | public void testBeforeAll() { 19 | System.out.println("Test: " + CLASS_ID); 20 | } 21 | 22 | @Test 23 | @Disabled 24 | public void testDisabled() { 25 | System.out.println("Test: " + CLASS_ID); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/beforeafterall/FailedAfterEachTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.beforeafterall; 2 | 3 | import com.epam.reportportal.junit5.BeforeAfterAllTest; 4 | import org.junit.jupiter.api.AfterEach; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(BeforeAfterAllTest.BeforeAfterAllTestExtension.class) 9 | public class FailedAfterEachTest { 10 | 11 | @Test 12 | public void testAfterEachFailed() { 13 | System.out.println("Test: testAfterEachFailed"); 14 | } 15 | 16 | @AfterEach 17 | public void afterEach() { 18 | throw new IllegalStateException("After each: afterEach"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/beforeafterall/FailedConstructorTest.java: -------------------------------------------------------------------------------- 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.junit5.features.beforeafterall; 18 | 19 | import com.epam.reportportal.junit5.TestInitTest; 20 | import org.junit.jupiter.api.BeforeAll; 21 | import org.junit.jupiter.api.BeforeEach; 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | 25 | @ExtendWith(TestInitTest.TestInitTestExtension.class) 26 | public class FailedConstructorTest { 27 | private int a = 4 / 0; 28 | 29 | @BeforeAll 30 | public static void beforeAll() { 31 | } 32 | 33 | @BeforeEach 34 | public void beforeEach() { 35 | } 36 | 37 | @Test 38 | public void test() { 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/beforeafterall/NonStaticBeforeAfterAllTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.beforeafterall; 2 | 3 | import org.junit.jupiter.api.AfterAll; 4 | import org.junit.jupiter.api.BeforeAll; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.TestInstance; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | @ExtendWith(com.epam.reportportal.junit5.BeforeAfterAllTest.BeforeAfterAllTestExtension.class) 10 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 11 | public class NonStaticBeforeAfterAllTest { 12 | public static final String CLASS_ID = "d93ecaae-2161-4c1c-8b68-124ed4dcb4f1"; 13 | 14 | @BeforeAll 15 | public void beforeAll() { 16 | System.out.println("Before all: " + CLASS_ID); 17 | } 18 | 19 | @Test 20 | public void testBeforeAfterAll() { 21 | System.out.println("Test: " + CLASS_ID); 22 | } 23 | 24 | @AfterAll 25 | public void afterAll() { 26 | System.out.println("After all: " + CLASS_ID); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/bug/BeforeEachFailedDuplicateTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.bug; 2 | 3 | import com.epam.reportportal.junit5.bugs.BeforeEachFailedDuplicationTest; 4 | import org.junit.jupiter.api.AfterAll; 5 | import org.junit.jupiter.api.AfterEach; 6 | import org.junit.jupiter.api.BeforeAll; 7 | import org.junit.jupiter.api.BeforeEach; 8 | import org.junit.jupiter.api.extension.ExtendWith; 9 | import org.junit.jupiter.params.ParameterizedTest; 10 | import org.junit.jupiter.params.provider.EnumSource; 11 | 12 | @ExtendWith(BeforeEachFailedDuplicationTest.BeforeEachFailedDuplicationExtension.class) 13 | public class BeforeEachFailedDuplicateTest { 14 | 15 | public enum TestParams { 16 | ONE, 17 | TWO 18 | } 19 | 20 | @BeforeAll 21 | public static void beforeAll() { 22 | System.out.println("Before all"); 23 | } 24 | 25 | @BeforeEach 26 | public void beforeEach() throws InterruptedException { 27 | System.out.println("Before each"); 28 | Thread.sleep(100); 29 | } 30 | 31 | @ParameterizedTest 32 | @EnumSource(TestParams.class) 33 | public void testFirstBeforeAfterAllBeforeAfterEach(TestParams param) throws InterruptedException { 34 | System.out.println("First Test: " + param.name()); 35 | Thread.sleep(100); 36 | } 37 | 38 | @ParameterizedTest 39 | @EnumSource(TestParams.class) 40 | public void testSecondBeforeAfterAllBeforeAfterEach(TestParams param) throws InterruptedException { 41 | System.out.println("Second Test: " + param.name()); 42 | Thread.sleep(100); 43 | } 44 | 45 | @AfterEach 46 | public void afterEach() throws InterruptedException { 47 | System.out.println("After each"); 48 | Thread.sleep(100); 49 | } 50 | 51 | @AfterAll 52 | public static void afterAll() { 53 | System.out.println("After all"); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/bug/TestIncorrectStartTime.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.bug; 2 | 3 | import com.epam.reportportal.junit5.bugs.LaunchStartTimeTest; 4 | import com.epam.reportportal.util.test.CommonUtils; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(LaunchStartTimeTest.TestExtension.class) 9 | public class TestIncorrectStartTime { 10 | 11 | @Test 12 | public void test_start_time() throws InterruptedException { 13 | Thread.sleep(CommonUtils.MINIMAL_TEST_PAUSE); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/callback/CallbackFeatureTest.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.junit5.features.callback; 18 | 19 | import com.epam.reportportal.junit5.CallbackReportingTest; 20 | import com.epam.reportportal.junit5.utils.ItemTreeUtils; 21 | import com.epam.reportportal.service.tree.ItemTreeReporter; 22 | import com.epam.reportportal.service.tree.TestItemTree; 23 | import com.epam.ta.reportportal.ws.model.FinishTestItemRQ; 24 | import org.junit.jupiter.api.AfterEach; 25 | import org.junit.jupiter.api.Assertions; 26 | import org.junit.jupiter.api.Test; 27 | import org.junit.jupiter.api.TestInfo; 28 | import org.junit.jupiter.api.extension.ExtendWith; 29 | 30 | import java.util.Calendar; 31 | 32 | import static com.epam.reportportal.junit5.CallbackReportingTest.ITEM_CALLBACK_FINISH_STATUS; 33 | import static com.epam.reportportal.junit5.ReportPortalExtension.REPORT_PORTAL; 34 | import static com.epam.reportportal.junit5.ReportPortalExtension.TEST_ITEM_TREE; 35 | 36 | /** 37 | * @author Ivan Budayeu 38 | */ 39 | @ExtendWith(CallbackReportingTest.CallbackReportingExtension.class) 40 | public class CallbackFeatureTest { 41 | 42 | @Test 43 | void someTest() { 44 | Assertions.assertEquals(1, 1); 45 | } 46 | 47 | @AfterEach 48 | void afterMethod(TestInfo testInfo) { 49 | TestItemTree.TestItemLeaf testItemLeaf = ItemTreeUtils.retrieveLeaf(testInfo, TEST_ITEM_TREE); 50 | if (testItemLeaf != null) { 51 | finishWithStatus(ITEM_CALLBACK_FINISH_STATUS, testItemLeaf); 52 | } 53 | } 54 | 55 | private void finishWithStatus(String status, TestItemTree.TestItemLeaf testItemLeaf) { 56 | FinishTestItemRQ finishTestItemRQ = new FinishTestItemRQ(); 57 | finishTestItemRQ.setStatus(status); 58 | finishTestItemRQ.setEndTime(Calendar.getInstance().getTime()); 59 | ItemTreeReporter.finishItem(REPORT_PORTAL.getClient(), finishTestItemRQ, TEST_ITEM_TREE.getLaunchId(), testItemLeaf) 60 | .cache() 61 | .blockingGet(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/callback/CallbackLogFeatureTest.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.junit5.features.callback; 18 | 19 | import com.epam.reportportal.junit5.CallbackReportingTest; 20 | import com.epam.reportportal.junit5.utils.ItemTreeUtils; 21 | import com.epam.reportportal.service.tree.ItemTreeReporter; 22 | import com.epam.reportportal.service.tree.TestItemTree; 23 | import org.junit.jupiter.api.AfterEach; 24 | import org.junit.jupiter.api.Assertions; 25 | import org.junit.jupiter.api.Test; 26 | import org.junit.jupiter.api.TestInfo; 27 | import org.junit.jupiter.api.extension.ExtendWith; 28 | 29 | import static com.epam.reportportal.junit5.CallbackReportingTest.*; 30 | import static com.epam.reportportal.junit5.ReportPortalExtension.REPORT_PORTAL; 31 | import static com.epam.reportportal.junit5.ReportPortalExtension.TEST_ITEM_TREE; 32 | 33 | /** 34 | * @author Ivan Budayeu 35 | */ 36 | @ExtendWith(CallbackReportingTest.CallbackReportingExtension.class) 37 | public class CallbackLogFeatureTest { 38 | 39 | @Test 40 | void someTest() { 41 | Assertions.assertEquals(1, 1); 42 | } 43 | 44 | @AfterEach 45 | void afterMethod(TestInfo testInfo) { 46 | TestItemTree.TestItemLeaf testItemLeaf = ItemTreeUtils.retrieveLeaf(testInfo, TEST_ITEM_TREE); 47 | if (testItemLeaf != null) { 48 | attachLog(testItemLeaf); 49 | } 50 | } 51 | 52 | private static void attachLog(TestItemTree.TestItemLeaf testItemLeaf) { 53 | ItemTreeReporter.sendLog( 54 | REPORT_PORTAL.getClient(), 55 | ERROR_LOG_LEVEL, 56 | LOG_MESSAGE, 57 | LOG_TIME, 58 | TEST_ITEM_TREE.getLaunchId(), 59 | testItemLeaf 60 | ); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/coderef/SingleDynamicTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.coderef; 2 | 3 | import com.epam.reportportal.junit5.CodeReferenceTest; 4 | import org.junit.jupiter.api.DynamicTest; 5 | import org.junit.jupiter.api.TestFactory; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | import java.util.UUID; 9 | import java.util.stream.Stream; 10 | 11 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 12 | 13 | @ExtendWith(CodeReferenceTest.CodeReferenceTestExtension.class) 14 | public class SingleDynamicTest { 15 | 16 | public static final String TEST_CASE_DISPLAY_NAME = UUID.randomUUID().toString(); 17 | 18 | @TestFactory 19 | Stream testForTestFactory() { 20 | return Stream.of(dynamicTest(TEST_CASE_DISPLAY_NAME, () -> System.out.println("Test factory test: " + TEST_CASE_DISPLAY_NAME))); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/coderef/SingleTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.coderef; 2 | 3 | import com.epam.reportportal.junit5.CodeReferenceTest; 4 | import org.junit.jupiter.api.DisplayName; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(CodeReferenceTest.CodeReferenceTestExtension.class) 9 | public class SingleTest { 10 | 11 | public static final String TEST_CASE_DISPLAY_NAME = "0c6b91e-623d-498d-a56d-fae1f2bbcbe4"; 12 | 13 | @Test() 14 | @DisplayName("0c6b91e-623d-498d-a56d-fae1f2bbcbe4") 15 | public void singleTest() { 16 | System.out.println("Test factory test: " + TEST_CASE_DISPLAY_NAME); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/configname/ConfigurationMethodsDefaultDisplayNameTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.configname; 2 | 3 | import com.epam.reportportal.junit5.miscellaneous.DisplayNamesForConfigurationItemsTest; 4 | import org.junit.jupiter.api.*; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | 7 | @ExtendWith(DisplayNamesForConfigurationItemsTest.TestExtension.class) 8 | public class ConfigurationMethodsDefaultDisplayNameTest { 9 | public static final String DISPLAY_NAME = "My custom display name"; 10 | 11 | @BeforeAll 12 | public static void beforeAll() { 13 | System.out.println("Before all"); 14 | } 15 | 16 | @BeforeEach 17 | public void beforeEach() { 18 | System.out.println("Before each"); 19 | } 20 | 21 | @Test 22 | public void testBeforeAfterAll() { 23 | System.out.println("Test"); 24 | } 25 | 26 | @AfterEach 27 | public void afterEach() { 28 | System.out.println("After each"); 29 | } 30 | 31 | @AfterAll 32 | public static void afterAll() { 33 | System.out.println("After all"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/configname/ConfigurationMethodsDisplayNameGeneratorTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.configname; 2 | 3 | import com.epam.reportportal.junit5.miscellaneous.DisplayNamesForConfigurationItemsTest; 4 | import org.junit.jupiter.api.*; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | 7 | @ExtendWith(DisplayNamesForConfigurationItemsTest.TestExtension.class) 8 | @DisplayNameGeneration(CustomDisplayNameGenerator.class) 9 | public class ConfigurationMethodsDisplayNameGeneratorTest { 10 | 11 | @BeforeAll 12 | public static void beforeAll() { 13 | System.out.println("Before all"); 14 | } 15 | 16 | @BeforeEach 17 | public void beforeEach() { 18 | System.out.println("Before each"); 19 | } 20 | 21 | @Test 22 | public void testBeforeAfterAll() { 23 | System.out.println("Test"); 24 | } 25 | 26 | @AfterEach 27 | public void afterEach() { 28 | System.out.println("After each"); 29 | } 30 | 31 | @AfterAll 32 | public static void afterAll() { 33 | System.out.println("After all"); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/configname/ConfigurationMethodsDisplayNameTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.configname; 2 | 3 | import com.epam.reportportal.junit5.miscellaneous.DisplayNamesForConfigurationItemsTest; 4 | import org.junit.jupiter.api.*; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | 7 | @ExtendWith(DisplayNamesForConfigurationItemsTest.TestExtension.class) 8 | public class ConfigurationMethodsDisplayNameTest { 9 | public static final String DISPLAY_NAME = "My custom display name"; 10 | 11 | @DisplayName(DISPLAY_NAME) 12 | @BeforeAll 13 | public static void beforeAll() { 14 | System.out.println("Before all"); 15 | } 16 | 17 | @DisplayName(DISPLAY_NAME) 18 | @BeforeEach 19 | public void beforeEach() { 20 | System.out.println("Before each"); 21 | } 22 | 23 | @DisplayName(DISPLAY_NAME) 24 | @Test 25 | public void testBeforeAfterAll() { 26 | System.out.println("Test"); 27 | } 28 | 29 | @DisplayName(DISPLAY_NAME) 30 | @AfterEach 31 | public void afterEach() { 32 | System.out.println("After each"); 33 | } 34 | 35 | @DisplayName(DISPLAY_NAME) 36 | @AfterAll 37 | public static void afterAll() { 38 | System.out.println("After all"); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/configname/CustomDisplayNameGenerator.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.configname; 2 | 3 | import org.junit.jupiter.api.DisplayNameGenerator; 4 | 5 | import java.lang.reflect.Method; 6 | 7 | public class CustomDisplayNameGenerator implements DisplayNameGenerator { 8 | public static final String DISPLAY_NAME_CLASS = "My custom display name for class"; 9 | public static final String DISPLAY_NAME_NESTED_CLASS = "My custom display name for nested class"; 10 | public static final String DISPLAY_NAME_METHOD = "My custom display name for method"; 11 | 12 | @Override 13 | public String generateDisplayNameForClass(Class testClass) { 14 | return DISPLAY_NAME_CLASS; 15 | } 16 | 17 | @Override 18 | public String generateDisplayNameForNestedClass(Class nestedClass) { 19 | return DISPLAY_NAME_NESTED_CLASS; 20 | } 21 | 22 | @Override 23 | public String generateDisplayNameForMethod(Class testClass, Method testMethod) { 24 | return DISPLAY_NAME_METHOD; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/description/DescriptionAnnotatedClassDynamicTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.description; 2 | 3 | import com.epam.reportportal.annotations.Description; 4 | import com.epam.reportportal.junit5.DescriptionTest; 5 | import org.junit.jupiter.api.DynamicTest; 6 | import org.junit.jupiter.api.TestFactory; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | import java.util.stream.Stream; 10 | 11 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 12 | 13 | @ExtendWith(DescriptionTest.TestExtension.class) 14 | @Description(DescriptionAnnotatedClassDynamicTest.TEST_DESCRIPTION_DYNAMIC_CLASS) 15 | public class DescriptionAnnotatedClassDynamicTest { 16 | public static final String TEST_DESCRIPTION_DYNAMIC_CLASS = "My test description on the dynamic class"; 17 | 18 | @TestFactory 19 | Stream testForTestFactory() { 20 | return Stream.of(dynamicTest("My dynamic test", () -> System.out.println("Inside dynamic test"))); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/description/DescriptionAnnotatedClassTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.description; 2 | 3 | import com.epam.reportportal.annotations.Description; 4 | import com.epam.reportportal.junit5.DescriptionTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @Description(DescriptionAnnotatedClassTest.TEST_DESCRIPTION_CLASS) 9 | @ExtendWith(DescriptionTest.TestExtension.class) 10 | public class DescriptionAnnotatedClassTest { 11 | public static final String TEST_DESCRIPTION_CLASS = "My test description on the class"; 12 | 13 | @Test 14 | public void testDescriptionTest() { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/description/DescriptionAnnotatedMethodAndClassDynamicTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.description; 2 | 3 | import com.epam.reportportal.annotations.Description; 4 | import com.epam.reportportal.junit5.DescriptionTest; 5 | import org.junit.jupiter.api.DynamicTest; 6 | import org.junit.jupiter.api.TestFactory; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | import java.util.stream.Stream; 10 | 11 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 12 | 13 | @ExtendWith(DescriptionTest.TestExtension.class) 14 | @Description(DescriptionAnnotatedClassDynamicTest.TEST_DESCRIPTION_DYNAMIC_CLASS) 15 | public class DescriptionAnnotatedMethodAndClassDynamicTest { 16 | @TestFactory 17 | @Description(DescriptionAnnotatedMethodDynamicTest.TEST_DESCRIPTION_DYNAMIC_METHOD) 18 | Stream testForTestFactory() { 19 | return Stream.of(dynamicTest("My dynamic test", () -> System.out.println("Inside dynamic test"))); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/description/DescriptionAnnotatedMethodAndClassTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.description; 2 | 3 | import com.epam.reportportal.annotations.Description; 4 | import com.epam.reportportal.junit5.DescriptionTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(DescriptionTest.TestExtension.class) 9 | @Description(DescriptionAnnotatedClassTest.TEST_DESCRIPTION_CLASS) 10 | public class DescriptionAnnotatedMethodAndClassTest { 11 | @Test 12 | @Description(DescriptionAnnotatedMethodTest.TEST_DESCRIPTION_METHOD) 13 | public void testDescriptionTest() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/description/DescriptionAnnotatedMethodDynamicTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.description; 2 | 3 | import com.epam.reportportal.annotations.Description; 4 | import com.epam.reportportal.junit5.DescriptionTest; 5 | import org.junit.jupiter.api.DynamicTest; 6 | import org.junit.jupiter.api.TestFactory; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | import java.util.stream.Stream; 10 | 11 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 12 | 13 | @ExtendWith(DescriptionTest.TestExtension.class) 14 | public class DescriptionAnnotatedMethodDynamicTest { 15 | public static final String TEST_DESCRIPTION_DYNAMIC_METHOD = "My test description on the dynamic method"; 16 | 17 | @TestFactory 18 | @Description(TEST_DESCRIPTION_DYNAMIC_METHOD) 19 | Stream testForTestFactory() { 20 | return Stream.of(dynamicTest("My dynamic test", () -> System.out.println("Inside dynamic test"))); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/description/DescriptionAnnotatedMethodTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.description; 2 | 3 | import com.epam.reportportal.annotations.Description; 4 | import com.epam.reportportal.junit5.DescriptionTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(DescriptionTest.TestExtension.class) 9 | public class DescriptionAnnotatedMethodTest { 10 | public static final String TEST_DESCRIPTION_METHOD = "My test description on the method"; 11 | 12 | @Test 13 | @Description(TEST_DESCRIPTION_METHOD) 14 | public void testDescriptionTest() { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/disabled/OneDisabledOneEnabledTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.disabled; 2 | 3 | import com.epam.reportportal.junit5.DisabledTestTest; 4 | import org.junit.jupiter.api.Disabled; 5 | import org.junit.jupiter.api.DisplayName; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | @ExtendWith(DisabledTestTest.DisabledTestExtension.class) 10 | public class OneDisabledOneEnabledTest { 11 | 12 | public static final String DISPLAY_NAME = "My enabled display name"; 13 | 14 | // JUnit 5 executes test in alphabetical order, so names matters 15 | @Disabled 16 | @Test 17 | void testADisabledTest() { 18 | System.out.println("disabled"); 19 | } 20 | 21 | @Test 22 | @DisplayName(DISPLAY_NAME) 23 | void testBEnabledTest() { 24 | System.out.println("enabled"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/disabled/OneDisabledTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.disabled; 2 | 3 | import com.epam.reportportal.junit5.DisabledTestTest; 4 | import org.junit.jupiter.api.Disabled; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(DisabledTestTest.DisabledTestExtension.class) 9 | public class OneDisabledTest { 10 | 11 | @Disabled 12 | @Test 13 | void disabledTest() { 14 | System.out.println("disabled"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/disabled/OneDisabledWithReasonDescriptionTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.disabled; 2 | 3 | import com.epam.reportportal.annotations.Description; 4 | import com.epam.reportportal.junit5.DisabledTestTest; 5 | import org.junit.jupiter.api.Disabled; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | @ExtendWith(DisabledTestTest.DisabledTestExtension.class) 10 | public class OneDisabledWithReasonDescriptionTest { 11 | public static final String TEST_DESCRIPTION_METHOD = "My test description on the method"; 12 | public static final String REASON = "My reason to disable test"; 13 | 14 | @Disabled(REASON) 15 | @Description(TEST_DESCRIPTION_METHOD) 16 | @Test 17 | void disabledTest() { 18 | System.out.println("disabled"); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/disabled/OneDisabledWithReasonTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.disabled; 2 | 3 | import com.epam.reportportal.junit5.DisabledTestTest; 4 | import org.junit.jupiter.api.Disabled; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(DisabledTestTest.DisabledTestExtension.class) 9 | public class OneDisabledWithReasonTest { 10 | 11 | public static final String REASON = "My reason to disable test"; 12 | 13 | @Disabled(REASON) 14 | @Test 15 | void disabledTest() { 16 | System.out.println("disabled"); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/displayname/DisplayNameAnnotatedClassDynamicTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.displayname; 2 | 3 | import com.epam.reportportal.annotations.DisplayName; 4 | import com.epam.reportportal.junit5.DisplayNameTest; 5 | import org.junit.jupiter.api.DynamicTest; 6 | import org.junit.jupiter.api.TestFactory; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | import java.util.stream.Stream; 10 | 11 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 12 | 13 | @ExtendWith(DisplayNameTest.TestExtension.class) 14 | @DisplayName(DisplayNameAnnotatedClassDynamicTest.TEST_DISPLAY_NAME_DYNAMIC_CLASS) 15 | public class DisplayNameAnnotatedClassDynamicTest { 16 | public static final String TEST_DISPLAY_NAME_DYNAMIC_CLASS = "My test displayName on the dynamic class"; 17 | 18 | @TestFactory 19 | Stream testForTestFactory() { 20 | return Stream.of(dynamicTest("My dynamic test", () -> System.out.println("Inside dynamic test"))); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/displayname/DisplayNameAnnotatedClassTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.displayname; 2 | 3 | import com.epam.reportportal.junit5.DisplayNameTest; 4 | import org.junit.jupiter.api.Test; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | 7 | @com.epam.reportportal.annotations.DisplayName(DisplayNameAnnotatedClassTest.TEST_DISPLAY_NAME_CLASS) 8 | @ExtendWith(DisplayNameTest.TestExtension.class) 9 | public class DisplayNameAnnotatedClassTest { 10 | public static final String TEST_DISPLAY_NAME_CLASS = "My display name"; 11 | 12 | @Test 13 | public void testDisplayNameTest() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/displayname/DisplayNameAnnotatedClassWithEmptyValueTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.displayname; 2 | 3 | import com.epam.reportportal.junit5.DisplayNameTest; 4 | import org.junit.jupiter.api.Test; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | 7 | @com.epam.reportportal.annotations.DisplayName(DisplayNameAnnotatedClassWithEmptyValueTest.TEST_DISPLAY_NAME_CLASS) 8 | @ExtendWith(DisplayNameTest.TestExtension.class) 9 | public class DisplayNameAnnotatedClassWithEmptyValueTest { 10 | public static final String TEST_DISPLAY_NAME_CLASS = ""; 11 | 12 | @Test 13 | public void testDisplayNameTest() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/displayname/DisplayNameAnnotatedMethodAndClassDynamicTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.displayname; 2 | 3 | import com.epam.reportportal.annotations.DisplayName; 4 | import com.epam.reportportal.junit5.DisplayNameTest; 5 | import org.junit.jupiter.api.DynamicTest; 6 | import org.junit.jupiter.api.TestFactory; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | import java.util.stream.Stream; 10 | 11 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 12 | 13 | @ExtendWith(DisplayNameTest.TestExtension.class) 14 | @DisplayName(DisplayNameAnnotatedClassDynamicTest.TEST_DISPLAY_NAME_DYNAMIC_CLASS) 15 | public class DisplayNameAnnotatedMethodAndClassDynamicTest { 16 | @TestFactory 17 | @DisplayName(DisplayNameAnnotatedMethodDynamicTest.TEST_DISPLAY_NAME_DYNAMIC_METHOD) 18 | Stream testForTestFactory() { 19 | return Stream.of(dynamicTest("My dynamic test", () -> System.out.println("Inside dynamic test"))); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/displayname/DisplayNameAnnotatedMethodAndClassTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.displayname; 2 | 3 | import com.epam.reportportal.annotations.DisplayName; 4 | import com.epam.reportportal.junit5.DisplayNameTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(DisplayNameTest.TestExtension.class) 9 | @DisplayName(DisplayNameAnnotatedClassTest.TEST_DISPLAY_NAME_CLASS) 10 | public class DisplayNameAnnotatedMethodAndClassTest { 11 | @Test 12 | @DisplayName(DisplayNameAnnotatedMethodTest.TEST_DISPLAY_NAME_METHOD) 13 | public void testDisplayNameTest() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/displayname/DisplayNameAnnotatedMethodDynamicTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.displayname; 2 | 3 | import com.epam.reportportal.annotations.DisplayName; 4 | import com.epam.reportportal.junit5.DisplayNameTest; 5 | import org.junit.jupiter.api.DynamicTest; 6 | import org.junit.jupiter.api.TestFactory; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | import java.util.stream.Stream; 10 | 11 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 12 | 13 | @ExtendWith(DisplayNameTest.TestExtension.class) 14 | public class DisplayNameAnnotatedMethodDynamicTest { 15 | public static final String TEST_DISPLAY_NAME_DYNAMIC_METHOD = "My test displayName on the dynamic method"; 16 | 17 | @TestFactory 18 | @DisplayName(TEST_DISPLAY_NAME_DYNAMIC_METHOD) 19 | Stream testForTestFactory() { 20 | return Stream.of(dynamicTest("My dynamic test", () -> System.out.println("Inside dynamic test"))); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/displayname/DisplayNameAnnotatedMethodTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.displayname; 2 | 3 | import com.epam.reportportal.annotations.DisplayName; 4 | import com.epam.reportportal.junit5.DisplayNameTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(DisplayNameTest.TestExtension.class) 9 | public class DisplayNameAnnotatedMethodTest { 10 | public static final String TEST_DISPLAY_NAME_METHOD = "My test displayName on the method"; 11 | 12 | @Test 13 | @DisplayName(TEST_DISPLAY_NAME_METHOD) 14 | public void testDisplayNameTest() { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/displayname/DisplayNameAnnotatedMethodWithEmptyValueTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.displayname; 2 | 3 | import com.epam.reportportal.annotations.DisplayName; 4 | import com.epam.reportportal.junit5.DisplayNameTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(DisplayNameTest.TestExtension.class) 9 | public class DisplayNameAnnotatedMethodWithEmptyValueTest { 10 | public static final String TEST_DISPLAY_NAME_METHOD = ""; 11 | 12 | @Test 13 | @DisplayName(TEST_DISPLAY_NAME_METHOD) 14 | public void testDisplayNameTest() { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/displayname/DisplayNameBothJunitAndRPAnnotatedClassDynamicTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.displayname; 2 | 3 | import com.epam.reportportal.annotations.DisplayName; 4 | import com.epam.reportportal.junit5.DisplayNameTest; 5 | import org.junit.jupiter.api.DynamicTest; 6 | import org.junit.jupiter.api.TestFactory; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | import java.util.stream.Stream; 10 | 11 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 12 | 13 | @ExtendWith(DisplayNameTest.TestExtension.class) 14 | @DisplayName(DisplayNameBothJunitAndRPAnnotatedClassDynamicTest.TEST_DISPLAY_NAME_DYNAMIC_CLASS) 15 | @org.junit.jupiter.api.DisplayName("Junit") 16 | public class DisplayNameBothJunitAndRPAnnotatedClassDynamicTest { 17 | public static final String TEST_DISPLAY_NAME_DYNAMIC_CLASS = "My test displayName on the dynamic class"; 18 | 19 | @TestFactory 20 | Stream testForTestFactory() { 21 | return Stream.of(dynamicTest("My dynamic test", () -> System.out.println("Inside dynamic test"))); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/displayname/DisplayNameBothJunitAndRPAnnotatedClassTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.displayname; 2 | 3 | import com.epam.reportportal.junit5.DisplayNameTest; 4 | import org.junit.jupiter.api.DisplayName; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @com.epam.reportportal.annotations.DisplayName(DisplayNameBothJunitAndRPAnnotatedClassTest.TEST_DISPLAY_NAME_CLASS) 9 | @ExtendWith(DisplayNameTest.TestExtension.class) 10 | @DisplayName("Junit") 11 | public class DisplayNameBothJunitAndRPAnnotatedClassTest { 12 | public static final String TEST_DISPLAY_NAME_CLASS = "My display name"; 13 | 14 | @Test 15 | public void testDisplayNameTest() { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/displayname/DisplayNameBothJunitAndRPAnnotatedMethodAndClassDynamicTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.displayname; 2 | 3 | import com.epam.reportportal.annotations.DisplayName; 4 | import com.epam.reportportal.junit5.DisplayNameTest; 5 | import org.junit.jupiter.api.DynamicTest; 6 | import org.junit.jupiter.api.TestFactory; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | import java.util.stream.Stream; 10 | 11 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 12 | 13 | @ExtendWith(DisplayNameTest.TestExtension.class) 14 | @DisplayName(DisplayNameAnnotatedClassDynamicTest.TEST_DISPLAY_NAME_DYNAMIC_CLASS) 15 | @org.junit.jupiter.api.DisplayName("Junit class") 16 | public class DisplayNameBothJunitAndRPAnnotatedMethodAndClassDynamicTest { 17 | @TestFactory 18 | @DisplayName(DisplayNameAnnotatedMethodDynamicTest.TEST_DISPLAY_NAME_DYNAMIC_METHOD) 19 | @org.junit.jupiter.api.DisplayName("Junit method") 20 | Stream testForTestFactory() { 21 | return Stream.of(dynamicTest("My dynamic test", () -> System.out.println("Inside dynamic test"))); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/displayname/DisplayNameBothJunitAndRPAnnotatedMethodAndClassTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.displayname; 2 | 3 | import com.epam.reportportal.annotations.DisplayName; 4 | import com.epam.reportportal.junit5.DisplayNameTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(DisplayNameTest.TestExtension.class) 9 | @DisplayName(DisplayNameAnnotatedClassTest.TEST_DISPLAY_NAME_CLASS) 10 | @org.junit.jupiter.api.DisplayName("Junit class") 11 | public class DisplayNameBothJunitAndRPAnnotatedMethodAndClassTest { 12 | @Test 13 | @DisplayName(DisplayNameAnnotatedMethodTest.TEST_DISPLAY_NAME_METHOD) 14 | @org.junit.jupiter.api.DisplayName("Junit method") 15 | public void testDisplayNameTest() { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/displayname/DisplayNameBothJunitAndRPAnnotatedMethodDynamicTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.displayname; 2 | 3 | import com.epam.reportportal.annotations.DisplayName; 4 | import com.epam.reportportal.junit5.DisplayNameTest; 5 | import org.junit.jupiter.api.DynamicTest; 6 | import org.junit.jupiter.api.TestFactory; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | import java.util.stream.Stream; 10 | 11 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 12 | 13 | @ExtendWith(DisplayNameTest.TestExtension.class) 14 | public class DisplayNameBothJunitAndRPAnnotatedMethodDynamicTest { 15 | public static final String TEST_DISPLAY_NAME_DYNAMIC_METHOD = "My test displayName on the dynamic method"; 16 | 17 | @TestFactory 18 | @DisplayName(TEST_DISPLAY_NAME_DYNAMIC_METHOD) 19 | @org.junit.jupiter.api.DisplayName("Junit") 20 | Stream testForTestFactory() { 21 | return Stream.of(dynamicTest("My dynamic test", () -> System.out.println("Inside dynamic test"))); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/displayname/DisplayNameBothJunitAndRPAnnotatedMethodTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.displayname; 2 | 3 | import com.epam.reportportal.annotations.DisplayName; 4 | import com.epam.reportportal.junit5.DisplayNameTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(DisplayNameTest.TestExtension.class) 9 | public class DisplayNameBothJunitAndRPAnnotatedMethodTest { 10 | public static final String TEST_DISPLAY_NAME_METHOD = "My test displayName on the method"; 11 | 12 | @Test 13 | @DisplayName(TEST_DISPLAY_NAME_METHOD) 14 | @org.junit.jupiter.api.DisplayName("Junit") 15 | public void testDisplayNameTest() { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/issue/DynamicIssueTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.issue; 2 | 3 | import com.epam.reportportal.annotations.Issue; 4 | import com.epam.reportportal.junit5.IssueReportingTest; 5 | import org.junit.jupiter.api.DynamicTest; 6 | import org.junit.jupiter.api.TestFactory; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | import java.util.stream.Stream; 10 | 11 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 12 | 13 | @ExtendWith(IssueReportingTest.TestExtension.class) 14 | public class DynamicIssueTest { 15 | public static final String FAILURE_MESSAGE = "This test is expected to fail"; 16 | 17 | @TestFactory 18 | @Issue(value = "ab001", comment = FAILURE_MESSAGE) 19 | Stream testForTestFactory() { 20 | return Stream.of(dynamicTest( 21 | "My dynamic test", () -> { 22 | throw new IllegalStateException(FAILURE_MESSAGE); 23 | } 24 | )); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/issue/ParameterizedWithOneIssueTest.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.junit5.features.issue; 18 | 19 | import com.epam.reportportal.annotations.Issue; 20 | import com.epam.reportportal.annotations.TestFilter; 21 | import com.epam.reportportal.annotations.TestParamFilter; 22 | import com.epam.reportportal.junit5.IssueReportingTest; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.junit.jupiter.params.ParameterizedTest; 25 | import org.junit.jupiter.params.provider.ValueSource; 26 | 27 | @ExtendWith(IssueReportingTest.TestExtension.class) 28 | public class ParameterizedWithOneIssueTest { 29 | 30 | public static final String FAILURE_MESSAGE = "This parameterized test is expected to fail: "; 31 | public static final String ISSUE_MESSAGE = "This test is expected to fail"; 32 | 33 | @ParameterizedTest 34 | @ValueSource(booleans = { true, false }) 35 | @Issue(value = "ab001", comment = ISSUE_MESSAGE, filter = @TestFilter(param = { @TestParamFilter(valueStartsWith = "false") })) 36 | public void failureTest(boolean param) { 37 | throw new IllegalStateException(FAILURE_MESSAGE + param); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/issue/ParameterizedWithTwoIssueTest.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.junit5.features.issue; 18 | 19 | import com.epam.reportportal.annotations.Issue; 20 | import com.epam.reportportal.annotations.TestFilter; 21 | import com.epam.reportportal.annotations.TestParamFilter; 22 | import com.epam.reportportal.junit5.IssueReportingTest; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.junit.jupiter.params.ParameterizedTest; 25 | import org.junit.jupiter.params.provider.ValueSource; 26 | 27 | @ExtendWith(IssueReportingTest.TestExtension.class) 28 | public class ParameterizedWithTwoIssueTest { 29 | 30 | public static final String FAILURE_MESSAGE = "This parameterized test is expected to fail: "; 31 | public static final String ISSUE_MESSAGE = "This test is expected to fail"; 32 | 33 | @ParameterizedTest 34 | @ValueSource(booleans = { true, false }) 35 | @Issue(value = "ab001", comment = ISSUE_MESSAGE, filter = @TestFilter(param = { @TestParamFilter(valueStartsWith = "true") })) 36 | @Issue(value = "pb001", comment = ISSUE_MESSAGE, filter = @TestFilter(param = { @TestParamFilter(valueStartsWith = "false") })) 37 | public void failureTest(boolean param) { 38 | throw new IllegalStateException(FAILURE_MESSAGE + param); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/issue/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.junit5.features.issue; 18 | 19 | import com.epam.reportportal.annotations.Issue; 20 | import com.epam.reportportal.junit5.IssueReportingTest; 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | 24 | @ExtendWith(IssueReportingTest.TestExtension.class) 25 | public class SimpleIssueTest { 26 | 27 | public static final String FAILURE_MESSAGE = "This test is expected to fail"; 28 | 29 | @Test 30 | @Issue(value = "pb001", comment = FAILURE_MESSAGE) 31 | public void failureTest() { 32 | throw new IllegalStateException(FAILURE_MESSAGE); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/issue/SimpleSkippedIssueTest.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.junit5.features.issue; 18 | 19 | import com.epam.reportportal.annotations.Issue; 20 | import com.epam.reportportal.junit5.IssueReportingTest; 21 | import org.junit.jupiter.api.Disabled; 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | 25 | @ExtendWith(IssueReportingTest.TestExtension.class) 26 | public class SimpleSkippedIssueTest { 27 | 28 | public static final String FAILURE_MESSAGE = "This test is expected to fail"; 29 | 30 | @Test 31 | @Issue(value = "pb001", comment = FAILURE_MESSAGE) 32 | @Disabled 33 | public void failureTest() { 34 | throw new IllegalStateException(FAILURE_MESSAGE); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/issue/SimpleTwoIssuesTest.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.junit5.features.issue; 18 | 19 | import com.epam.reportportal.annotations.Issue; 20 | import com.epam.reportportal.junit5.IssueReportingTest; 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | 24 | @ExtendWith(IssueReportingTest.TestExtension.class) 25 | public class SimpleTwoIssuesTest { 26 | 27 | public static final String FAILURE_MESSAGE = "This test is expected to fail"; 28 | 29 | @Test 30 | @Issue(value = "ab001", comment = FAILURE_MESSAGE) 31 | @Issue(value = "pb001", comment = FAILURE_MESSAGE) 32 | public void failureTest() { 33 | throw new IllegalStateException(FAILURE_MESSAGE); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/issue/TwoDynamicIssueTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.issue; 2 | 3 | import com.epam.reportportal.annotations.Issue; 4 | import com.epam.reportportal.junit5.IssueReportingTest; 5 | import org.junit.jupiter.api.DynamicTest; 6 | import org.junit.jupiter.api.TestFactory; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | import java.util.stream.Stream; 10 | 11 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 12 | 13 | @ExtendWith(IssueReportingTest.TestExtension.class) 14 | public class TwoDynamicIssueTest { 15 | public static final String FAILURE_MESSAGE = "This test is expected to fail"; 16 | 17 | @TestFactory 18 | @Issue(value = "ab001", comment = FAILURE_MESSAGE) 19 | Stream testForTestFactory() { 20 | return Stream.of( 21 | dynamicTest( 22 | "My dynamic test", () -> { 23 | throw new IllegalStateException(FAILURE_MESSAGE); 24 | } 25 | ), dynamicTest( 26 | "My dynamic test 2", () -> { 27 | throw new IllegalStateException(FAILURE_MESSAGE); 28 | } 29 | ) 30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/issue/TwoDynamicTwoIssueTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.issue; 2 | 3 | import com.epam.reportportal.annotations.Issue; 4 | import com.epam.reportportal.annotations.TestFilter; 5 | import com.epam.reportportal.annotations.TestNameFilter; 6 | import com.epam.reportportal.junit5.IssueReportingTest; 7 | import org.junit.jupiter.api.DynamicTest; 8 | import org.junit.jupiter.api.TestFactory; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | 11 | import java.util.stream.Stream; 12 | 13 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 14 | 15 | @ExtendWith(IssueReportingTest.TestExtension.class) 16 | public class TwoDynamicTwoIssueTest { 17 | public static final String FAILURE_MESSAGE = "This test is expected to fail"; 18 | 19 | @TestFactory 20 | @Issue(value = "ab001", comment = FAILURE_MESSAGE, filter = { @TestFilter(name = @TestNameFilter(endsWith = "test")) }) 21 | @Issue(value = "pb001", comment = FAILURE_MESSAGE, filter = { @TestFilter(name = @TestNameFilter(contains = "test 2")) }) 22 | Stream testForTestFactory() { 23 | return Stream.of( 24 | dynamicTest( 25 | "My dynamic test", () -> { 26 | throw new IllegalStateException(FAILURE_MESSAGE); 27 | } 28 | ), dynamicTest( 29 | "My dynamic test 2", () -> { 30 | throw new IllegalStateException(FAILURE_MESSAGE); 31 | } 32 | ) 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/lasterrorlog/ErrorLastLogFeatureWithAssertionErrorTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.lasterrorlog; 2 | 3 | import com.epam.reportportal.annotations.Description; 4 | import com.epam.reportportal.junit5.ErrorLastLogTest; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | @ExtendWith(ErrorLastLogTest.ErrorDescriptionTestExtension.class) 10 | public class ErrorLastLogFeatureWithAssertionErrorTest { 11 | 12 | @Test 13 | @Description("0 and 1 is not equal") 14 | public void testWithAssertException() { 15 | Assertions.assertEquals(0, 1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/lasterrorlog/ErrorLastLogFeatureWithAssertionPassedTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.lasterrorlog; 2 | 3 | import com.epam.reportportal.annotations.Description; 4 | import com.epam.reportportal.annotations.Step; 5 | import com.epam.reportportal.junit5.ErrorLastLogTest; 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.Test; 8 | import org.junit.jupiter.api.extension.ExtendWith; 9 | 10 | @ExtendWith(ErrorLastLogTest.ErrorDescriptionTestExtension.class) 11 | public class ErrorLastLogFeatureWithAssertionPassedTest { 12 | 13 | @Test 14 | @Description("successful test") 15 | public void testWithDescriptionAndPassed() { 16 | login(); 17 | Assertions.assertTrue(true); 18 | } 19 | 20 | @Step 21 | public void login() { 22 | System.out.println("Login successful"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/lasterrorlog/ErrorLastLogFeatureWithExceptionTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.lasterrorlog; 2 | 3 | import com.epam.reportportal.junit5.ErrorLastLogTest; 4 | import org.junit.jupiter.api.Test; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | 7 | @ExtendWith(ErrorLastLogTest.ErrorDescriptionTestExtension.class) 8 | public class ErrorLastLogFeatureWithExceptionTest { 9 | 10 | @Test 11 | public void testWithException() { 12 | throw new RuntimeException("Critical error"); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/lasterrorlog/ErrorLastLogFeatureWithStepTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.lasterrorlog; 2 | 3 | import com.epam.reportportal.annotations.Description; 4 | import com.epam.reportportal.annotations.Step; 5 | import com.epam.reportportal.junit5.ErrorLastLogTest; 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.Test; 8 | import org.junit.jupiter.api.extension.ExtendWith; 9 | 10 | import java.util.NoSuchElementException; 11 | 12 | @ExtendWith(ErrorLastLogTest.ErrorDescriptionTestExtension.class) 13 | public class ErrorLastLogFeatureWithStepTest { 14 | 15 | @Test 16 | @Description("Login issue") 17 | public void testWithStepError() { 18 | enterCredentials(); 19 | System.out.println("Username is not correct"); 20 | loginWithException(); 21 | Assertions.assertTrue(Boolean.TRUE); 22 | } 23 | 24 | @Step 25 | @Description("Credentials entered") 26 | public void enterCredentials() { 27 | Assertions.assertTrue(Boolean.TRUE); 28 | } 29 | 30 | @Step 31 | public void loginWithException() { 32 | throw new NoSuchElementException("Error message"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/nested/JunitClassNestedTests.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.nested; 2 | 3 | import com.epam.reportportal.junit5.JunitNestedTestTest; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.Nested; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | @ExtendWith(JunitNestedTestTest.TestExtension.class) 12 | public class JunitClassNestedTests { 13 | private static final Logger LOGGER = LoggerFactory.getLogger(JunitClassNestedTests.class); 14 | 15 | @Nested 16 | class Outer { 17 | @Nested 18 | class Inner { 19 | @Test 20 | void aTest() { 21 | LOGGER.info("executing aTest"); 22 | Assertions.assertEquals(1, 1); 23 | } 24 | 25 | @Test 26 | void anotherTest() { 27 | LOGGER.info("executing anotherTest"); 28 | Assertions.assertEquals(1, 1); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/nested/JunitClassNestedTestsLongDepth.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.nested; 2 | 3 | import com.epam.reportportal.junit5.JunitNestedTestTest; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.Nested; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | @ExtendWith(JunitNestedTestTest.TestExtension.class) 12 | public class JunitClassNestedTestsLongDepth { 13 | private static final Logger LOGGER = LoggerFactory.getLogger(JunitClassNestedTests.class); 14 | 15 | @Nested 16 | class Outer { 17 | @Nested 18 | class Inner { 19 | @Nested 20 | class TestOuter { 21 | @Nested 22 | class TestInner { 23 | @Test 24 | void aTest() { 25 | LOGGER.info("executing aTest"); 26 | Assertions.assertEquals(1, 1); 27 | } 28 | } 29 | } 30 | 31 | @Test 32 | void bTest() { 33 | LOGGER.info("executing bTest"); 34 | Assertions.assertEquals(1, 1); 35 | } 36 | } 37 | } 38 | 39 | @Nested 40 | class SecondOuter { 41 | @Nested 42 | class SecondInner { 43 | @Nested 44 | class SecondTestOuter { 45 | @Nested 46 | class SecondTestInner { 47 | @Test 48 | void cTest() { 49 | LOGGER.info("executing cTest"); 50 | Assertions.assertEquals(1, 1); 51 | } 52 | } 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/nested/JunitDynamicNestedTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.nested; 2 | 3 | import com.epam.reportportal.junit5.JunitNestedTestTest; 4 | import org.junit.jupiter.api.DynamicContainer; 5 | import org.junit.jupiter.api.DynamicNode; 6 | import org.junit.jupiter.api.DynamicTest; 7 | import org.junit.jupiter.api.TestFactory; 8 | import org.junit.jupiter.api.extension.ExtendWith; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | import java.util.stream.Stream; 13 | 14 | import static org.hamcrest.MatcherAssert.assertThat; 15 | import static org.hamcrest.Matchers.*; 16 | 17 | @ExtendWith(JunitNestedTestTest.TestExtension.class) 18 | public class JunitDynamicNestedTest { 19 | private static final Logger LOGGER = LoggerFactory.getLogger(JunitDynamicNestedTest.class); 20 | 21 | @TestFactory 22 | Stream dynamicTestsWithContainers() { 23 | return Stream.of("A", "B").map(input -> DynamicContainer.dynamicContainer( 24 | input, Stream.of(DynamicContainer.dynamicContainer( 25 | input + " inner container", Stream.of( 26 | DynamicTest.dynamicTest( 27 | input + " Test 1", () -> { 28 | LOGGER.info("Checking length == 1"); 29 | assertThat(input, hasLength(1)); 30 | } 31 | ), DynamicTest.dynamicTest( 32 | input + " Test 2", () -> { 33 | LOGGER.info("Checking not empty"); 34 | assertThat(input, not(emptyOrNullString())); 35 | } 36 | ) 37 | ) 38 | )) 39 | )); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/nested/NestedStepFeatureFailedTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.nested; 2 | 3 | import com.epam.reportportal.annotations.Step; 4 | import com.epam.reportportal.junit5.NestedStepTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | import static com.epam.reportportal.junit5.NestedStepTest.NESTED_STEP_NAME_TEMPLATE; 9 | import static com.epam.reportportal.junit5.NestedStepTest.PARAM; 10 | 11 | /** 12 | * @author Ivan Budayeu 13 | */ 14 | @ExtendWith(NestedStepTest.TestExtension.class) 15 | public class NestedStepFeatureFailedTest { 16 | 17 | @Test 18 | public void test() { 19 | failedMethod(PARAM); 20 | } 21 | 22 | @Step(NESTED_STEP_NAME_TEMPLATE) 23 | public void failedMethod(String param) { 24 | throw new RuntimeException("Some random error"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/nested/NestedStepFeaturePassedTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.nested; 2 | 3 | import com.epam.reportportal.annotations.Step; 4 | import com.epam.reportportal.junit5.NestedStepTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | import static com.epam.reportportal.junit5.NestedStepTest.NESTED_STEP_NAME_TEMPLATE; 9 | import static com.epam.reportportal.junit5.NestedStepTest.PARAM; 10 | 11 | /** 12 | * @author Ivan Budayeu 13 | */ 14 | @ExtendWith(NestedStepTest.TestExtension.class) 15 | public class NestedStepFeaturePassedTest { 16 | @Test 17 | public void test() { 18 | method(PARAM); 19 | } 20 | 21 | @Step(NESTED_STEP_NAME_TEMPLATE) 22 | public void method(String param) { 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/nested/NestedStepMultiLevelTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.nested; 2 | 3 | import com.epam.reportportal.annotations.Step; 4 | import com.epam.reportportal.junit5.NestedStepTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | import static com.epam.reportportal.junit5.NestedStepTest.INNER_METHOD_NAME_TEMPLATE; 9 | import static com.epam.reportportal.junit5.NestedStepTest.METHOD_WITH_INNER_METHOD_NAME_TEMPLATE; 10 | 11 | /** 12 | * @author Ivan Budayeu 13 | */ 14 | @ExtendWith(NestedStepTest.TestExtension.class) 15 | public class NestedStepMultiLevelTest { 16 | 17 | @Test 18 | public void test() { 19 | methodWithInnerMethod(); 20 | } 21 | 22 | @Step(METHOD_WITH_INNER_METHOD_NAME_TEMPLATE) 23 | public void methodWithInnerMethod() { 24 | innerMethod(); 25 | } 26 | 27 | @Step(INNER_METHOD_NAME_TEMPLATE) 28 | public void innerMethod() { 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/nested/NestedStepWithBeforeEachTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.nested; 2 | 3 | import com.epam.reportportal.annotations.Step; 4 | import com.epam.reportportal.junit5.NestedStepTest; 5 | import com.epam.reportportal.util.test.CommonUtils; 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.Test; 8 | import org.junit.jupiter.api.extension.ExtendWith; 9 | 10 | import static com.epam.reportportal.junit5.NestedStepTest.NESTED_STEP_NAME_TEMPLATE; 11 | import static com.epam.reportportal.junit5.NestedStepTest.PARAM; 12 | 13 | /** 14 | * @author Ivan Budayeu 15 | */ 16 | @ExtendWith(NestedStepTest.TestExtension.class) 17 | public class NestedStepWithBeforeEachTest { 18 | 19 | @BeforeEach 20 | public void before() throws InterruptedException { 21 | method(PARAM); 22 | } 23 | 24 | @Test() 25 | public void test() { 26 | 27 | } 28 | 29 | @Step(NESTED_STEP_NAME_TEMPLATE) 30 | public void method(String param) throws InterruptedException { 31 | Thread.sleep(CommonUtils.MINIMAL_TEST_PAUSE); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/parameters/CsvParametersTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.parameters; 2 | 3 | import com.epam.reportportal.junit5.ParametersTest; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.junit.jupiter.params.ParameterizedTest; 6 | import org.junit.jupiter.params.provider.CsvSource; 7 | 8 | @ExtendWith(ParametersTest.ParameterTestExtension.class) 9 | public class CsvParametersTest { 10 | 11 | @ParameterizedTest 12 | @CsvSource({ "one", "two, three" }) 13 | public void testParameters(String param) { 14 | System.out.println("Csv parameter test: " + param); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/parameters/EnumParametersFailedTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.parameters; 2 | 3 | import com.epam.reportportal.junit5.ParametersTest; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | import org.junit.jupiter.params.ParameterizedTest; 7 | import org.junit.jupiter.params.provider.EnumSource; 8 | 9 | @ExtendWith(ParametersTest.ParameterTestExtension.class) 10 | public class EnumParametersFailedTest { 11 | 12 | public enum TestParams { 13 | ONE, 14 | TWO 15 | } 16 | 17 | @ParameterizedTest 18 | @EnumSource(TestParams.class) 19 | public void testParameters(TestParams param) { 20 | System.out.println("Test: " + param.name()); 21 | if (param == TestParams.ONE) { 22 | Assertions.fail("Failure parameter passed: " + param); 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/parameters/EnumParametersTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.parameters; 2 | 3 | import com.epam.reportportal.junit5.ParametersTest; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.junit.jupiter.params.ParameterizedTest; 6 | import org.junit.jupiter.params.provider.EnumSource; 7 | 8 | @ExtendWith(ParametersTest.ParameterTestExtension.class) 9 | public class EnumParametersTest { 10 | 11 | public enum TestParams { 12 | ONE, 13 | TWO 14 | } 15 | 16 | @ParameterizedTest 17 | @EnumSource(TestParams.class) 18 | public void testParameters(TestParams param) { 19 | System.out.println("Test: " + param.name()); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/parameters/NullParameterTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.parameters; 2 | 3 | import com.epam.reportportal.junit5.ParametersTest; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.junit.jupiter.params.ParameterizedTest; 6 | import org.junit.jupiter.params.provider.NullSource; 7 | import org.junit.jupiter.params.provider.ValueSource; 8 | 9 | @ExtendWith(ParametersTest.ParameterTestExtension.class) 10 | public class NullParameterTest { 11 | 12 | @ParameterizedTest 13 | @NullSource 14 | @ValueSource(strings = { "one" }) 15 | public void testParameters(String param) { 16 | System.out.println("Csv parameter test: " + param); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/parameters/ParameterNamesNotAllNamedTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.parameters; 2 | 3 | import com.epam.reportportal.annotations.ParameterKey; 4 | import com.epam.reportportal.junit5.ParametersTest; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | import org.junit.jupiter.params.ParameterizedTest; 7 | import org.junit.jupiter.params.provider.CsvSource; 8 | 9 | @ExtendWith(ParametersTest.ParameterTestExtension.class) 10 | public class ParameterNamesNotAllNamedTest { 11 | public static final String SECOND_PARAMETER_NAME = "second_parameter"; 12 | 13 | @ParameterizedTest 14 | @CsvSource({ "1, two", "3, four" }) 15 | public void testTwoParameters(int param1, @ParameterKey(SECOND_PARAMETER_NAME) String param2) { 16 | System.out.println("Two parameters test: " + param1 + " - " + param2); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/parameters/ParameterNamesTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.parameters; 2 | 3 | import com.epam.reportportal.annotations.ParameterKey; 4 | import com.epam.reportportal.junit5.ParametersTest; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | import org.junit.jupiter.params.ParameterizedTest; 7 | import org.junit.jupiter.params.provider.CsvSource; 8 | 9 | @ExtendWith(ParametersTest.ParameterTestExtension.class) 10 | public class ParameterNamesTest { 11 | 12 | public static final String FIRST_PARAMETER_NAME = "first_parameter"; 13 | public static final String SECOND_PARAMETER_NAME = "second_parameter"; 14 | 15 | @ParameterizedTest 16 | @CsvSource({ "one, two", "three, four" }) 17 | public void testTwoParameters(@ParameterKey(FIRST_PARAMETER_NAME) String param1, @ParameterKey(SECOND_PARAMETER_NAME) String param2) { 18 | System.out.println("Two parameters test: " + param1 + " - " + param2); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/parameters/TwoParametersTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.parameters; 2 | 3 | import com.epam.reportportal.junit5.ParametersTest; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.junit.jupiter.params.ParameterizedTest; 6 | import org.junit.jupiter.params.provider.CsvSource; 7 | 8 | @ExtendWith(ParametersTest.ParameterTestExtension.class) 9 | public class TwoParametersTest { 10 | 11 | @ParameterizedTest 12 | @CsvSource({ "one, two", "three, four" }) 13 | public void testTwoParameters(String param1, String param2) { 14 | System.out.println("Two parameters test: " + param1 + " - " + param2); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/skipped/AfterEachFailedTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.skipped; 2 | 3 | import com.epam.reportportal.junit5.miscellaneous.FailedBeforeEachReportsSkippedTestTest; 4 | import org.junit.jupiter.api.AfterEach; 5 | import org.junit.jupiter.api.BeforeEach; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | @ExtendWith(FailedBeforeEachReportsSkippedTestTest.SkippedTestExtension.class) 10 | public class AfterEachFailedTest { 11 | 12 | @BeforeEach 13 | public void beforeEachFailed() { 14 | System.out.println("Before each"); 15 | } 16 | 17 | @Test 18 | public void testAfterEachFailed() { 19 | System.out.println("Test: testAfterEachFailed"); 20 | } 21 | 22 | @AfterEach 23 | public void afterEachFailed() { 24 | throw new IllegalStateException("After each"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/skipped/AssertJAssumptionFailedTest.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.junit5.features.skipped; 18 | 19 | import com.epam.reportportal.junit5.AssumptionsTest; 20 | import org.assertj.core.api.Assumptions; 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | 24 | @ExtendWith(AssumptionsTest.AssumptionsTestExtension.class) 25 | public class AssertJAssumptionFailedTest { 26 | 27 | @Test 28 | public void testAssumptionFailed() { 29 | Assumptions.assumeThat(true).isFalse(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/skipped/AssumptionFailedTest.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.junit5.features.skipped; 18 | 19 | import com.epam.reportportal.junit5.AssumptionsTest; 20 | import org.junit.jupiter.api.Assumptions; 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | 24 | @ExtendWith(AssumptionsTest.AssumptionsTestExtension.class) 25 | public class AssumptionFailedTest { 26 | 27 | @Test 28 | public void testAssumptionFailed() { 29 | //noinspection ConstantConditions 30 | Assumptions.assumeFalse(true, "Test failed assumption"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/skipped/BeforeEachAssumptionFailedTest.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.junit5.features.skipped; 18 | 19 | import com.epam.reportportal.junit5.AssumptionsTest; 20 | import org.junit.jupiter.api.Assumptions; 21 | import org.junit.jupiter.api.BeforeEach; 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | 25 | @ExtendWith(AssumptionsTest.AssumptionsTestExtension.class) 26 | public class BeforeEachAssumptionFailedTest { 27 | 28 | @BeforeEach 29 | public void setup() { 30 | //noinspection ConstantConditions 31 | Assumptions.assumeFalse(true, "Test failed assumption"); 32 | } 33 | 34 | @Test 35 | public void testBeforeEachAssumptionFailed() { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/skipped/BeforeEachFailedParametrizedTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.skipped; 2 | 3 | import com.epam.reportportal.junit5.miscellaneous.FailedBeforeEachReportsSkippedTestTest; 4 | import org.junit.jupiter.api.BeforeEach; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | import org.junit.jupiter.params.ParameterizedTest; 7 | import org.junit.jupiter.params.provider.EnumSource; 8 | 9 | @ExtendWith(FailedBeforeEachReportsSkippedTestTest.SkippedTestExtension.class) 10 | public class BeforeEachFailedParametrizedTest { 11 | 12 | public enum TestParams { 13 | ONE, 14 | TWO 15 | } 16 | 17 | @BeforeEach 18 | public void beforeEachFailed() { 19 | throw new IllegalStateException("Before each"); 20 | } 21 | 22 | @ParameterizedTest 23 | @EnumSource(TestParams.class) 24 | public void testBeforeEachFailed(TestParams param) { 25 | System.out.println("Test: testBeforeEachFailed - " + param.name()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/skipped/BeforeEachFailedTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.skipped; 2 | 3 | import com.epam.reportportal.junit5.miscellaneous.FailedBeforeEachReportsSkippedTestTest; 4 | import org.junit.jupiter.api.BeforeEach; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | @ExtendWith(FailedBeforeEachReportsSkippedTestTest.SkippedTestExtension.class) 9 | public class BeforeEachFailedTest { 10 | 11 | @BeforeEach 12 | public void beforeEachFailed() { 13 | throw new IllegalStateException("Before each"); 14 | } 15 | 16 | @Test 17 | public void testBeforeEachFailed() { 18 | System.out.println("Test: testBeforeEachFailed"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/skipped/BeforeEachFailedWithAfterEachTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.features.skipped; 2 | 3 | import com.epam.reportportal.junit5.miscellaneous.FailedBeforeEachSkippedTestOrderTest; 4 | import org.junit.jupiter.api.AfterEach; 5 | import org.junit.jupiter.api.BeforeEach; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | 9 | @ExtendWith(FailedBeforeEachSkippedTestOrderTest.SkippedTestExtension.class) 10 | public class BeforeEachFailedWithAfterEachTest { 11 | @BeforeEach 12 | public void beforeEachFailed() throws InterruptedException { 13 | Thread.sleep(2); 14 | throw new IllegalStateException("Before each"); 15 | } 16 | 17 | @Test 18 | public void testBeforeEachFailed() { 19 | System.out.println("Test: testBeforeEachFailed"); 20 | } 21 | 22 | @AfterEach 23 | public void afterEach() { 24 | System.out.println("After Each"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/skipped/Junit4AssumptionFailedTest.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.junit5.features.skipped; 18 | 19 | import com.epam.reportportal.junit5.AssumptionsTest; 20 | import org.junit.AssumptionViolatedException; 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | 24 | @ExtendWith(AssumptionsTest.AssumptionsTestExtension.class) 25 | public class Junit4AssumptionFailedTest { 26 | 27 | @Test 28 | public void testAssumptionFailed() { 29 | throw new AssumptionViolatedException("Test"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/skipped/Junit4ExtendedAssumptionFailedTest.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.junit5.features.skipped; 18 | 19 | import com.epam.reportportal.junit5.AssumptionsTest; 20 | import org.junit.AssumptionViolatedException; 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | 24 | @ExtendWith(AssumptionsTest.AssumptionsTestExtension.class) 25 | public class Junit4ExtendedAssumptionFailedTest { 26 | 27 | private static class MyAssumptionException extends AssumptionViolatedException { 28 | public MyAssumptionException(String message) { 29 | super(message); 30 | } 31 | } 32 | 33 | @Test 34 | public void testAssumptionFailed() { 35 | throw new MyAssumptionException("Test"); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/step/ManualStepReporterFeatureTest.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.junit5.features.step; 18 | 19 | import com.epam.reportportal.junit5.StepReporterTest; 20 | import com.epam.reportportal.listeners.ItemStatus; 21 | import com.epam.reportportal.service.Launch; 22 | import com.epam.reportportal.service.step.StepReporter; 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | 28 | import java.io.File; 29 | 30 | /** 31 | * @author Ihar Kahadouski 32 | */ 33 | @ExtendWith(StepReporterTest.TestExtension.class) 34 | public class ManualStepReporterFeatureTest { 35 | 36 | public static final String FIRST_NAME = "I am the first nested step"; 37 | public static final String SECOND_NAME = "I am the second nested step"; 38 | public static final String THIRD_NAME = "I am the third nested step"; 39 | 40 | private static final Logger LOGGER = LoggerFactory.getLogger(ManualStepReporterFeatureTest.class); 41 | 42 | @Test 43 | public void manualStepTest() throws InterruptedException { 44 | 45 | StepReporter stepReporter = Launch.currentLaunch().getStepReporter(); 46 | stepReporter.sendStep(FIRST_NAME); 47 | LOGGER.info("First info log of the first step"); 48 | LOGGER.info("Second info log of the first step"); 49 | Thread.sleep(100); 50 | 51 | stepReporter.sendStep(SECOND_NAME); 52 | LOGGER.error("First error log of the second step"); 53 | 54 | Thread.sleep(100); 55 | stepReporter.sendStep(ItemStatus.FAILED, THIRD_NAME, new File("pug/unlucky.jpg")); 56 | LOGGER.error("Second error log of the second step"); 57 | 58 | Thread.sleep(100); 59 | stepReporter.finishPreviousStep(); 60 | 61 | LOGGER.error("Main test method error log"); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/step/ManualStepReporterSimpleTest.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.junit5.features.step; 18 | 19 | import com.epam.reportportal.junit5.StepReporterTest; 20 | import com.epam.reportportal.service.Launch; 21 | import com.epam.reportportal.service.step.StepReporter; 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | 27 | @ExtendWith(StepReporterTest.TestExtension.class) 28 | public class ManualStepReporterSimpleTest { 29 | 30 | public static final String FIRST_NAME = "I am the first nested step"; 31 | 32 | private static final Logger LOGGER = LoggerFactory.getLogger(ManualStepReporterSimpleTest.class); 33 | 34 | @Test 35 | public void manualStepTest() { 36 | 37 | StepReporter stepReporter = Launch.currentLaunch().getStepReporter(); 38 | 39 | stepReporter.sendStep(FIRST_NAME); 40 | LOGGER.info("Inside first nested step"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/testcaseid/SingleDynamicAnnotatedTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 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.junit5.features.testcaseid; 18 | 19 | import com.epam.reportportal.annotations.TestCaseId; 20 | import com.epam.reportportal.junit5.TestCaseIdTest; 21 | import org.junit.jupiter.api.DynamicTest; 22 | import org.junit.jupiter.api.TestFactory; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | 25 | import java.util.UUID; 26 | import java.util.stream.Stream; 27 | 28 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 29 | 30 | /** 31 | * @author Ihar Kahadouski 32 | */ 33 | @ExtendWith(TestCaseIdTest.TestCaseIdExtension.class) 34 | public class SingleDynamicAnnotatedTest { 35 | 36 | public static final String TEST_CASE_DISPLAY_NAME = UUID.randomUUID().toString(); 37 | public static final String TEST_CASE_ID_VALUE = "test-case-id"; 38 | 39 | @TestFactory 40 | @TestCaseId(TEST_CASE_ID_VALUE) 41 | Stream testForTestFactory() { 42 | return Stream.of(dynamicTest(TEST_CASE_DISPLAY_NAME, () -> System.out.println("Test factory test: " + TEST_CASE_DISPLAY_NAME))); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/testcaseid/SingleDynamicTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 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.junit5.features.testcaseid; 18 | 19 | import com.epam.reportportal.junit5.TestCaseIdTest; 20 | import org.junit.jupiter.api.DynamicTest; 21 | import org.junit.jupiter.api.TestFactory; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | 24 | import java.util.UUID; 25 | import java.util.stream.Stream; 26 | 27 | import static org.junit.jupiter.api.DynamicTest.dynamicTest; 28 | 29 | /** 30 | * @author Ihar Kahadouski 31 | */ 32 | @ExtendWith(TestCaseIdTest.TestCaseIdExtension.class) 33 | public class SingleDynamicTest { 34 | public static final String TEST_CASE_DISPLAY_NAME = UUID.randomUUID().toString(); 35 | 36 | @TestFactory 37 | Stream testForTestFactory() { 38 | return Stream.of(dynamicTest(TEST_CASE_DISPLAY_NAME, () -> System.out.println("Test factory test: " + TEST_CASE_DISPLAY_NAME))); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/testcaseid/TestCaseIdFromAnnotationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 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.junit5.features.testcaseid; 18 | 19 | import com.epam.reportportal.annotations.TestCaseId; 20 | import com.epam.reportportal.junit5.TestCaseIdTest; 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | 24 | /** 25 | * @author Ihar Kahadouski 26 | */ 27 | @ExtendWith(TestCaseIdTest.TestCaseIdExtension.class) 28 | public class TestCaseIdFromAnnotationTest { 29 | 30 | public static final String TEST_CASE_ID_VALUE = "test-case-id"; 31 | 32 | @TestCaseId(TEST_CASE_ID_VALUE) 33 | @Test 34 | void test() { 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/testcaseid/TestCaseIdFromCodeRefAndParamsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 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.junit5.features.testcaseid; 18 | 19 | import com.epam.reportportal.junit5.TestCaseIdTest; 20 | import org.junit.jupiter.api.extension.ExtendWith; 21 | import org.junit.jupiter.params.ParameterizedTest; 22 | import org.junit.jupiter.params.provider.ValueSource; 23 | 24 | /** 25 | * @author Ihar Kahadouski 26 | */ 27 | @ExtendWith(TestCaseIdTest.TestCaseIdExtension.class) 28 | public class TestCaseIdFromCodeRefAndParamsTest { 29 | 30 | @ParameterizedTest 31 | @ValueSource(ints = { 101, 0 }) 32 | void parametrized(int value) { 33 | System.out.println("Parameter: " + value); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/testcaseid/TestCaseIdFromCodeRefTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 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.junit5.features.testcaseid; 18 | 19 | import com.epam.reportportal.junit5.TestCaseIdTest; 20 | import org.junit.jupiter.api.Test; 21 | import org.junit.jupiter.api.extension.ExtendWith; 22 | 23 | /** 24 | * @author Ihar Kahadouski 25 | */ 26 | @ExtendWith(TestCaseIdTest.TestCaseIdExtension.class) 27 | public class TestCaseIdFromCodeRefTest { 28 | 29 | @Test 30 | void test() { 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/testcaseid/TestCaseIdFromParametrizedAnnotationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 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.junit5.features.testcaseid; 18 | 19 | import com.epam.reportportal.annotations.TestCaseId; 20 | import com.epam.reportportal.annotations.TestCaseIdKey; 21 | import com.epam.reportportal.junit5.TestCaseIdTest; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | import org.junit.jupiter.params.ParameterizedTest; 24 | import org.junit.jupiter.params.provider.ValueSource; 25 | 26 | /** 27 | * @author Ihar Kahadouski 28 | */ 29 | @ExtendWith(TestCaseIdTest.TestCaseIdExtension.class) 30 | public class TestCaseIdFromParametrizedAnnotationTest { 31 | 32 | @TestCaseId(parametrized = true) 33 | @ParameterizedTest 34 | @ValueSource(strings = { "one", "two" }) 35 | void test(@TestCaseIdKey String parameter) { 36 | System.out.println("Parameter: " + parameter); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/features/testcaseid/TestCaseIdTemplateTest.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.junit5.features.testcaseid; 18 | 19 | import com.epam.reportportal.annotations.TestCaseId; 20 | import com.epam.reportportal.junit5.TestCaseIdTest; 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | 24 | @ExtendWith(TestCaseIdTest.TestCaseIdExtension.class) 25 | public class TestCaseIdTemplateTest { 26 | 27 | public static final String FIELD = "template"; 28 | 29 | public static final String TEST_CASE_ID_VALUE = "test-case-id-{this.FIELD}"; 30 | 31 | @TestCaseId(TEST_CASE_ID_VALUE) 32 | @Test 33 | void test() { 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/miscellaneous/DisplayNamesForConfigurationItemsTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.miscellaneous; 2 | 3 | import com.epam.reportportal.junit5.ReportPortalExtension; 4 | import com.epam.reportportal.junit5.features.configname.ConfigurationMethodsDefaultDisplayNameTest; 5 | import com.epam.reportportal.junit5.features.configname.ConfigurationMethodsDisplayNameGeneratorTest; 6 | import com.epam.reportportal.junit5.features.configname.ConfigurationMethodsDisplayNameTest; 7 | import com.epam.reportportal.junit5.features.configname.CustomDisplayNameGenerator; 8 | import com.epam.reportportal.junit5.util.TestUtils; 9 | import com.epam.reportportal.service.Launch; 10 | import com.epam.reportportal.service.step.StepReporter; 11 | import com.epam.reportportal.util.test.CommonUtils; 12 | import com.epam.ta.reportportal.ws.model.StartTestItemRQ; 13 | import io.reactivex.Maybe; 14 | import org.junit.jupiter.api.BeforeEach; 15 | import org.junit.jupiter.api.Test; 16 | import org.junit.jupiter.api.TestInstance; 17 | import org.junit.jupiter.api.extension.ExtensionContext; 18 | import org.mockito.ArgumentCaptor; 19 | import org.mockito.stubbing.Answer; 20 | 21 | import java.lang.reflect.Method; 22 | import java.util.Arrays; 23 | import java.util.List; 24 | import java.util.stream.Collectors; 25 | import java.util.stream.IntStream; 26 | 27 | import static com.epam.reportportal.junit5.miscellaneous.DisplayNamesForConfigurationItemsTest.TestExtension.LAUNCH; 28 | import static org.hamcrest.MatcherAssert.assertThat; 29 | import static org.hamcrest.Matchers.equalTo; 30 | import static org.mockito.ArgumentMatchers.any; 31 | import static org.mockito.ArgumentMatchers.notNull; 32 | import static org.mockito.Mockito.*; 33 | 34 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 35 | public class DisplayNamesForConfigurationItemsTest { 36 | 37 | public static class TestExtension extends ReportPortalExtension { 38 | static Launch LAUNCH; 39 | 40 | @Override 41 | protected Launch getLaunch(ExtensionContext context) { 42 | return LAUNCH; 43 | } 44 | } 45 | 46 | @BeforeEach 47 | public void setupMock() { 48 | LAUNCH = mock(Launch.class); 49 | when(LAUNCH.getStepReporter()).thenReturn(StepReporter.NOOP_STEP_REPORTER); 50 | when(LAUNCH.startTestItem(any())).thenAnswer((Answer>) invocation -> CommonUtils.createMaybeUuid()); 51 | when(LAUNCH.startTestItem(any(), any())).thenAnswer((Answer>) invocation -> CommonUtils.createMaybeUuid()); 52 | } 53 | 54 | @Test 55 | public void test_configuration_method_display_name_annotation() { 56 | TestUtils.runClasses(ConfigurationMethodsDisplayNameTest.class); 57 | 58 | verify(LAUNCH, times(1)).startTestItem(any()); // Start parent Suite 59 | ArgumentCaptor captorStart = ArgumentCaptor.forClass(StartTestItemRQ.class); 60 | verify(LAUNCH, times(5)).startTestItem(notNull(), captorStart.capture()); // Start a suite and two tests 61 | 62 | captorStart.getAllValues().forEach(i -> assertThat(i.getName(), equalTo(ConfigurationMethodsDisplayNameTest.DISPLAY_NAME))); 63 | } 64 | 65 | @Test 66 | public void test_configuration_method_display_name_generator() { 67 | TestUtils.runClasses(ConfigurationMethodsDisplayNameGeneratorTest.class); 68 | 69 | ArgumentCaptor startSuiteCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); 70 | verify(LAUNCH, times(1)).startTestItem(startSuiteCaptor.capture()); // Start parent Suite 71 | ArgumentCaptor startItemCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); 72 | verify(LAUNCH, times(5)).startTestItem(notNull(), startItemCaptor.capture()); // Start a suite and two tests 73 | 74 | assertThat(startSuiteCaptor.getValue().getName(), equalTo(CustomDisplayNameGenerator.DISPLAY_NAME_CLASS)); 75 | 76 | startItemCaptor.getAllValues().forEach(i -> assertThat(i.getName(), equalTo(CustomDisplayNameGenerator.DISPLAY_NAME_METHOD))); 77 | } 78 | 79 | @Test 80 | public void test_configuration_method_display_name_default_values() { 81 | TestUtils.runClasses(ConfigurationMethodsDefaultDisplayNameTest.class); 82 | 83 | verify(LAUNCH, times(1)).startTestItem(any()); // Start parent Suite 84 | ArgumentCaptor startItemCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class); 85 | verify(LAUNCH, times(5)).startTestItem(notNull(), startItemCaptor.capture()); // Start a suite and two tests 86 | 87 | List itemNames = startItemCaptor.getAllValues() 88 | .stream() 89 | .map(StartTestItemRQ::getName) 90 | .filter(e -> !e.startsWith("test")) 91 | .sorted() 92 | .collect(Collectors.toList()); 93 | List methodNames = Arrays.stream(ConfigurationMethodsDefaultDisplayNameTest.class.getMethods()) 94 | .map(Method::getName) 95 | .filter(e -> e.startsWith("before") || e.startsWith("after")) 96 | .sorted() 97 | .collect(Collectors.toList()); 98 | 99 | IntStream.range(0, itemNames.size()).forEach(i -> assertThat(itemNames.get(i), equalTo(methodNames.get(i) + "()"))); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/miscellaneous/FailedBeforeEachReportsSkippedTestTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.miscellaneous; 2 | 3 | import com.epam.reportportal.junit5.ReportPortalExtension; 4 | import com.epam.reportportal.junit5.features.skipped.AfterEachFailedTest; 5 | import com.epam.reportportal.junit5.features.skipped.BeforeEachFailedParametrizedTest; 6 | import com.epam.reportportal.junit5.features.skipped.BeforeEachFailedTest; 7 | import com.epam.reportportal.junit5.util.TestUtils; 8 | import com.epam.reportportal.listeners.ItemStatus; 9 | import com.epam.reportportal.service.Launch; 10 | import com.epam.reportportal.service.step.StepReporter; 11 | import com.epam.reportportal.util.test.CommonUtils; 12 | import com.epam.ta.reportportal.ws.model.FinishTestItemRQ; 13 | import com.epam.ta.reportportal.ws.model.StartTestItemRQ; 14 | import io.reactivex.Maybe; 15 | import org.apache.commons.lang3.tuple.Pair; 16 | import org.junit.jupiter.api.BeforeEach; 17 | import org.junit.jupiter.api.Test; 18 | import org.junit.jupiter.api.extension.ExtensionContext; 19 | import org.mockito.stubbing.Answer; 20 | 21 | import java.time.Instant; 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | import java.util.Map; 25 | import java.util.stream.IntStream; 26 | 27 | import static com.epam.reportportal.junit5.miscellaneous.FailedBeforeEachReportsSkippedTestTest.SkippedTestExtension.ITEMS; 28 | import static com.epam.reportportal.junit5.miscellaneous.FailedBeforeEachReportsSkippedTestTest.SkippedTestExtension.LAUNCH; 29 | import static com.epam.reportportal.junit5.util.Verifications.verify_call_number_and_capture_arguments; 30 | import static org.hamcrest.MatcherAssert.assertThat; 31 | import static org.hamcrest.Matchers.*; 32 | import static org.mockito.ArgumentMatchers.any; 33 | import static org.mockito.Mockito.*; 34 | 35 | public class FailedBeforeEachReportsSkippedTestTest { 36 | public static class SkippedTestExtension extends ReportPortalExtension { 37 | 38 | final static List ITEMS = new ArrayList<>(); 39 | static Launch LAUNCH; 40 | 41 | @Override 42 | protected Launch getLaunch(ExtensionContext context) { 43 | return LAUNCH; 44 | } 45 | } 46 | 47 | @BeforeEach 48 | public void setupMock() { 49 | ITEMS.clear(); 50 | LAUNCH = mock(Launch.class); 51 | when(LAUNCH.getStepReporter()).thenReturn(StepReporter.NOOP_STEP_REPORTER); 52 | when(LAUNCH.startTestItem(any())).thenAnswer((Answer>) invocation -> { 53 | Maybe result = CommonUtils.createMaybeUuid(); 54 | ITEMS.add(result.blockingGet()); 55 | return result; 56 | }); 57 | when(LAUNCH.startTestItem(any(), any())).thenAnswer((Answer>) invocation -> { 58 | Maybe result = CommonUtils.createMaybeUuid(); 59 | ITEMS.add(result.blockingGet()); 60 | return result; 61 | }); 62 | } 63 | 64 | @Test 65 | public void agent_should_report_skipped_test_in_case_of_failed_before_each() { 66 | TestUtils.runClasses(BeforeEachFailedTest.class); 67 | Pair>, Map> calls = verify_call_number_and_capture_arguments( 68 | 3, 69 | LAUNCH 70 | ); 71 | verifyNoMoreInteractions(LAUNCH); 72 | 73 | assertThat("There are 3 item created: suite, @BeforeEach and @Test", ITEMS, hasSize(3)); 74 | 75 | FinishTestItemRQ beforeEachFinish = calls.getValue().get(ITEMS.get(1)); 76 | 77 | assertThat("@BeforeEach failed", beforeEachFinish.getStatus(), equalTo("FAILED")); 78 | 79 | StartTestItemRQ testStart = calls.getKey().get(2).getValue(); 80 | assertThat( 81 | "@Test has correct code reference", 82 | testStart.getCodeRef(), 83 | equalTo(BeforeEachFailedTest.class.getCanonicalName() + ".testBeforeEachFailed") 84 | ); 85 | 86 | assertThat("@Test has correct name", testStart.getName(), equalTo("testBeforeEachFailed()")); 87 | 88 | FinishTestItemRQ testFinish = calls.getValue().get(ITEMS.get(2)); 89 | assertThat("@Test reported as skipped", testFinish.getStatus(), equalTo(ItemStatus.SKIPPED.name())); 90 | assertThat("@Test issue muted", testFinish.getIssue(), sameInstance(Launch.NOT_ISSUE)); 91 | Instant currentDate = Instant.now(); 92 | assertThat((Instant) testFinish.getEndTime(), lessThanOrEqualTo(currentDate)); 93 | } 94 | 95 | @Test 96 | public void agent_should_report_skipped_parametrized_tests_in_case_of_failed_before_each() { 97 | TestUtils.runClasses(BeforeEachFailedParametrizedTest.class); 98 | Pair>, Map> calls = verify_call_number_and_capture_arguments( 99 | 6, 100 | LAUNCH 101 | ); 102 | verifyNoMoreInteractions(LAUNCH); 103 | 104 | assertThat("There are 6 item created: parent suite, suite, 2 @BeforeEach, @Test 1 and @Test 2", ITEMS, hasSize(6)); 105 | 106 | FinishTestItemRQ beforeEachFinish = calls.getValue().get(ITEMS.get(2)); 107 | 108 | assertThat("@BeforeEach failed", beforeEachFinish.getStatus(), equalTo("FAILED")); 109 | 110 | Instant currentDate = Instant.now(); 111 | IntStream.rangeClosed(0, 1).boxed().forEach(i -> { 112 | StartTestItemRQ testStart = calls.getKey().get(3 + (i * 2)).getValue(); 113 | assertThat( 114 | "@Test has correct code reference", 115 | testStart.getCodeRef(), 116 | equalTo(BeforeEachFailedParametrizedTest.class.getCanonicalName() + ".testBeforeEachFailed") 117 | ); 118 | 119 | assertThat( 120 | "@Test has correct name", 121 | testStart.getName(), 122 | equalTo("[" + (i + 1) + "] " + BeforeEachFailedParametrizedTest.TestParams.values()[i]) 123 | ); 124 | 125 | FinishTestItemRQ testFinish = calls.getValue().get(ITEMS.get(3 + (i * 2))); 126 | assertThat("@Test reported as skipped", testFinish.getStatus(), equalTo(ItemStatus.SKIPPED.name())); 127 | assertThat("@Test issue muted", testFinish.getIssue(), sameInstance(Launch.NOT_ISSUE)); 128 | assertThat((Instant) testFinish.getEndTime(), lessThanOrEqualTo(currentDate)); 129 | }); 130 | } 131 | 132 | @Test 133 | public void agent_should_not_report_skipped_test_in_case_of_failed_after_each() { 134 | TestUtils.runClasses(AfterEachFailedTest.class); 135 | Pair>, Map> calls = verify_call_number_and_capture_arguments( 136 | 4, 137 | LAUNCH 138 | ); 139 | verifyNoMoreInteractions(LAUNCH); 140 | 141 | assertThat("There are 4 item created: suite, @BeforeEach, @Test and @AfterEach", ITEMS, hasSize(4)); 142 | 143 | FinishTestItemRQ beforeEachFinish = calls.getValue().get(ITEMS.get(1)); 144 | 145 | assertThat("@BeforeEach passed", beforeEachFinish.getStatus(), equalTo("PASSED")); 146 | 147 | FinishTestItemRQ testFinish = calls.getValue().get(ITEMS.get(2)); 148 | assertThat("@Test passed", testFinish.getStatus(), equalTo("PASSED")); 149 | 150 | FinishTestItemRQ afterEachFinish = calls.getValue().get(ITEMS.get(3)); 151 | assertThat("@AfterEach failed", afterEachFinish.getStatus(), equalTo("FAILED")); 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/miscellaneous/FailedBeforeEachSkippedTestOrderTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.miscellaneous; 2 | 3 | import com.epam.reportportal.junit5.ReportPortalExtension; 4 | import com.epam.reportportal.junit5.features.skipped.BeforeEachFailedWithAfterEachTest; 5 | import com.epam.reportportal.junit5.util.TestUtils; 6 | import com.epam.reportportal.service.Launch; 7 | import com.epam.ta.reportportal.ws.model.StartTestItemRQ; 8 | import org.junit.jupiter.api.BeforeEach; 9 | import org.junit.jupiter.api.RepeatedTest; 10 | import org.junit.jupiter.api.extension.ExtensionContext; 11 | import org.mockito.ArgumentCaptor; 12 | 13 | import java.time.Instant; 14 | import java.util.List; 15 | 16 | import static com.epam.reportportal.junit5.miscellaneous.FailedBeforeEachSkippedTestOrderTest.SkippedTestExtension.LAUNCH; 17 | import static org.hamcrest.MatcherAssert.assertThat; 18 | import static org.hamcrest.Matchers.greaterThan; 19 | import static org.mockito.ArgumentMatchers.notNull; 20 | import static org.mockito.Mockito.times; 21 | import static org.mockito.Mockito.verify; 22 | 23 | public class FailedBeforeEachSkippedTestOrderTest { 24 | public static class SkippedTestExtension extends ReportPortalExtension { 25 | static Launch LAUNCH; 26 | 27 | @Override 28 | protected Launch getLaunch(ExtensionContext context) { 29 | return LAUNCH; 30 | } 31 | } 32 | 33 | @BeforeEach 34 | public void setupMock() { 35 | LAUNCH = TestUtils.getBasicMockedLaunch(); 36 | } 37 | 38 | @RepeatedTest(10) 39 | public void test_skipped_test_order_by_start_time_after_failed_before_each() { 40 | TestUtils.runClasses(BeforeEachFailedWithAfterEachTest.class); 41 | 42 | ArgumentCaptor captor = ArgumentCaptor.forClass(StartTestItemRQ.class); 43 | verify(LAUNCH, times(3)).startTestItem(notNull(), captor.capture()); // Start a before, a test, an after 44 | 45 | List rqValues = captor.getAllValues(); 46 | Instant firstDate = (Instant) rqValues.get(0).getStartTime(); 47 | for (int i = 1; i < rqValues.size(); i++) { 48 | Instant itemDate = (Instant) rqValues.get(i).getStartTime(); 49 | assertThat(itemDate, greaterThan(firstDate)); 50 | firstDate = itemDate; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/util/TestUtils.java: -------------------------------------------------------------------------------- 1 | package com.epam.reportportal.junit5.util; 2 | 3 | import com.epam.reportportal.listeners.ListenerParameters; 4 | import com.epam.reportportal.service.Launch; 5 | import com.epam.reportportal.service.ReportPortalClient; 6 | import com.epam.reportportal.util.test.CommonUtils; 7 | import com.epam.ta.reportportal.ws.model.BatchSaveOperatingRS; 8 | import com.epam.ta.reportportal.ws.model.OperationCompletionRS; 9 | import com.epam.ta.reportportal.ws.model.StartTestItemRQ; 10 | import com.epam.ta.reportportal.ws.model.item.ItemCreatedRS; 11 | import com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ; 12 | import com.epam.ta.reportportal.ws.model.launch.StartLaunchRS; 13 | import io.reactivex.Maybe; 14 | import org.apache.commons.lang3.tuple.Pair; 15 | import org.junit.platform.engine.discovery.ClassSelector; 16 | import org.junit.platform.engine.discovery.DiscoverySelectors; 17 | import org.junit.platform.launcher.LauncherDiscoveryRequest; 18 | import org.junit.platform.launcher.TestExecutionListener; 19 | import org.junit.platform.launcher.core.LauncherConfig; 20 | import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; 21 | import org.junit.platform.launcher.core.LauncherFactory; 22 | import org.mockito.ArgumentCaptor; 23 | import org.mockito.stubbing.Answer; 24 | 25 | import java.util.*; 26 | import java.util.stream.Collectors; 27 | import java.util.stream.Stream; 28 | 29 | import static com.epam.reportportal.util.test.CommonUtils.createMaybeUuid; 30 | import static org.mockito.ArgumentMatchers.*; 31 | import static org.mockito.Mockito.mock; 32 | import static org.mockito.Mockito.when; 33 | 34 | public class TestUtils { 35 | 36 | private TestUtils() { 37 | } 38 | 39 | public static ListenerParameters standardParameters() { 40 | ListenerParameters result = new ListenerParameters(); 41 | result.setClientJoin(false); 42 | result.setBatchLogsSize(1); 43 | result.setLaunchName("My-test-launch-" + CommonUtils.generateUniqueId()); 44 | result.setProjectName("unit-test"); 45 | result.setEnable(true); 46 | return result; 47 | } 48 | 49 | public static void runClasses(final Class... testClasses) { 50 | runClasses(null, testClasses); 51 | } 52 | 53 | public static void runClasses(final TestExecutionListener listener, final Class... testClasses) { 54 | ClassSelector[] classSelectors = Stream.of(testClasses).map(DiscoverySelectors::selectClass).toArray(ClassSelector[]::new); 55 | LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(classSelectors).build(); 56 | LauncherConfig.Builder builder = LauncherConfig.builder(); 57 | if (listener != null) { 58 | builder.addTestExecutionListeners(listener); 59 | } 60 | LauncherConfig config = builder.enableTestExecutionListenerAutoRegistration(false).build(); 61 | LauncherFactory.create(config).execute(request); 62 | } 63 | 64 | public static Launch getBasicMockedLaunch() { 65 | Launch result = mock(Launch.class); 66 | when(result.startTestItem(any())).thenAnswer((Answer>) invocation -> createMaybeUuid()); 67 | when(result.startTestItem(any(), any())).thenAnswer((Answer>) invocation -> createMaybeUuid()); 68 | return result; 69 | } 70 | 71 | public static void mockLaunch(ReportPortalClient client, String launchUuid, String testClassUuid, String testMethodUuid) { 72 | mockLaunch(client, launchUuid, testClassUuid, Collections.singleton(testMethodUuid)); 73 | } 74 | 75 | @SuppressWarnings("unchecked") 76 | public static void mockLaunch(ReportPortalClient client, String launchUuid, String testClassUuid, 77 | Collection testMethodUuidList) { 78 | when(client.startLaunch(any())).thenReturn(Maybe.just(new StartLaunchRS(launchUuid, 1L))); 79 | 80 | Maybe testClassMaybe = Maybe.just(new ItemCreatedRS(testClassUuid, testClassUuid)); 81 | when(client.startTestItem(any())).thenReturn(testClassMaybe); 82 | 83 | List> responses = testMethodUuidList.stream() 84 | .map(uuid -> Maybe.just(new ItemCreatedRS(uuid, uuid))) 85 | .collect(Collectors.toList()); 86 | Maybe first = responses.get(0); 87 | Maybe[] other = responses.subList(1, responses.size()).toArray(new Maybe[0]); 88 | when(client.startTestItem(eq(testClassUuid), any())).thenReturn(first, other); 89 | new HashSet<>(testMethodUuidList).forEach(testMethodUuid -> when(client.finishTestItem( 90 | eq(testMethodUuid), 91 | any() 92 | )).thenReturn(Maybe.just(new OperationCompletionRS()))); 93 | 94 | Maybe testClassFinishMaybe = Maybe.just(new OperationCompletionRS()); 95 | when(client.finishTestItem(eq(testClassUuid), any())).thenReturn(testClassFinishMaybe); 96 | 97 | when(client.finishLaunch(eq(launchUuid), any())).thenReturn(Maybe.just(new OperationCompletionRS())); 98 | } 99 | 100 | public static StartLaunchRQ launchRQ(ListenerParameters parameters) { 101 | StartLaunchRQ result = new StartLaunchRQ(); 102 | result.setName(parameters.getLaunchName()); 103 | result.setStartTime(Calendar.getInstance().getTime()); 104 | return result; 105 | } 106 | 107 | @SuppressWarnings("unchecked") 108 | public static void mockNestedSteps(final ReportPortalClient client, final List> parentNestedPairs) { 109 | Map> responseOrders = parentNestedPairs.stream() 110 | .collect(Collectors.groupingBy(Pair::getKey, Collectors.mapping(Pair::getValue, Collectors.toList()))); 111 | responseOrders.forEach((k, v) -> { 112 | List> responses = v.stream() 113 | .map(uuid -> Maybe.just(new ItemCreatedRS(uuid, uuid))) 114 | .collect(Collectors.toList()); 115 | 116 | Maybe first = responses.get(0); 117 | Maybe[] other = responses.subList(1, responses.size()).toArray(new Maybe[0]); 118 | when(client.startTestItem(same(k), any())).thenReturn(first, other); 119 | }); 120 | parentNestedPairs.forEach(p -> when(client.finishTestItem( 121 | same(p.getValue()), 122 | any() 123 | )).thenAnswer((Answer>) invocation -> Maybe.just(new OperationCompletionRS()))); 124 | } 125 | 126 | @SuppressWarnings("unchecked") 127 | public static void mockLogging(ReportPortalClient client) { 128 | when(client.log(any(List.class))).thenReturn(Maybe.just(new BatchSaveOperatingRS())); 129 | } 130 | 131 | public static StartTestItemRQ extractRequest(ArgumentCaptor captor, String methodType) { 132 | return captor.getAllValues() 133 | .stream() 134 | .filter(it -> methodType.equalsIgnoreCase(it.getType())) 135 | .findAny() 136 | .orElseThrow(() -> new AssertionError(String.format("Method type '%s' should be present among requests", methodType))); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/test/java/com/epam/reportportal/junit5/utils/ItemTreeUtilsTest.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.junit5.utils; 18 | 19 | import com.epam.reportportal.service.tree.TestItemTree; 20 | import io.reactivex.Maybe; 21 | import org.junit.jupiter.api.BeforeEach; 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.TestInfo; 24 | import org.junit.jupiter.api.extension.ExtensionContext; 25 | import org.mockito.Mock; 26 | import org.mockito.MockitoAnnotations; 27 | 28 | import static org.hamcrest.MatcherAssert.assertThat; 29 | import static org.hamcrest.Matchers.equalTo; 30 | import static org.hamcrest.Matchers.notNullValue; 31 | import static org.mockito.Mockito.when; 32 | 33 | /** 34 | * @author Ivan Budayeu 35 | */ 36 | class ItemTreeUtilsTest { 37 | 38 | private static final String NAME = "Simple name"; 39 | private static final int ANOTHER_HASH = NAME.hashCode() - 1; 40 | 41 | @Mock 42 | private TestInfo testInfo; 43 | 44 | @Mock 45 | private ExtensionContext extensionContext; 46 | 47 | private TestItemTree testItemTree; 48 | 49 | @BeforeEach 50 | void init() { 51 | MockitoAnnotations.initMocks(this); 52 | when(testInfo.getDisplayName()).thenReturn(NAME); 53 | when(extensionContext.getDisplayName()).thenReturn(NAME); 54 | 55 | testItemTree = new TestItemTree(); 56 | } 57 | 58 | @Test 59 | void createKeyFromString() { 60 | TestItemTree.ItemTreeKey itemTreeKey = ItemTreeUtils.createItemTreeKey(NAME); 61 | 62 | assertThat(itemTreeKey.getName(), equalTo(NAME)); 63 | assertThat(itemTreeKey.getHash(), equalTo(NAME.hashCode())); 64 | } 65 | 66 | @Test 67 | void createKeyFromStringAndHash() { 68 | TestItemTree.ItemTreeKey itemTreeKey = ItemTreeUtils.createItemTreeKey(NAME, ANOTHER_HASH); 69 | 70 | assertThat(itemTreeKey.getName(), equalTo(NAME)); 71 | assertThat(itemTreeKey.getHash(), equalTo(ANOTHER_HASH)); 72 | } 73 | 74 | @Test 75 | void createKeyFromTestInfo() { 76 | TestItemTree.ItemTreeKey itemTreeKey = ItemTreeUtils.createItemTreeKey(testInfo); 77 | 78 | assertThat(itemTreeKey.getName(), equalTo(NAME)); 79 | assertThat(itemTreeKey.getHash(), equalTo(NAME.hashCode())); 80 | } 81 | 82 | @Test 83 | void createKeyFromTestInfoAndHash() { 84 | TestItemTree.ItemTreeKey itemTreeKey = ItemTreeUtils.createItemTreeKey(testInfo, ANOTHER_HASH); 85 | 86 | assertThat(itemTreeKey.getName(), equalTo(NAME)); 87 | assertThat(itemTreeKey.getHash(), equalTo(ANOTHER_HASH)); 88 | } 89 | 90 | @Test 91 | void createKeyFromExtensionContext() { 92 | TestItemTree.ItemTreeKey itemTreeKey = ItemTreeUtils.createItemTreeKey(extensionContext); 93 | 94 | assertThat(itemTreeKey.getName(), equalTo(NAME)); 95 | assertThat(itemTreeKey.getHash(), equalTo(NAME.hashCode())); 96 | } 97 | 98 | @Test 99 | void createKeyFromExtensionContextAndHash() { 100 | TestItemTree.ItemTreeKey itemTreeKey = ItemTreeUtils.createItemTreeKey(extensionContext, ANOTHER_HASH); 101 | 102 | assertThat(itemTreeKey.getName(), equalTo(NAME)); 103 | assertThat(itemTreeKey.getHash(), equalTo(ANOTHER_HASH)); 104 | } 105 | 106 | @Test 107 | void retrieveLeafByName() { 108 | 109 | TestItemTree.ItemTreeKey treeKey = TestItemTree.ItemTreeKey.of(NAME); 110 | Maybe itemId = createIdMaybe("first"); 111 | TestItemTree.TestItemLeaf itemLeaf = TestItemTree.createTestItemLeaf(itemId); 112 | 113 | testItemTree.getTestItems().put(treeKey, itemLeaf); 114 | 115 | TestItemTree.TestItemLeaf retrievedLeaf = ItemTreeUtils.retrieveLeaf(NAME, testItemTree); 116 | 117 | assertThat(retrievedLeaf.getItemId(), notNullValue()); 118 | assertThat(retrievedLeaf.getItemId(), equalTo(itemId)); 119 | } 120 | 121 | @Test 122 | void retrieveLeafByTestInfo() { 123 | TestItemTree.ItemTreeKey treeKey = TestItemTree.ItemTreeKey.of(NAME); 124 | Maybe itemId = createIdMaybe("first"); 125 | TestItemTree.TestItemLeaf itemLeaf = TestItemTree.createTestItemLeaf(itemId); 126 | 127 | testItemTree.getTestItems().put(treeKey, itemLeaf); 128 | 129 | TestItemTree.TestItemLeaf retrievedLeaf = ItemTreeUtils.retrieveLeaf(testInfo, testItemTree); 130 | 131 | assertThat(retrievedLeaf.getItemId(), notNullValue()); 132 | assertThat(retrievedLeaf.getItemId(), equalTo(itemId)); 133 | } 134 | 135 | public static Maybe createIdMaybe(String id) { 136 | return Maybe.create(emitter -> { 137 | emitter.onSuccess(id); 138 | emitter.onComplete(); 139 | }); 140 | } 141 | } -------------------------------------------------------------------------------- /src/test/resources/META-INF/aop-ajc.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/test/resources/agent.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019 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 | agent.name=TestAgent 17 | agent.version=TestVersion -------------------------------------------------------------------------------- /src/test/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 | } 32 | -------------------------------------------------------------------------------- /src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | %d{HH:mm:ss.SSS} %-5level %logger{5} - %thread - %msg%n 9 | 10 | 11 | 12 | 13 | 14 | 15 | %d{HH:mm:ss.SSS} [%t] %-5level - %msg%n 16 | [%t] - %msg%n 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/test/resources/pug/unlucky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reportportal/agent-java-junit5/8bb8181518a0894ed700bccd4c49c5602e55d944/src/test/resources/pug/unlucky.jpg --------------------------------------------------------------------------------