opentest4j-r1.2.0/000077500000000000000000000000001347626406500140105ustar00rootroot00000000000000opentest4j-r1.2.0/.gitattributes000066400000000000000000000000351347626406500167010ustar00rootroot00000000000000* text eol=lf *.bat eol=crlf opentest4j-r1.2.0/.github/000077500000000000000000000000001347626406500153505ustar00rootroot00000000000000opentest4j-r1.2.0/.github/PULL_REQUEST_TEMPLATE.md000066400000000000000000000001511347626406500211460ustar00rootroot00000000000000## Overview - --- I hereby agree to the terms of the Open Test Alliance Contributor License Agreement. opentest4j-r1.2.0/.gitignore000066400000000000000000000002641347626406500160020ustar00rootroot00000000000000# Gradle .gradle build/ # Ignore Gradle GUI config gradle-app.setting # Eclipse .classpath .settings/ .project bin/ # IntelliJ *.iml *.ipr *.iws *.uml .idea/ out/ # Misc *.log opentest4j-r1.2.0/.travis.yml000066400000000000000000000056071347626406500161310ustar00rootroot00000000000000language: java # Specify which branches/tags that we do not want to be built: r5.0.0-M5 branches: except: - /^r\d.*$/ before_install: - unset _JAVA_OPTIONS # https://github.com/travis-ci/travis-ci/issues/8408 install: - ./gradlew --version # Display Gradle, Groovy, JVM and other versions jdk: - openjdk11 stages: - test - name: deploy if: (branch = master) AND (NOT type IN (pull_request)) jobs: include: - script: ./gradlew --stacktrace build - stage: deploy name: "Publish snapshot artifacts" env: # ORG_GRADLE_PROJECT_ossrhUsername - secure: K3oEnLQ2ai8lmTHrfQsktkb8vc/W5ghP6NurUmb4E+SHWw/zqv2naxupbpVZqovhhTqYm1/I0rqHKrGrBIUDSFMhyTKYmqw4+Nck3BAnjXovotGuKyMrg6yqoBjaWhT8rJe/fR2hZgUi96vSjEKC/UDSGRRHhoEyX73qAwbA7CGJ3SMVRZpkBvs2GUubKZgXuJCpGSk2FWOtJpWK4sC87/yV8Arg1DgrCHUm7uc1we+CedjierPxfo6QX9Laohyn60D3BtojYw1xxsiX9Rv0KCxCqmZn5Qd6PLV4+0PzFXjO0xvrHecQ+NhyWfmMkfV5dO/zaF0OoxrHj/cFmvoGSHN4r1SIV2TwbtIuUCxypWqUTVrfejQyJ2Dhk2GbOa941EtXXX8i2zEDTBq56Tby4d44QvhK1v8QNmmev/o6j1YCBMKN+X59bSqUHF4PX8ap9m2iWYNCbvwET5YJAKnWLEj2QGBXn34GWZksyU/Fe+mvVJ0eRwZjUWKfOcS5xzrvRrNayyMIzUSUGKuTDeS+KR9eF7215hBDu6t8z+s+jSyoLD8+tttnHrgBkkUvwzctT8MeQP0JdpYhYyITuWYJ1OB9w2GKHE5ch9JYYOKUliJga42P6Hbx4NwTeCSNJ96mzQAKcDwwJZujzN2PDSr86uBlHwLdn+9cy0vndYUSYtY= # ORG_GRADLE_PROJECT_ossrhPassword - secure: NewZka3bmiDgrSP8+yfPQNf85K/sT4CQiIbrf9SWOTgI7Z6kq6kKXU94cEQue6Ugli0USreMZYhl5b6XvcCUzRF9kOh/mRk9VIaOOaOIloatmaF581mGiYNBn8AoBoQ/JURQ59dBxHxyyf4Wm5o63FW0RdZoBOb8FA+esLGdY8ZlpsSc3WdYmguJf6Ga2auT1FIGujDLjBYCaPBqx1xM8JckFWBU0QHhDGFo6CjGUUd62KTf72RVtsLmcMnEvoJ18s7txmWYY4H/BwONekTnmXw80+y6EVXP3K7kkD/9KL9xq/fDibcmP9UfbpCnEysu7hygMhPfMPB3KmPhFSP7GGlEZsLeGNhLBLXidpJmyNvcSHOdS+vaF8xbW/+DBJ3stNntS1TaPGPcIjAyKN67q4yayZBdJKzkIWzVkJy3akRwO7D0Lj1irs7mcLL0DSkP3YrgShIhcq34D+Iknblz4AykG1/ehv4eAipljrh66SGB41QlN6U0AZVpqi869sPfu55q8Piucnrps+3jo26q25mtPpurEIIQIX6SCwUyK4A+4Jvk4r8KUykkBS7HildiflKGwiLTRHgskGkAslm0ARZo4B50FQgqcJbytkSqe76y4WeVLZ648zNNTlX7oysKeizGjj6CxnXN3KLKmmXqKaht5UX6gCSbw2+O9/OlAgw= script: ./gradlew --stacktrace uploadArchives -x check - name: "Update snapshot documentation" env: # ORG_GRADLE_PROJECT_githubToken - secure: AW4jpuuv5MTIxUw1dlfIKyRgp5G9aj9/wsJx+XBVdZ6/+0Tj8BzBldUe9b4JeNEnDGIRIL83lPHMR0a/DbfF5Cg0Cpi0oLQE+JkKh/ucRZucrXXMjIg+3IEtpdUG/I4vqjwd1xUAYZ/URPP75NVr7b3RVY9+MTaSaZ2b+VtG/aMNJ5kih4PHfJ2wR0OobHrTSxOkyGwZTdG6ZvFplHcPtuZ/v6KJGaUrCFYRnXOZIE73dPDQjxqy90FQrNlscvkZ3cerqVeeQ1nK7eU60neNBrSP9PJsN6zqSyPfMfyfzGBiS7v2dlVktSjeOmdEn+NCSmR59a0wbVObhzisOgODqBMk3KLWOWwWHfA2M5URuQaNr/AsKQTr2FlVkwY/cHO52q58tKNE1m/3nPs5ZMEhlh6jtbBafUe8NA9JQ0LKppA/kMqd1vT97hCeMGR0B5rTZEYXK9pCKWmWg98YEAR9RA9gnNuRod07uI/T9dSvHVvg3T7K1jdFtnSs8TOYamxn3wo1I8jud34mUTv7v4Wdk7ujXZJIcIkHFWKon/OpRwiBHNh9w5w0d7qZVvH7dYFhxRYjbUP4d+QzYlUQUVcy1QvixHBr4eYRZ1q7v40OWBKb9lOXdD1I6x7XLtcNcZ08c3xKpiBFjwTPIMot87vw90PTPFigBAfRj1wDocdd9Sg= script: ./gradlew --stacktrace publishGhPages opentest4j-r1.2.0/CONTRIBUTING.md000066400000000000000000000043031347626406500162410ustar00rootroot00000000000000# Contributing ## Open Test Alliance Contributor License Agreement **Project License:** [Apache License Version 2.0](LICENSE) - You will only Submit Contributions where You have authored 100% of the content. - You will only Submit Contributions to which You have the necessary rights. This means that if You are employed You have received the necessary permissions from Your employer to make the Contributions. - Whatever content You Contribute will be provided under the Project License(s). ## Pull Requests Please add the following lines to your pull request description: ```markdown --- I hereby agree to the terms of the Open Test Alliance Contributor License Agreement. ``` ## Coding Conventions ### Formatting Code formatting is enforced using the [Spotless](https://github.com/diffplug/spotless) Gradle plugin. You can use `gradle spotlessApply` to format new code and add missing license headers to source files. Formatter settings for Eclipse are available [in the repository](https://github.com/ota4j-team/opentest4j/blob/master/etc/eclipse/eclipse-formatter-settings.xml). For IntelliJ IDEA there's a [plugin](https://plugins.jetbrains.com/plugin/6546) you can use. ### Javadoc - Javadoc comments should be wrapped after 80 characters whenever possible. - This first paragraph must be a single, concise sentence that ends with a period ("."). - Place `

` on the same line as the first line in a new paragraph and precede `

` with a blank line. - Insert a blank line before at-clauses/tags. - Favor `{@code foo}` over `foo`. - Favor literals (e.g., `{@literal @}`) over HTML entities. - Use `@since 1.0` instead of `@since 1.0.0`. - Use `@author` tags with full, real names (no nicknames or aliases) at the type level. Do not include email addresses or URLs in `@author` tags. ### Tests #### Naming - Tests are written using JUnit 4. - All test classes must end with a `Tests` suffix. - Example test classes that should not be picked up by the build must end with a `TestCase` suffix. #### Assertions - Use `org.junit.Assert` wherever possible. - Do not use `junit.framework.Assert`. - Use AssertJ when richer assertions are needed. #### Mocking - Use either Mockito or hand-written test doubles. opentest4j-r1.2.0/LICENSE000066400000000000000000000261361347626406500150250ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. opentest4j-r1.2.0/README.md000066400000000000000000000100401347626406500152620ustar00rootroot00000000000000# Open Test Alliance for the JVM [![Travis Build Status](https://travis-ci.org/ota4j-team/opentest4j.svg?branch=master)](https://travis-ci.org/ota4j-team/opentest4j) ## History This project is the result of an initiative by the [JUnit 5 team](https://github.com/junit-team/junit5/issues/12). ## Status Quo There is no standard for testing on the JVM: the only common building block we have is `java.lang.AssertionError`. `AssertionError` is great for signaling that a test has failed, but it doesn't go far enough. Each testing framework is therefore forced to fill the gap with custom subclasses of `AssertionError` or `RuntimeException` to provide a richer feature set to end users. The downside is that each framework has its **own** set of custom errors and exceptions, and this makes it a challenge for frameworks to interoperate. For example, JUnit has long supported the notion of a _failed assumption_ via its `AssumptionViolatedException`, but assertion frameworks like AssertJ cannot integrate that feature without a direct dependency on JUnit. Furthermore, the status quo makes the work of IDEs and build tools more difficult than it should be. ## Proposal The only real solution to this problem is to create a foundation that we can all build on! Based on discussions with IDE and build tool developers from Eclipse, Gradle, and IntelliJ, the JUnit 5 team is working on a proposal for an open source project to provide a minimal common foundation for testing libraries on the JVM. The primary goal of the project is to enable testing frameworks like JUnit, TestNG, Spock, etc. and third-party assertion libraries like Hamcrest, AssertJ, etc. to use a common set of exceptions that IDEs and build tools can support in a consistent manner across all testing scenarios -- for example, for consistent handling of failed assertions and failed assumptions as well as visualization of test execution in IDEs and reports. ## Initial Implementation We have begun with a small set of errors and exceptions that we consider to be common for all testing and assertion frameworks. In fact, these errors and exceptions are already used in [JUnit 5]. Please take a look at the project and let us know what you think. ## Javadocs - [Latest release](http://ota4j-team.github.io/opentest4j/docs/current/api/) - [Latest snapshot](http://ota4j-team.github.io/opentest4j/docs/snapshot/api/) ## Contributing Contributions to the Open Test Alliance are both welcomed and appreciated. For specific guidelines regarding contributions, please see [CONTRIBUTING.md] in the root directory of the project. Those willing to use milestone or SNAPSHOT releases are encouraged to file feature requests and bug reports using the project's [issue tracker](https://github.com/ota4j-team/opentest4j/issues). ### Feedback is welcome! What types of _errors_ and _exceptions_ should the OTA support? What types of properties should such errors and exceptions have? What additional functionality (e.g., interfaces, utility methods, etc.) should the OTA provide? ## Projects already contacted We've already reached out to and asked for feedback from the maintainers of the following projects. - Test NG - Hamcrest - AssertJ - Spock - Google Truth - ScalaTest - Eclipse - IntelliJ - Gradle - Maven Surefire Plugin - Allure Framework # Installation Release artifacts are deployed to [Maven Central]. Snapshot artifacts are deployed to Sonatype's [snapshots repository]. ## Dependency Metadata ### Latest Release - **Group ID**: `org.opentest4j` - **Artifact ID**: `opentest4j` - **Version**: `1.2.0` See also: ### Snapshots - **Group ID**: `org.opentest4j` - **Artifact ID**: `opentest4j` - **Version**: `1.3.0-SNAPSHOT` See also: [CONTRIBUTING.md]: https://github.com/ota4j-team/opentest4j/blob/master/CONTRIBUTING.md [JUnit 5]: https://github.com/junit-team/junit5 [Maven Central]: http://search.maven.org/ [snapshots repository]: https://oss.sonatype.org/content/repositories/snapshots/ opentest4j-r1.2.0/build.gradle000066400000000000000000000150061347626406500162710ustar00rootroot00000000000000import java.text.SimpleDateFormat plugins { id 'java' id 'osgi' id 'eclipse' id 'idea' id 'maven' id 'signing' id 'com.diffplug.gradle.spotless' version '3.23.0' id 'net.nemerosa.versioning' version '2.8.2' id 'org.ajoberstar.github-pages' version '1.7.2' } Date buildTimeAndDate = new Date() ext { buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate) buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate) builtByValue = project.hasProperty('builtBy') ? project.builtBy : project.defaultBuiltBy } description = 'Open Test Alliance for the JVM' def moduleName = 'org.opentest4j' repositories { mavenCentral() } compileJava { options.compilerArgs = ['--release', '6'] } task compileModule(type: JavaCompile) { def moduleSrcDir = file('src/module/java') source(moduleSrcDir) destinationDir = file("$buildDir/classes/java/modules") classpath = compileJava.classpath inputs.property("moduleName", moduleName) inputs.property("moduleVersion", project.version) options.compilerArgs = [ '--release', '9', '--module-version', project.version as String, '--module-source-path', moduleSrcDir.toString(), '--patch-module', "$moduleName=${sourceSets.main.allJava.srcDirs.join(':')}", '--module', moduleName ] } dependencies { testCompile("junit:junit:${junit4Version}") } test { testLogging { exceptionFormat = 'full' } } def normalizeVersion = { versionLiteral -> try { (versionLiteral =~ /(\d+)\.(\d+)\.(\d+).*/)[0][1..3].join('.') } catch (e) { throw new GradleException("Version '$versionLiteral' does not match version pattern, e.g. 1.0.0-QUALIFIER", e) } } jar { manifest { attributes( 'Created-By': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})".toString(), 'Built-By': builtByValue, 'Build-Date': buildDate, 'Build-Time': buildTime, 'Build-Revision': versioning.info.commit, 'Specification-Title': project.name, 'Specification-Version': normalizeVersion(project.version), 'Specification-Vendor': 'opentest4j.org', 'Implementation-Title': project.name, 'Implementation-Version': project.version, 'Implementation-Vendor': 'opentest4j.org' ) license = 'The Apache License, Version 2.0' vendor = 'opentest4j.org' } from(files("${compileModule.destinationDir}/$moduleName").builtBy(compileModule)) { include('module-info.class') } } javadoc { options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED options.author = true options.header = 'Open Test Alliance for the JVM' options.addStringOption('Xdoclint:html,syntax,reference', '-quiet') options.links 'https://docs.oracle.com/en/java/javase/11/docs/api/' } task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' from sourceSets.main.allSource } task javadocJar(type: Jar) { classifier = 'javadoc' from javadoc } artifacts { archives sourcesJar archives javadocJar } spotless { java { licenseHeaderFile rootProject.file('etc/spotless/apache-license-2.0.java') importOrder('java', 'javax', 'com', 'org') eclipse().configFile(rootProject.file('etc/eclipse/eclipse-formatter-settings.xml')) trimTrailingWhitespace() endWithNewline() } } def signArtifacts = !project.version.contains('SNAPSHOT') if (signArtifacts) { signing { sign configurations.archives } } uploadArchives { dependsOn check repositories { mavenDeployer { if (signArtifacts) { beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } } def ossrhUsername = rootProject.hasProperty('ossrhUsername') ? rootProject.ossrhUsername : '' def ossrhPassword = rootProject.hasProperty('ossrhPassword') ? rootProject.ossrhPassword : '' repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { authentication(userName: ossrhUsername, password: ossrhPassword) } snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { authentication(userName: ossrhUsername, password: ossrhPassword) } pom.project { name "${project.group}:${project.name}" packaging 'jar' description "Open Test Alliance for the JVM" url 'https://github.com/ota4j-team/opentest4j' scm { connection 'scm:git:git://github.com/ota4j-team/opentest4j.git' developerConnection 'scm:git:git://github.com/ota4j-team/opentest4j.git' url 'https://github.com/ota4j-team/opentest4j' } licenses { license { name 'The Apache License, Version 2.0' url 'http://www.apache.org/licenses/LICENSE-2.0.txt' } } developers { developer { id 'bechte' name 'Stefan Bechtold' email 'stefan.bechtold@me.com' } developer { id 'jlink' name 'Johannes Link' email 'business@johanneslink.net' } developer { id 'marcphilipp' name 'Marc Philipp' email 'mail@marcphilipp.de' } developer { id 'mmerdes' name 'Matthias Merdes' email 'Matthias.Merdes@heidelberg-mobil.com' } developer { id 'sbrannen' name 'Sam Brannen' email 'sam@sambrannen.com' } } } pom.whenConfigured { p -> p.dependencies = p.dependencies.findAll { dep -> dep.scope != 'test' } } } } } spotless { format 'misc', { target project.fileTree(project.rootDir) { include '**/*.gradle', '**/*.md', '**/*.gitignore' exclude '.gradle/**/*.*' } indentWithTabs() trimTrailingWhitespace() endWithNewline() } } def docsVersion = project.version.contains('SNAPSHOT') ? 'snapshot' : project.version def docsDir = new File(buildDir, 'ghpages-docs') task prepareDocsForUploadToGhPages(dependsOn: [javadoc], type: Copy) { outputs.dir docsDir from("$buildDir/docs") { include 'javadoc/**' } into "${docsDir}/${docsVersion}" filesMatching('javadoc/**') { fileCopyDetails -> fileCopyDetails.path = fileCopyDetails.path.replace('javadoc/', 'api/') } includeEmptyDirs = false } task createCurrentDocsFolder(dependsOn: prepareDocsForUploadToGhPages, type: Copy) { outputs.dir "${docsDir}/current" from "${docsDir}/${docsVersion}" into "${docsDir}/current" } createCurrentDocsFolder.onlyIf { project.hasProperty('replaceCurrentDocs') } githubPages { repoUri = 'https://github.com/ota4j-team/opentest4j.git' credentials { username = project.hasProperty('githubToken') ? project.githubToken : '' password = '' } pages { from docsDir into "docs" } deleteExistingFiles = false } prepareGhPages.dependsOn(prepareDocsForUploadToGhPages) prepareGhPages.dependsOn(createCurrentDocsFolder) opentest4j-r1.2.0/etc/000077500000000000000000000000001347626406500145635ustar00rootroot00000000000000opentest4j-r1.2.0/etc/eclipse/000077500000000000000000000000001347626406500162075ustar00rootroot00000000000000opentest4j-r1.2.0/etc/eclipse/eclipse-formatter-settings.xml000066400000000000000000000750071347626406500242250ustar00rootroot00000000000000 opentest4j-r1.2.0/etc/spotless/000077500000000000000000000000001347626406500164375ustar00rootroot00000000000000opentest4j-r1.2.0/etc/spotless/apache-license-2.0.java000066400000000000000000000011551347626406500224420ustar00rootroot00000000000000/* * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ opentest4j-r1.2.0/gradle.properties000066400000000000000000000001531347626406500173630ustar00rootroot00000000000000group = org.opentest4j version = 1.2.0 junit4Version = 4.12 defaultBuiltBy = OTA4J Team opentest4j-r1.2.0/settings.gradle000066400000000000000000000003401347626406500170250ustar00rootroot00000000000000rootProject.name = 'opentest4j' // Require Java 11 if (!JavaVersion.current().java11) { throw new GradleException('The OpenTest4J build requires Java 11. ' + "Currently executing with Java ${JavaVersion.current()}.") } opentest4j-r1.2.0/src/000077500000000000000000000000001347626406500145775ustar00rootroot00000000000000opentest4j-r1.2.0/src/main/000077500000000000000000000000001347626406500155235ustar00rootroot00000000000000opentest4j-r1.2.0/src/main/java/000077500000000000000000000000001347626406500164445ustar00rootroot00000000000000opentest4j-r1.2.0/src/main/java/org/000077500000000000000000000000001347626406500172335ustar00rootroot00000000000000opentest4j-r1.2.0/src/main/java/org/opentest4j/000077500000000000000000000000001347626406500213325ustar00rootroot00000000000000opentest4j-r1.2.0/src/main/java/org/opentest4j/AssertionFailedError.java000066400000000000000000000112401347626406500262610ustar00rootroot00000000000000/* * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.opentest4j; /** * {@code AssertionFailedError} is a common base class for test-related * {@link AssertionError AssertionErrors}. * *

In addition to a message and a cause, this class stores the expected * and actual values of an assertion using the {@link ValueWrapper} type. * * @author Sam Brannen * @author Marc Philipp * @since 1.0 */ public class AssertionFailedError extends AssertionError { private static final long serialVersionUID = 1L; private final ValueWrapper expected; private final ValueWrapper actual; /** * Constructs an {@code AssertionFailedError} with an empty message, no * cause, and no expected/actual values. */ public AssertionFailedError() { this(null); } /** * Constructs an {@code AssertionFailedError} with a message, no cause, * and no expected/actual values. * * @param message the detail message; {@code null} or blank will be * converted to the empty {@code String} */ public AssertionFailedError(String message) { this(message, null); } /** * Constructs an {@code AssertionFailedError} with a message and * expected/actual values but without a cause. * * @param message the detail message; {@code null} or blank will be * converted to the empty {@code String} * @param expected the expected value; may be {@code null} * @param actual the actual value; may be {@code null} */ public AssertionFailedError(String message, Object expected, Object actual) { this(message, expected, actual, null); } /** * Constructs an {@code AssertionFailedError} with a message and a cause * but without expected/actual values. * * @param message the detail message; {@code null} or blank will be * converted to the empty {@code String} * @param cause the cause of the failure */ public AssertionFailedError(String message, Throwable cause) { this(message, null, null, cause); } /** * Constructs an {@code AssertionFailedError} with a message, * expected/actual values, and a cause. * * @param message the detail message; {@code null} or blank will be * converted to the empty {@code String} * @param expected the expected value; may be {@code null} * @param actual the actual value; may be {@code null} * @param cause the cause of the failure */ public AssertionFailedError(String message, Object expected, Object actual, Throwable cause) { this(message, ValueWrapper.create(expected), ValueWrapper.create(actual), cause); } private AssertionFailedError(String message, ValueWrapper expected, ValueWrapper actual, Throwable cause) { super((message == null || message.trim().length() == 0) ? "" : message); this.expected = expected; this.actual = actual; initCause(cause); } /** * Returns {@code true} if an expected value was supplied via an * appropriate constructor. * * @see #getExpected() */ public boolean isExpectedDefined() { return this.expected != null; } /** * Returns {@code true} if an actual value was supplied via an * appropriate constructor. * * @see #getActual() */ public boolean isActualDefined() { return this.actual != null; } /** * Returns the wrapped expected value if it is defined; otherwise {@code null}. * * @see #isExpectedDefined() */ public ValueWrapper getExpected() { return this.expected; } /** * Returns the wrapped actual value if it is defined; otherwise {@code null}. * * @see #isActualDefined() */ public ValueWrapper getActual() { return this.actual; } /** * Returns a short description of this assertion error using the same format * as {@link Throwable#toString()}. * *

Since the constructors of this class convert supplied {@code null} or * blank messages to the empty {@code String}, this method only includes * non-empty messages in its return value. * * @return a string representation of this {@code AssertionFailedError} * @since 1.1.1 */ @Override public String toString() { String className = getClass().getName(); String message = getLocalizedMessage(); return ("".equals(message) ? className : (className + ": " + message)); } } opentest4j-r1.2.0/src/main/java/org/opentest4j/IncompleteExecutionException.java000066400000000000000000000025771347626406500300520ustar00rootroot00000000000000/* * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.opentest4j; /** * {@link RuntimeException} used to indicate that the execution of a test * was incomplete — for example, that the execution was entirely * skipped or aborted mid-stream. See subclasses for concrete use cases. * *

An {@code IncompleteExecutionException} is not used * to indicate that a test execution failed. * * @author Johannes Link * @author Sam Brannen * @since 1.0 */ public class IncompleteExecutionException extends RuntimeException { private static final long serialVersionUID = 1L; public IncompleteExecutionException() { } public IncompleteExecutionException(String message) { super(message); } public IncompleteExecutionException(String message, Throwable cause) { super(message, cause); } } opentest4j-r1.2.0/src/main/java/org/opentest4j/MultipleFailuresError.java000066400000000000000000000066631347626406500265100ustar00rootroot00000000000000/* * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.opentest4j; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * {@link MultipleFailuresError} is an {@link AssertionError} that aggregates * multiple failures thrown in a given context (i.e., typically within the * invocation of a single test). * * @author Johannes Link * @author Sam Brannen * @author Marc Philipp * @since 1.0 */ public class MultipleFailuresError extends AssertionError { private static final long serialVersionUID = 1L; private static final String EOL = System.getProperty("line.separator"); private final String heading; private final List failures; /** * Constructs an {@code MultipleFailuresError} with the supplied heading and * failures. * * @param heading the message heading; a default value will be used if * {@code null} or blank * @param failures the list of failures; must not be {@code null} or contain * {@code null} elements */ public MultipleFailuresError(String heading, List failures) { if (failures == null) { throw new NullPointerException("failures must not be null"); } this.heading = isBlank(heading) ? "Multiple Failures" : heading.trim(); this.failures = new ArrayList(); for (Throwable failure : failures) { if (failure == null) { throw new NullPointerException("failures must not contain null elements"); } this.failures.add(failure); } } @Override public String getMessage() { int failureCount = this.failures.size(); if (failureCount == 0) { return this.heading; } // @formatter:off StringBuilder builder = new StringBuilder(this.heading) .append(" (") .append(failureCount).append(" ") .append(pluralize(failureCount, "failure", "failures")) .append(")") .append(EOL); // @formatter:on int lastIndex = failureCount - 1; for (Throwable failure : this.failures.subList(0, lastIndex)) { builder.append("\t").append(nullSafeMessage(failure)).append(EOL); } builder.append('\t').append(nullSafeMessage(this.failures.get(lastIndex))); return builder.toString(); } /** * Returns the list of failures contained in this error. */ public List getFailures() { return Collections.unmodifiableList(this.failures); } /** * Returns whether this error contains any failures. */ public boolean hasFailures() { return !this.failures.isEmpty(); } private static boolean isBlank(String str) { return (str == null || str.trim().length() == 0); } private static String pluralize(int count, String singular, String plural) { return count == 1 ? singular : plural; } private static String nullSafeMessage(Throwable failure) { if (isBlank(failure.getMessage())) { return failure.getClass().getName() + ": "; } return failure.getClass().getName() + ": " + failure.getMessage(); } } opentest4j-r1.2.0/src/main/java/org/opentest4j/TestAbortedException.java000066400000000000000000000023321347626406500262740ustar00rootroot00000000000000/* * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.opentest4j; /** * Specialization of {@link IncompleteExecutionException} used to indicate * that a test was aborted during execution (e.g., due to a failed * assumption). * * @author Sam Brannen * @author Johannes Link * @since 1.0 * @see TestSkippedException */ public class TestAbortedException extends IncompleteExecutionException { private static final long serialVersionUID = 1L; public TestAbortedException() { } public TestAbortedException(String message) { super(message); } public TestAbortedException(String message, Throwable cause) { super(message, cause); } } opentest4j-r1.2.0/src/main/java/org/opentest4j/TestSkippedException.java000066400000000000000000000023471347626406500263210ustar00rootroot00000000000000/* * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.opentest4j; /** * Specialization of {@link IncompleteExecutionException} used to indicate * that a test was skipped prior to execution (e.g., disabled * or ignored). * * @author Sam Brannen * @author Johannes Link * @since 1.0 * @see TestAbortedException */ public class TestSkippedException extends IncompleteExecutionException { private static final long serialVersionUID = 1L; public TestSkippedException() { } public TestSkippedException(String message) { super(message); } public TestSkippedException(String message, Throwable cause) { super(message, cause); } } opentest4j-r1.2.0/src/main/java/org/opentest4j/ValueWrapper.java000066400000000000000000000145411347626406500246170ustar00rootroot00000000000000/* * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.opentest4j; import java.io.Serializable; /** * Serializable representation of a value that was used in an assertion. * *

This class only stores the value if it implements {@link Serializable}. * In any case, it stores its {@linkplain #getType() runtime type}, {@linkplain * #getIdentityHashCode() identity hash code}, and {@linkplain * #getStringRepresentation() string representation} determined via {@link * String#valueOf(Object)}. If the invocation of {@code String.valueOf(Object)} * throws an {@link Exception}, the string representation will take the form of * {@code ""}, where "e" is the caught * exception. * *

The {@link #toString()} method returns the string representation of the * value along with its type and identity hash code. * * @author Marc Philipp * @author Sam Brannen * @since 1.0 * @see System#identityHashCode */ public final class ValueWrapper implements Serializable { private static final long serialVersionUID = 1L; private static final ValueWrapper nullValueWrapper = new ValueWrapper(null); /** * Factory for creating a new {@code ValueWrapper} for the supplied {@code value}. * *

If the supplied {@code value} is {@code null}, this method will return a * cached {@code ValueWrapper} suitable for all {@code null} values. * If the supplied {@code value} is already an instance of {@link ValueWrapper}, * it will be returned as is. * * @param value the value to wrap; may be {@code null} * @return a wrapper for the supplied value; never {@code null} */ public static ValueWrapper create(Object value) { if (value instanceof ValueWrapper) return (ValueWrapper) value; return (value == null) ? nullValueWrapper : new ValueWrapper(value); } /** * Factory for creating a new {@code ValueWrapper} for the supplied {@code value} * using the supplied custom {@code stringRepresentation}. * *

You should use this method when you don't want to rely on the result of the * value's {@link Object#toString() toString()} method. * *

If the supplied {@code value} is {@code null}, this method will return a * cached {@code ValueWrapper} suitable for all {@code null} values. * If the supplied {@code value} is already an instance of {@link ValueWrapper}, * it will be returned as is if the {@code stringRepresentation} match, otherwise * the original value will be unwrapped and a new {@code ValueWrapper} with the * new {@code stringRepresentation} will be created. * * @param value the value to wrap; may be {@code null} * @param stringRepresentation a custom rendering of the value; will fallback to * the default behavior if {@code null} * @return a wrapper for the supplied value; never {@code null} * @since 1.2 */ public static ValueWrapper create(Object value, String stringRepresentation) { if (value instanceof ValueWrapper) { ValueWrapper wrapper = (ValueWrapper) value; return wrapper.stringRepresentation.equals(stringRepresentation) ? wrapper : create(wrapper.value, stringRepresentation); } return (value == null ? nullValueWrapper : new ValueWrapper(value, stringRepresentation)); } private final Serializable value; private final Class type; private final String stringRepresentation; private final int identityHashCode; private final transient Object ephemeralValue; /** * Reads and stores the supplied value's runtime type, string representation, and * identity hash code. */ private ValueWrapper(Object value, String stringRepresentation) { this.value = value instanceof Serializable ? (Serializable) value : null; this.type = value != null ? value.getClass() : null; this.stringRepresentation = stringRepresentation == null ? safeValueToString(value) : stringRepresentation; this.identityHashCode = System.identityHashCode(value); this.ephemeralValue = value; } private ValueWrapper(Object value) { this(value, safeValueToString(value)); } private static String safeValueToString(Object value) { try { return String.valueOf(value); } catch (Exception e) { return ""; } } /** * Returns the value supplied to {@link #create(Object)} if the value * implements {@link Serializable}; otherwise, {@code null}. * * @see #getEphemeralValue() */ public Serializable getValue() { return this.value; } /** * Returns the value's runtime type or {@code null} if the value is * {@code null}. */ public Class getType() { return this.type; } /** * Returns the value's string representation. * *

The string representation is generated by invoking * {@link String#valueOf(Object) String.valueOf(value)} for the value * supplied to {@link #create(Object)}. * * @see #getValue() */ public String getStringRepresentation() { return this.stringRepresentation; } /** * Returns the value's identity hash code. * *

The identity hash code is generated by invoking * {@link System#identityHashCode(Object) System.identityHashCode(value)} * for the value supplied to {@link #create(Object)}. * * @see #getValue() */ public int getIdentityHashCode() { return this.identityHashCode; } /** * Returns the original value supplied to {@link #create(Object) create()}. * *

If this {@code ValueWrapper} was created by deserialization this method * returns {@code null}. * * @see #getValue() * @since 1.2 */ public Object getEphemeralValue() { return this.ephemeralValue; } /** * Returns the value's string representation along with its type and * identity hash code. */ @Override public String toString() { if (this.type == null) { return "null"; } return this.stringRepresentation + // " (" + this.type.getName() + "@" + Integer.toHexString(this.identityHashCode) + ")"; } } opentest4j-r1.2.0/src/main/java/org/opentest4j/package-info.java000066400000000000000000000002761347626406500245260ustar00rootroot00000000000000/** * Common {@link java.lang.AssertionError AssertionErrors} and * {@link java.lang.RuntimeException RuntimeExceptions} for testing * frameworks on the JVM. */ package org.opentest4j; opentest4j-r1.2.0/src/module/000077500000000000000000000000001347626406500160645ustar00rootroot00000000000000opentest4j-r1.2.0/src/module/java/000077500000000000000000000000001347626406500170055ustar00rootroot00000000000000opentest4j-r1.2.0/src/module/java/org.opentest4j/000077500000000000000000000000001347626406500216725ustar00rootroot00000000000000opentest4j-r1.2.0/src/module/java/org.opentest4j/module-info.java000066400000000000000000000000631347626406500247520ustar00rootroot00000000000000module org.opentest4j { exports org.opentest4j; } opentest4j-r1.2.0/src/test/000077500000000000000000000000001347626406500155565ustar00rootroot00000000000000opentest4j-r1.2.0/src/test/java/000077500000000000000000000000001347626406500164775ustar00rootroot00000000000000opentest4j-r1.2.0/src/test/java/org/000077500000000000000000000000001347626406500172665ustar00rootroot00000000000000opentest4j-r1.2.0/src/test/java/org/opentest4j/000077500000000000000000000000001347626406500213655ustar00rootroot00000000000000opentest4j-r1.2.0/src/test/java/org/opentest4j/AssertionFailedErrorTests.java000066400000000000000000000204451347626406500273460ustar00rootroot00000000000000/* * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.opentest4j; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import org.junit.Test; /** * Unit tests for {@link AssertionFailedError}. * * @author Marc Philipp * @author Sam Brannen * @since 1.0 */ public class AssertionFailedErrorTests { private static final String EMPTY = ""; private static final String BLANK = " "; @Test public void defaultConstructorUsesEmptyMessage() { assertEquals(EMPTY, new AssertionFailedError().getMessage()); } @Test public void nullMessageIsConvertedToEmptyMessage() { assertEquals(EMPTY, new AssertionFailedError(null).getMessage()); assertEquals(EMPTY, new AssertionFailedError(null, null).getMessage()); assertEquals(EMPTY, new AssertionFailedError(null, "foo", "bar").getMessage()); assertEquals(EMPTY, new AssertionFailedError(null, "foo", "bar", null).getMessage()); } @Test public void blankMessageIsConvertedToEmptyMessage() { assertEquals(EMPTY, new AssertionFailedError(BLANK).getMessage()); assertEquals(EMPTY, new AssertionFailedError(BLANK, null).getMessage()); assertEquals(EMPTY, new AssertionFailedError(BLANK, "foo", "bar").getMessage()); assertEquals(EMPTY, new AssertionFailedError(BLANK, "foo", "bar", null).getMessage()); } @Test public void toStringChecks() { String className = AssertionFailedError.class.getName(); assertEquals(className, new AssertionFailedError().toString()); assertEquals(className, new AssertionFailedError(null).toString()); assertEquals(className, new AssertionFailedError(null, "foo", "bar").toString()); assertEquals(className, new AssertionFailedError(null, new RuntimeException()).toString()); assertEquals(className, new AssertionFailedError(null, "foo", "bar", new RuntimeException()).toString()); assertEquals(className, new AssertionFailedError(EMPTY).toString()); assertEquals(className, new AssertionFailedError(EMPTY, "foo", "bar").toString()); assertEquals(className, new AssertionFailedError(EMPTY, new RuntimeException()).toString()); assertEquals(className, new AssertionFailedError(EMPTY, "foo", "bar", new RuntimeException()).toString()); assertEquals(className, new AssertionFailedError(BLANK).toString()); assertEquals(className, new AssertionFailedError(BLANK, "foo", "bar").toString()); assertEquals(className, new AssertionFailedError(BLANK, new RuntimeException()).toString()); assertEquals(className, new AssertionFailedError(BLANK, "foo", "bar", new RuntimeException()).toString()); assertEquals(className + ": message", new AssertionFailedError("message").toString()); assertEquals(className + ": message", new AssertionFailedError("message", "foo", "bar").toString()); assertEquals(className + ": message", new AssertionFailedError("message", new RuntimeException()).toString()); assertEquals(className + ": message", new AssertionFailedError("message", "foo", "bar", new RuntimeException()).toString()); } @Test public void messageAndCauseAreStored() { RuntimeException cause = new RuntimeException("cause"); AssertionFailedError error = new AssertionFailedError("my message", cause); assertEquals("my message", error.getMessage()); assertEquals(cause, error.getCause()); assertFalse(error.isExpectedDefined()); assertFalse(error.isActualDefined()); } @Test public void expectedAndActualValuesAreStored() { AssertionFailedError errorWithExpectedAndActual = new AssertionFailedError(null, "foo", "bar"); assertTrue(errorWithExpectedAndActual.isExpectedDefined()); assertEquals("foo", errorWithExpectedAndActual.getExpected().getValue()); assertTrue(errorWithExpectedAndActual.isActualDefined()); assertEquals("bar", errorWithExpectedAndActual.getActual().getValue()); } @Test public void returnsNullForExpectedAndActualWhenNotPassedToConstructor() { AssertionFailedError errorWithoutExpectedAndActual = new AssertionFailedError(); assertFalse(errorWithoutExpectedAndActual.isExpectedDefined()); assertNull(errorWithoutExpectedAndActual.getExpected()); assertFalse(errorWithoutExpectedAndActual.isActualDefined()); assertNull(errorWithoutExpectedAndActual.getActual()); } @Test public void serializationWorksForAssertionFailedErrorWithMessageAndExpectedAndActualValues() throws Exception { AssertionFailedError error = serializeAndDeserialize(new AssertionFailedError("a message", "foo", "bar")); assertEquals("a message", error.getMessage()); assertTrue(error.isExpectedDefined()); assertEquals("foo", error.getExpected().getValue()); assertTrue(error.isActualDefined()); assertEquals("bar", error.getActual().getValue()); } @Test public void serializationWorksForAssertionFailedErrorWithoutAnyValues() throws Exception { AssertionFailedError error = serializeAndDeserialize(new AssertionFailedError()); assertEquals(EMPTY, error.getMessage()); assertFalse(error.isExpectedDefined()); assertNull(error.getExpected()); assertFalse(error.isActualDefined()); assertNull(error.getActual()); } @Test public void deserializationOfAssertionFailedErrorWorksForVersion_1_0_0() throws Exception { // Generated using: // FileOutputStream outputStream = new FileOutputStream("src/test/resources/AssertionFailedError_serializedVersion_1_0_0.out"); // serialize(new AssertionFailedError("message", "foo", "bar"), outputStream); // outputStream.close(); AssertionFailedError error = (AssertionFailedError) deserializeClasspathResource( "/AssertionFailedError_serializedVersion_1_0_0.out"); assertEquals("message", error.getMessage()); assertTrue(error.isExpectedDefined()); assertEquals("foo", error.getExpected().getValue()); assertTrue(error.isActualDefined()); assertEquals("bar", error.getActual().getValue()); } @Test public void ephemeralValueIsOmittedFromSerialization() throws Exception { class NonSerializable { public final String guid = "8675309"; } AssertionFailedError error = serializeAndDeserialize( new AssertionFailedError("a message", new NonSerializable(), new NonSerializable())); assertEquals("a message", error.getMessage()); assertTrue(error.isExpectedDefined()); assertNull(error.getExpected().getValue()); assertNull(error.getExpected().getEphemeralValue()); assertTrue(error.isActualDefined()); assertNull(error.getActual().getValue()); assertNull(error.getActual().getEphemeralValue()); } private Object deserializeClasspathResource(String name) throws Exception { InputStream inputStream = getClass().getResourceAsStream(name); try { return deserialize(inputStream); } finally { inputStream.close(); } } private AssertionFailedError serializeAndDeserialize(AssertionFailedError originalError) throws Exception { byte[] bytes = serialize(originalError); Object deserializedObject = deserialize(new ByteArrayInputStream(bytes)); assertEquals(AssertionFailedError.class, deserializedObject.getClass()); return (AssertionFailedError) deserializedObject; } private Object deserialize(InputStream inputStream) throws Exception { ObjectInputStream in = new ObjectInputStream(inputStream); return in.readObject(); } private byte[] serialize(Object object) throws Exception { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); serialize(object, byteArrayOutputStream); return byteArrayOutputStream.toByteArray(); } private void serialize(Object object, OutputStream outputStream) throws Exception { ObjectOutputStream out = new ObjectOutputStream(outputStream); out.writeObject(object); out.flush(); } } opentest4j-r1.2.0/src/test/java/org/opentest4j/MultipleFailuresErrorTests.java000066400000000000000000000105421347626406500275550ustar00rootroot00000000000000/* * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.opentest4j; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; import org.junit.Test; /** * Unit tests for {@link MultipleFailuresError}. * * @author Marc Philipp * @author Sam Brannen * @since 1.0 */ public class MultipleFailuresErrorTests { private static final String DEFAULT_HEADING = "Multiple Failures"; private static final String HEADING = "Custom Heading"; @Test public void mfeWithNoFailuresWithNullHeading() { assertExceptionWithNoFailures(null, DEFAULT_HEADING); } @Test public void mfeWithNoFailuresWithEmptyHeading() { assertExceptionWithNoFailures(" ", DEFAULT_HEADING); } @Test public void mfeWithNoFailuresWithCustomHeading() { assertExceptionWithNoFailures(HEADING, HEADING); } @Test public void mfeWithSingleFailureWithNullHeading() { assertExceptionWithSingleFailure(null, DEFAULT_HEADING); } @Test public void mfeWithSingleFailureWithEmptyHeading() { assertExceptionWithSingleFailure(" ", DEFAULT_HEADING); } @Test public void mfeWithSingleFailureWithCustomHeading() { assertExceptionWithSingleFailure(HEADING, HEADING); } @Test public void mfeWithFailuresWithNullHeading() { assertExceptionWithFailures(null, DEFAULT_HEADING); } @Test public void mfeWithFailuresWithEmptyHeading() { assertExceptionWithFailures(" ", DEFAULT_HEADING); } @Test public void mfeWithFailuresWithCustomHeading() { assertExceptionWithFailures(HEADING, HEADING); } @Test public void mfeWithNullMessageFailures() throws Exception { List failures = new ArrayList(); failures.add(new AssertionError()); failures.add(new AssertionFailedError()); MultipleFailuresError mfe = new MultipleFailuresError(HEADING, failures); assertEquals(String.format("%s %s%n\t%s%n\t%s", HEADING, "(2 failures)", // "java.lang.AssertionError: ", // "org.opentest4j.AssertionFailedError: "), // mfe.getMessage()); } @Test(expected = NullPointerException.class) public void mfeThrowsNPEForNullFailureElements() { List failures = new ArrayList(); failures.add(new AssertionError()); failures.add(null); new MultipleFailuresError("", failures); } private void assertExceptionWithNoFailures(String inputHeading, String outputHeading) { MultipleFailuresError mfe = new MultipleFailuresError(inputHeading, new ArrayList()); assertTrue(mfe.getFailures().isEmpty()); assertFalse(mfe.hasFailures()); assertEquals(outputHeading, mfe.getMessage()); } private void assertExceptionWithSingleFailure(String inputHeading, String outputHeading) { List failures = new ArrayList(); failures.add(new AssertionError("failure 1")); MultipleFailuresError mfe = new MultipleFailuresError(inputHeading, failures); assertEquals(1, mfe.getFailures().size()); assertTrue(mfe.hasFailures()); assertEquals( String.format("%s %s%n\t%s: %s", outputHeading, "(1 failure)", AssertionError.class.getName(), "failure 1"), mfe.getMessage()); } private void assertExceptionWithFailures(String inputHeading, String outputHeading) { List failures = new ArrayList(); failures.add(new AssertionError("failure 1")); failures.add(new AssertionError("failure 2")); String assertErrorClassName = AssertionError.class.getName(); MultipleFailuresError mfe = new MultipleFailuresError(inputHeading, failures); assertEquals(2, mfe.getFailures().size()); assertTrue(mfe.hasFailures()); assertEquals(String.format("%s %s%n\t%s: %s%n\t%s: %s", outputHeading, "(2 failures)", assertErrorClassName, "failure 1", assertErrorClassName, "failure 2"), mfe.getMessage()); } } opentest4j-r1.2.0/src/test/java/org/opentest4j/ValueWrapperTests.java000066400000000000000000000117011347626406500256700ustar00rootroot00000000000000/* * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.opentest4j; import static org.junit.Assert.*; import java.io.Serializable; import org.junit.Test; /** * Unit tests for {@link ValueWrapper}. * * @author Marc Philipp * @author Sam Brannen * @since 1.0 */ public class ValueWrapperTests { @Test public void wrapsNull() { ValueWrapper wrapper = ValueWrapper.create(null); assertNull(wrapper.getType()); assertNull(wrapper.getValue()); assertEquals("null", wrapper.getStringRepresentation()); assertEquals(0, wrapper.getIdentityHashCode()); assertEquals("null", wrapper.toString()); assertNull(wrapper.getEphemeralValue()); } @Test public void wrapsSerializableValue() { ValueWrapper wrapper = ValueWrapper.create(1.2d); assertEquals(Double.class, wrapper.getType()); assertEquals(1.2d, wrapper.getValue()); assertEquals("1.2", wrapper.getStringRepresentation()); assertNotEquals(0, wrapper.getIdentityHashCode()); assertTrue(wrapper.toString().startsWith("1.2 (java.lang.Double@")); assertTrue(wrapper.toString().endsWith(")")); assertEquals(1.2D, wrapper.getEphemeralValue()); assertSame(wrapper.getValue(), wrapper.getEphemeralValue()); } @Test public void acceptsCustomStringRepresentation() { ValueWrapper wrapper = ValueWrapper.create(1.2d, "1,20"); assertEquals(Double.class, wrapper.getType()); assertEquals(1.2d, wrapper.getValue()); assertEquals("1,20", wrapper.getStringRepresentation()); assertNotEquals(0, wrapper.getIdentityHashCode()); assertTrue(wrapper.toString().startsWith("1,20 (java.lang.Double@")); assertTrue(wrapper.toString().endsWith(")")); } @Test public void doesNotWrapAnotherValueWrapper() { ValueWrapper wrapper = ValueWrapper.create(1.2d); ValueWrapper same = ValueWrapper.create(wrapper); assertSame(wrapper, same); } @Test public void doesNotWrapAnotherValueWrapperWithSameCustomRepresentation() { ValueWrapper wrapper = ValueWrapper.create(1.2d, "1,20"); ValueWrapper same = ValueWrapper.create(wrapper, "1,20"); assertSame(wrapper, same); } @Test public void doesRepackageValueWrapperWithDifferentStringRepresentation() { ValueWrapper wrapper = ValueWrapper.create(1.2d); ValueWrapper same = ValueWrapper.create(wrapper, "1,20"); assertNotSame(wrapper, same); } @Test public void nullForCustomStringRepresentationFallsBackToDefaultToString() { ValueWrapper wrapper = ValueWrapper.create(1.2d, null); assertEquals(Double.class, wrapper.getType()); assertEquals(1.2d, wrapper.getValue()); assertEquals("1.2", wrapper.getStringRepresentation()); assertNotEquals(0, wrapper.getIdentityHashCode()); assertTrue(wrapper.toString().startsWith("1.2 (java.lang.Double@")); assertTrue(wrapper.toString().endsWith(")")); } @Test public void wrapsNonSerializableValue() { class NonSerializable { @Override public String toString() { return "someString"; } } NonSerializable value = new NonSerializable(); ValueWrapper wrapper = ValueWrapper.create(value); assertEquals(NonSerializable.class, wrapper.getType()); assertNull(wrapper.getValue()); assertEquals("someString", wrapper.getStringRepresentation()); assertNotEquals(0, wrapper.getIdentityHashCode()); assertEquals(value, wrapper.getEphemeralValue()); String toString = wrapper.toString(); assertTrue(toString, toString.startsWith("someString (" + NonSerializable.class.getName() + "@")); assertTrue(toString, toString.endsWith(")")); } @Test public void wrapsWithBrokenToString() { class BrokenToString implements Serializable { private static final long serialVersionUID = -3072024134414066195L; @Override public String toString() { throw new RuntimeException("toStringFailure"); } } BrokenToString value = new BrokenToString(); ValueWrapper wrapper = ValueWrapper.create(value); assertEquals(BrokenToString.class, wrapper.getType()); assertEquals(value, wrapper.getValue()); assertEquals(value, wrapper.getEphemeralValue()); String representation = wrapper.getStringRepresentation(); assertTrue(representation, representation.contains(RuntimeException.class.getName())); assertTrue(representation, representation.contains("toStringFailure")); assertNotEquals(0, wrapper.getIdentityHashCode()); String toString = wrapper.toString(); assertTrue(toString, toString.contains(RuntimeException.class.getName())); assertTrue(toString, toString.contains("toStringFailure")); } } opentest4j-r1.2.0/src/test/resources/000077500000000000000000000000001347626406500175705ustar00rootroot00000000000000opentest4j-r1.2.0/src/test/resources/AssertionFailedError_serializedVersion_1_0_0.out000066400000000000000000000050561347626406500310540ustar00rootroot00000000000000sr#org.opentest4j.AssertionFailedErrorLactualtLorg/opentest4j/ValueWrapper;Lexpectedq~xrjava.lang.AssertionErrorm.A=xrjava.lang.ErrorE6VVxrjava.lang.Throwable5'9wLcausetLjava/lang/Throwable;L detailMessagetLjava/lang/String;[ stackTracet[Ljava/lang/StackTraceElement;LsuppressedExceptionstLjava/util/List;xpptmessageur[Ljava.lang.StackTraceElement;F*<<"9xpsrjava.lang.StackTraceElementa Ś&6݅I lineNumberLdeclaringClassq~LfileNameq~L methodNameq~xpvt(org.opentest4j.AssertionFailedErrorTeststAssertionFailedErrorTests.javat:deserializationOfAssertionFailedErrorWorksForVersion_1_0_0sq~ t$sun.reflect.NativeMethodAccessorImpltNativeMethodAccessorImpl.javatinvoke0sq~ >q~q~tinvokesq~ +t(sun.reflect.DelegatingMethodAccessorImplt!DelegatingMethodAccessorImpl.javaq~sq~ tjava.lang.reflect.Methodt Method.javaq~sq~ 2t)org.junit.runners.model.FrameworkMethod$1tFrameworkMethod.javatrunReflectiveCallsq~ t3org.junit.internal.runners.model.ReflectiveCallabletReflectiveCallable.javatrunsq~ /t'org.junit.runners.model.FrameworkMethodq~ tinvokeExplosivelysq~ t2org.junit.internal.runners.statements.InvokeMethodtInvokeMethod.javatevaluatesq~ Etorg.junit.runners.ParentRunnertParentRunner.javatrunLeafsq~ Nt(org.junit.runners.BlockJUnit4ClassRunnertBlockJUnit4ClassRunner.javatrunChildsq~ 9q~2q~3q~4sq~ "t org.junit.runners.ParentRunner$3q~/q~%sq~ Gt org.junit.runners.ParentRunner$1q~/tschedulesq~  q~.q~/t runChildrensq~ :q~.q~/t access$000sq~  t org.junit.runners.ParentRunner$2q~/q~,sq~ kq~.q~/q~%sq~ torg.junit.runner.JUnitCoretJUnitCore.javaq~%sq~ Dt(com.intellij.junit4.JUnit4IdeaTestRunnertJUnit4IdeaTestRunner.javatstartRunnerWithArgssq~ /t7com.intellij.rt.execution.junit.IdeaTestRunner$RepeatertIdeaTestRunner.javaq~Hsq~ t,com.intellij.rt.execution.junit.JUnitStartertJUnitStarter.javatprepareStreamsAndStartsq~ Fq~Mq~Ntmainsr&java.util.Collections$UnmodifiableList%1Llistq~xr,java.util.Collections$UnmodifiableCollectionB^LctLjava/util/Collection;xpsrjava.util.ArrayListxaIsizexpwxq~Wxsrorg.opentest4j.ValueWrapperIidentityHashCodeLstringRepresentationq~LtypetLjava/lang/Class;LvaluetLjava/io/Serializable;xp5tbarvrjava.lang.String8z;Bxpq~\sq~X #tfooq~^q~`