├── .github ├── FUNDING.yml ├── PULL_REQUEST_TEMPLATE.md ├── renovate.json5 ├── actions │ └── run-gradle │ │ └── action.yml └── workflows │ └── main.yml ├── .gitattributes ├── gradle ├── gradle-daemon-jvm.properties └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src ├── module │ └── java │ │ └── org.opentest4j │ │ └── module-info.java ├── test │ ├── resources │ │ └── AssertionFailedError_serializedVersion_1_0_0.out │ └── java │ │ └── org │ │ └── opentest4j │ │ ├── FileInfoTests.java │ │ ├── MultipleFailuresErrorTests.java │ │ ├── ValueWrapperTests.java │ │ └── AssertionFailedErrorTests.java └── main │ └── java │ └── org │ └── opentest4j │ ├── package-info.java │ ├── TestAbortedException.java │ ├── TestSkippedException.java │ ├── IncompleteExecutionException.java │ ├── MultipleFailuresError.java │ ├── FileInfo.java │ ├── AssertionFailedError.java │ └── ValueWrapper.java ├── gradle.properties ├── .gitignore ├── settings.gradle ├── COPYRIGHT ├── etc ├── spotless │ └── apache-license-2.0.java └── eclipse │ └── eclipse-formatter-settings.xml ├── SECURITY.md ├── CONTRIBUTING.md ├── .travis.yml ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: https://junit.org/sponsoring 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | *.bat text eol=crlf 3 | *.jar binary 4 | -------------------------------------------------------------------------------- /gradle/gradle-daemon-jvm.properties: -------------------------------------------------------------------------------- 1 | #This file is generated by updateDaemonJvm 2 | toolchainVersion=21 3 | -------------------------------------------------------------------------------- /src/module/java/org.opentest4j/module-info.java: -------------------------------------------------------------------------------- 1 | module org.opentest4j { 2 | exports org.opentest4j; 3 | } 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota4j-team/opentest4j/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Overview 2 | 3 | - 4 | 5 | --- 6 | I hereby agree to the terms of the Open Test Alliance Contributor License Agreement. 7 | -------------------------------------------------------------------------------- /.github/renovate.json5: -------------------------------------------------------------------------------- 1 | { 2 | $schema: 'https://docs.renovatebot.com/renovate-schema.json', 3 | extends: [ 4 | 'github>junit-team/renovate-config', 5 | ], 6 | } 7 | -------------------------------------------------------------------------------- /src/test/resources/AssertionFailedError_serializedVersion_1_0_0.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota4j-team/opentest4j/HEAD/src/test/resources/AssertionFailedError_serializedVersion_1_0_0.out -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | group = org.opentest4j 2 | version = 1.4.0-SNAPSHOT 3 | 4 | junit4Version = 4.13.2 5 | 6 | defaultBuiltBy = OTA4J Team 7 | 8 | org.gradle.java.installations.fromEnv=JDK11 9 | -------------------------------------------------------------------------------- /src/main/java/org/opentest4j/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Common {@link java.lang.AssertionError AssertionErrors} and 3 | * {@link java.lang.RuntimeException RuntimeExceptions} for testing 4 | * frameworks on the JVM. 5 | */ 6 | 7 | package org.opentest4j; 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Gradle 2 | .gradle 3 | build/ 4 | 5 | # Ignore Gradle GUI config 6 | gradle-app.setting 7 | 8 | # Eclipse 9 | .classpath 10 | .settings/ 11 | .project 12 | bin/ 13 | 14 | # IntelliJ 15 | *.iml 16 | *.ipr 17 | *.iws 18 | *.uml 19 | .idea/ 20 | out/ 21 | 22 | # Misc 23 | *.log 24 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionSha256Sum=72f44c9f8ebcb1af43838f45ee5c4aa9c5444898b3468ab3f4af7b6076c5bc3f 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip 5 | networkTimeout=10000 6 | validateDistributionUrl=true 7 | zipStoreBase=GRADLE_USER_HOME 8 | zipStorePath=wrapper/dists 9 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.gradle.develocity") version "4.3" 3 | id("com.gradle.common-custom-user-data-gradle-plugin") version "2.4.0" 4 | } 5 | 6 | rootProject.name = 'opentest4j' 7 | 8 | develocity { 9 | buildScan { 10 | def isCiServer = System.getenv("CI") != null 11 | 12 | server = "https://ge.junit.org" 13 | uploadInBackground = !isCiServer 14 | 15 | obfuscation { 16 | if (isCiServer) { 17 | username { "github" } 18 | } else { 19 | hostname { null } 20 | ipAddresses { [] } 21 | } 22 | } 23 | 24 | publishing.onlyIf { it.authenticated } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright 2015-2023 the original author or authors. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /etc/spotless/apache-license-2.0.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2025 the original author or authors. 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 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | ------- | ------------------ | 7 | | 1.3.x | :white_check_mark: | 8 | | < 1.3 | :x: | 9 | 10 | ## Reporting a Vulnerability 11 | 12 | To report a security vulnerability, you have two options: 13 | 14 | - [Privately report a vulnerability](https://github.com/ota4j-team/opentest4j/security/advisories/new) on GitHub (see [docs](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability) for details) 15 | - Send an email to security@junit.org. You can use the [published OpenPGP key](https://keys.openpgp.org/search?q=security%40junit.org) with fingerprint `0152DA30EABC7ABADCB09D10D9A6B1329D191D25` to encrypt the message body. 16 | -------------------------------------------------------------------------------- /.github/actions/run-gradle/action.yml: -------------------------------------------------------------------------------- 1 | name: Run Gradle 2 | description: Sets up Gradle JDKs and runs Gradle 3 | inputs: 4 | arguments: 5 | required: true 6 | description: Gradle arguments 7 | default: build 8 | runs: 9 | using: "composite" 10 | steps: 11 | - uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0 12 | id: setup-toolchain-jdk 13 | with: 14 | distribution: temurin 15 | java-version: 11 16 | - uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0 17 | id: setup-gradle-jdk 18 | with: 19 | distribution: temurin 20 | java-version: 21 21 | - uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0 22 | - shell: bash 23 | env: 24 | JDK11: ${{ steps.setup-toolchain-jdk.outputs.path }} 25 | JAVA_HOME: ${{ steps.setup-gradle-jdk.outputs.path }} 26 | run: | 27 | ./gradlew \ 28 | -Porg.gradle.java.installations.auto-download=false \ 29 | javaToolchains \ 30 | ${{ inputs.arguments }} 31 | -------------------------------------------------------------------------------- /src/main/java/org/opentest4j/TestAbortedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2025 the original author or authors. 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 org.opentest4j; 18 | 19 | /** 20 | * Specialization of {@link IncompleteExecutionException} used to indicate 21 | * that a test was aborted during execution (e.g., due to a failed 22 | * assumption). 23 | * 24 | * @author Sam Brannen 25 | * @author Johannes Link 26 | * @since 1.0 27 | * @see TestSkippedException 28 | */ 29 | public class TestAbortedException extends IncompleteExecutionException { 30 | 31 | private static final long serialVersionUID = 1L; 32 | 33 | public TestAbortedException() { 34 | } 35 | 36 | public TestAbortedException(String message) { 37 | super(message); 38 | } 39 | 40 | public TestAbortedException(String message, Throwable cause) { 41 | super(message, cause); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/opentest4j/TestSkippedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2025 the original author or authors. 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 org.opentest4j; 18 | 19 | /** 20 | * Specialization of {@link IncompleteExecutionException} used to indicate 21 | * that a test was skipped prior to execution (e.g., disabled 22 | * or ignored). 23 | * 24 | * @author Sam Brannen 25 | * @author Johannes Link 26 | * @since 1.0 27 | * @see TestAbortedException 28 | */ 29 | public class TestSkippedException extends IncompleteExecutionException { 30 | 31 | private static final long serialVersionUID = 1L; 32 | 33 | public TestSkippedException() { 34 | } 35 | 36 | public TestSkippedException(String message) { 37 | super(message); 38 | } 39 | 40 | public TestSkippedException(String message, Throwable cause) { 41 | super(message, cause); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/opentest4j/IncompleteExecutionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2025 the original author or authors. 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 org.opentest4j; 18 | 19 | /** 20 | * {@link RuntimeException} used to indicate that the execution of a test 21 | * was incomplete — for example, that the execution was entirely 22 | * skipped or aborted mid-stream. See subclasses for concrete use cases. 23 | * 24 | *
An {@code IncompleteExecutionException} is not used 25 | * to indicate that a test execution failed. 26 | * 27 | * @author Johannes Link 28 | * @author Sam Brannen 29 | * @since 1.0 30 | */ 31 | public class IncompleteExecutionException extends RuntimeException { 32 | 33 | private static final long serialVersionUID = 1L; 34 | 35 | public IncompleteExecutionException() { 36 | } 37 | 38 | public IncompleteExecutionException(String message) { 39 | super(message); 40 | } 41 | 42 | public IncompleteExecutionException(String message, Throwable cause) { 43 | super(message, cause); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Open Test Alliance Contributor License Agreement 4 | 5 | **Project License:** [Apache License Version 2.0](LICENSE) 6 | 7 | - You will only Submit Contributions where You have authored 100% of the content. 8 | - 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. 9 | - Whatever content You Contribute will be provided under the Project License(s). 10 | 11 | ## Pull Requests 12 | 13 | Please add the following lines to your pull request description: 14 | 15 | ```markdown 16 | --- 17 | 18 | I hereby agree to the terms of the Open Test Alliance Contributor License Agreement. 19 | ``` 20 | 21 | ## Coding Conventions 22 | 23 | ### Formatting 24 | 25 | Code formatting is enforced using the [Spotless](https://github.com/diffplug/spotless) 26 | Gradle plugin. You can use `gradle spotlessApply` to format new code and add missing 27 | license headers to source files. Formatter settings for Eclipse are available 28 | [in the repository](https://github.com/ota4j-team/opentest4j/blob/master/etc/eclipse/eclipse-formatter-settings.xml). 29 | For IntelliJ IDEA there's a [plugin](https://plugins.jetbrains.com/plugin/6546) you can use. 30 | 31 | ### Javadoc 32 | 33 | - Javadoc comments should be wrapped after 80 characters whenever possible. 34 | - This first paragraph must be a single, concise sentence that ends with a period ("."). 35 | - Place `
` on the same line as the first line in a new paragraph and precede `
` with a blank line.
36 | - Insert a blank line before at-clauses/tags.
37 | - Favor `{@code foo}` over ` Its main use case is for {@code actual} and {@code expected} values in
27 | * {@code AssertionFailedError}.
28 | *
29 | * The semantics of the {@code path} can be defined by the users of this
30 | * class.
31 | *
32 | * @author Marc Philipp
33 | * @author Reinhold Degenfellner
34 | * @since 1.3
35 | */
36 | public class FileInfo implements Serializable {
37 |
38 | private static final long serialVersionUID = 1L;
39 |
40 | private final String path;
41 | private final byte[] contents;
42 |
43 | /**
44 | * Constructs a {@code FileInfo} with a path to a file and the contents of
45 | * the file.
46 | *
47 | * Be cautious with large files (limiting the size may be a good idea).
48 | *
49 | * The supplied byte array is not copied to avoid unnecessary memory
50 | * allocations. However, callers of this constructors should not modify the
51 | * byte array after calling this constructor. This behavior may change
52 | * in a future release without prior notice.
53 | *
54 | * @param path the path to the file; must not be {@code null}
55 | * @param contents the contents of the file; must not be {@code null};
56 | */
57 | public FileInfo(String path, byte[] contents) {
58 | if (contents == null) {
59 | throw new NullPointerException("contents must not be null");
60 | }
61 | validatePath(path);
62 | this.contents = contents;
63 | this.path = path;
64 | }
65 |
66 | private static void validatePath(String path) {
67 | if (path == null || path.trim().isEmpty()) {
68 | throw new NullPointerException("path must not be null or blank");
69 | }
70 | }
71 |
72 | /**
73 | * Returns the path to the file.
74 | *
75 | * @return the path to the file; never {@code null}
76 | */
77 | public String getPath() {
78 | return path;
79 | }
80 |
81 | /**
82 | * Returns the contents of the file.
83 | *
84 | * This method does currently not return a defensive copy of the
85 | * contained byte array to avoid unnecessary memory allocations. However,
86 | * callers of this method should not modify the returned byte array. This
87 | * behavior may change in a future release without prior notice.
88 | *
89 | * @return the contents of the file; never {@code null}
90 | */
91 | public byte[] getContents() {
92 | return contents;
93 | }
94 |
95 | /**
96 | * Returns the contents of the file as a {@code String}.
97 | *
98 | * @return the contents of the file as a {@code String}; never {@code null}
99 | */
100 | public String getContentsAsString(Charset charset) {
101 | return new String(contents, charset);
102 | }
103 |
104 | /**
105 | * Determines if the supplied object is an instance of {@code FileInfo}
106 | * with the same path and contents as this {@code FileInfo}.
107 | */
108 | @Override
109 | public boolean equals(Object obj) {
110 | if (this == obj) {
111 | return true;
112 | }
113 | if (obj == null || getClass() != obj.getClass()) {
114 | return false;
115 | }
116 | FileInfo that = (FileInfo) obj;
117 | return this.path.equals(that.path) && Arrays.equals(this.contents, that.contents);
118 | }
119 |
120 | /**
121 | * Generates a unique hash code for this {@code FileInfo} based
122 | * on its {@link #getPath() path}.
123 | */
124 | @Override
125 | public int hashCode() {
126 | return path.hashCode();
127 | }
128 |
129 | /**
130 | * Generates a string representation of this {@code FileInfo} based
131 | * on the {@link #getPath() path} and {@link #getContents() contents}.
132 | */
133 | @Override
134 | public String toString() {
135 | return "FileInfo[path='" + this.path + "', contents containing " + this.contents.length + " bytes]";
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/src/test/java/org/opentest4j/MultipleFailuresErrorTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2025 the original author or authors.
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 org.opentest4j;
18 |
19 | import static org.junit.Assert.assertEquals;
20 | import static org.junit.Assert.assertFalse;
21 | import static org.junit.Assert.assertTrue;
22 |
23 | import java.util.ArrayList;
24 | import java.util.List;
25 |
26 | import org.junit.Test;
27 |
28 | /**
29 | * Unit tests for {@link MultipleFailuresError}.
30 | *
31 | * @author Marc Philipp
32 | * @author Sam Brannen
33 | * @since 1.0
34 | */
35 | public class MultipleFailuresErrorTests {
36 |
37 | private static final String DEFAULT_HEADING = "Multiple Failures";
38 | private static final String HEADING = "Custom Heading";
39 |
40 | @Test
41 | public void mfeWithNoFailuresWithNullHeading() {
42 | assertExceptionWithNoFailures(null, DEFAULT_HEADING);
43 | }
44 |
45 | @Test
46 | public void mfeWithNoFailuresWithEmptyHeading() {
47 | assertExceptionWithNoFailures(" ", DEFAULT_HEADING);
48 | }
49 |
50 | @Test
51 | public void mfeWithNoFailuresWithCustomHeading() {
52 | assertExceptionWithNoFailures(HEADING, HEADING);
53 | }
54 |
55 | @Test
56 | public void mfeWithSingleFailureWithNullHeading() {
57 | assertExceptionWithSingleFailure(null, DEFAULT_HEADING);
58 | }
59 |
60 | @Test
61 | public void mfeWithSingleFailureWithEmptyHeading() {
62 | assertExceptionWithSingleFailure(" ", DEFAULT_HEADING);
63 | }
64 |
65 | @Test
66 | public void mfeWithSingleFailureWithCustomHeading() {
67 | assertExceptionWithSingleFailure(HEADING, HEADING);
68 | }
69 |
70 | @Test
71 | public void mfeWithFailuresWithNullHeading() {
72 | assertExceptionWithFailures(null, DEFAULT_HEADING);
73 | }
74 |
75 | @Test
76 | public void mfeWithFailuresWithEmptyHeading() {
77 | assertExceptionWithFailures(" ", DEFAULT_HEADING);
78 | }
79 |
80 | @Test
81 | public void mfeWithFailuresWithCustomHeading() {
82 | assertExceptionWithFailures(HEADING, HEADING);
83 | }
84 |
85 | @Test
86 | public void mfeWithNullMessageFailures() throws Exception {
87 | List In addition to a message and a cause, this class stores the expected
24 | * and actual values of an assertion using the {@link ValueWrapper} type.
25 | *
26 | * @author Sam Brannen
27 | * @author Marc Philipp
28 | * @since 1.0
29 | */
30 | public class AssertionFailedError extends AssertionError {
31 |
32 | private static final long serialVersionUID = 1L;
33 |
34 | private static final Throwable NO_CAUSE = new RuntimeException("no cause indicator") {
35 | @Override
36 | public Throwable fillInStackTrace() {
37 | // Avoid the overhead of filling in the stack trace for this
38 | return this;
39 | }
40 | };
41 |
42 | private final ValueWrapper expected;
43 | private final ValueWrapper actual;
44 |
45 | /**
46 | * Constructs an {@code AssertionFailedError} with an empty message, no
47 | * cause, and no expected/actual values.
48 | */
49 | public AssertionFailedError() {
50 | this(null);
51 | }
52 |
53 | /**
54 | * Constructs an {@code AssertionFailedError} with a message, no cause,
55 | * and no expected/actual values.
56 | *
57 | * @param message the detail message; {@code null} or blank will be
58 | * converted to the empty {@code String}
59 | */
60 | public AssertionFailedError(String message) {
61 | this(message, NO_CAUSE);
62 | }
63 |
64 | /**
65 | * Constructs an {@code AssertionFailedError} with a message and
66 | * expected/actual values but without a cause.
67 | *
68 | * Actual and expected values may be {@link FileInfo} instances.
69 | *
70 | * @param message the detail message; {@code null} or blank will be
71 | * converted to the empty {@code String}
72 | * @param expected the expected value; may be {@code null}
73 | * @param actual the actual value; may be {@code null}
74 | */
75 | public AssertionFailedError(String message, Object expected, Object actual) {
76 | this(message, expected, actual, NO_CAUSE);
77 | }
78 |
79 | /**
80 | * Constructs an {@code AssertionFailedError} with a message and a cause
81 | * but without expected/actual values.
82 | *
83 | * @param message the detail message; {@code null} or blank will be
84 | * converted to the empty {@code String}
85 | * @param cause the cause of the failure
86 | */
87 | public AssertionFailedError(String message, Throwable cause) {
88 | this(message, null, null, cause);
89 | }
90 |
91 | /**
92 | * Constructs an {@code AssertionFailedError} with a message,
93 | * expected/actual values, and a cause.
94 | *
95 | * @param message the detail message; {@code null} or blank will be
96 | * converted to the empty {@code String}
97 | * @param expected the expected value; may be {@code null}
98 | * @param actual the actual value; may be {@code null}
99 | * @param cause the cause of the failure
100 | */
101 | public AssertionFailedError(String message, Object expected, Object actual, Throwable cause) {
102 | this(message, ValueWrapper.create(expected), ValueWrapper.create(actual), cause);
103 | }
104 |
105 | private AssertionFailedError(String message, ValueWrapper expected, ValueWrapper actual, Throwable cause) {
106 | super((message == null || message.trim().length() == 0) ? "" : message);
107 | this.expected = expected;
108 | this.actual = actual;
109 | if (cause != NO_CAUSE) {
110 | initCause(cause);
111 | }
112 | }
113 |
114 | /**
115 | * Returns {@code true} if an expected value was supplied via an
116 | * appropriate constructor.
117 | *
118 | * @see #getExpected()
119 | */
120 | public boolean isExpectedDefined() {
121 | return this.expected != null;
122 | }
123 |
124 | /**
125 | * Returns {@code true} if an actual value was supplied via an
126 | * appropriate constructor.
127 | *
128 | * @see #getActual()
129 | */
130 | public boolean isActualDefined() {
131 | return this.actual != null;
132 | }
133 |
134 | /**
135 | * Returns the wrapped expected value if it is defined; otherwise {@code null}.
136 | *
137 | * @see #isExpectedDefined()
138 | */
139 | public ValueWrapper getExpected() {
140 | return this.expected;
141 | }
142 |
143 | /**
144 | * Returns the wrapped actual value if it is defined; otherwise {@code null}.
145 | *
146 | * @see #isActualDefined()
147 | */
148 | public ValueWrapper getActual() {
149 | return this.actual;
150 | }
151 |
152 | /**
153 | * Returns a short description of this assertion error using the same format
154 | * as {@link Throwable#toString()}.
155 | *
156 | * Since the constructors of this class convert supplied {@code null} or
157 | * blank messages to the empty {@code String}, this method only includes
158 | * non-empty messages in its return value.
159 | *
160 | * @return a string representation of this {@code AssertionFailedError}
161 | * @since 1.1.1
162 | */
163 | @Override
164 | public String toString() {
165 | String className = getClass().getName();
166 | String message = getLocalizedMessage();
167 | return ("".equals(message) ? className : (className + ": " + message));
168 | }
169 |
170 | }
171 |
--------------------------------------------------------------------------------
/src/main/java/org/opentest4j/ValueWrapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2025 the original author or authors.
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 org.opentest4j;
18 |
19 | import java.io.Serializable;
20 |
21 | /**
22 | * Serializable representation of a value that was used in an assertion.
23 | *
24 | * This class only stores the value if it implements {@link Serializable}.
25 | * In any case, it stores its {@linkplain #getType() runtime type}, {@linkplain
26 | * #getIdentityHashCode() identity hash code}, and {@linkplain
27 | * #getStringRepresentation() string representation} determined via {@link
28 | * String#valueOf(Object)}. If the invocation of {@code String.valueOf(Object)}
29 | * throws an {@link Exception}, the string representation will take the form of
30 | * {@code " The {@link #toString()} method returns the string representation of the
34 | * value along with its type and identity hash code.
35 | *
36 | * @author Marc Philipp
37 | * @author Sam Brannen
38 | * @since 1.0
39 | * @see System#identityHashCode
40 | */
41 | public final class ValueWrapper implements Serializable {
42 |
43 | private static final long serialVersionUID = 1L;
44 |
45 | private static final ValueWrapper nullValueWrapper = new ValueWrapper(null);
46 |
47 | /**
48 | * Factory for creating a new {@code ValueWrapper} for the supplied {@code value}.
49 | *
50 | * If the supplied {@code value} is {@code null}, this method will return a
51 | * cached {@code ValueWrapper} suitable for all {@code null} values.
52 | * If the supplied {@code value} is already an instance of {@link ValueWrapper},
53 | * it will be returned as is.
54 | *
55 | * @param value the value to wrap; may be {@code null}
56 | * @return a wrapper for the supplied value; never {@code null}
57 | */
58 | public static ValueWrapper create(Object value) {
59 | if (value instanceof ValueWrapper)
60 | return (ValueWrapper) value;
61 | return (value == null) ? nullValueWrapper : new ValueWrapper(value);
62 | }
63 |
64 | /**
65 | * Factory for creating a new {@code ValueWrapper} for the supplied {@code value}
66 | * using the supplied custom {@code stringRepresentation}.
67 | *
68 | * You should use this method when you don't want to rely on the result of the
69 | * value's {@link Object#toString() toString()} method.
70 | *
71 | * If the supplied {@code value} is {@code null}, this method will return a
72 | * cached {@code ValueWrapper} suitable for all {@code null} values.
73 | * If the supplied {@code value} is already an instance of {@link ValueWrapper},
74 | * it will be returned as is if the {@code stringRepresentation} match, otherwise
75 | * the original value will be unwrapped and a new {@code ValueWrapper} with the
76 | * new {@code stringRepresentation} will be created.
77 | *
78 | * @param value the value to wrap; may be {@code null}
79 | * @param stringRepresentation a custom rendering of the value; will fallback to
80 | * the default behavior if {@code null}
81 | * @return a wrapper for the supplied value; never {@code null}
82 | * @since 1.2
83 | */
84 | public static ValueWrapper create(Object value, String stringRepresentation) {
85 | if (value instanceof ValueWrapper) {
86 | ValueWrapper wrapper = (ValueWrapper) value;
87 | return wrapper.stringRepresentation.equals(stringRepresentation) ? wrapper
88 | : create(wrapper.value, stringRepresentation);
89 | }
90 | return (value == null ? nullValueWrapper : new ValueWrapper(value, stringRepresentation));
91 | }
92 |
93 | private final Serializable value;
94 | private final Class> type;
95 | private final String stringRepresentation;
96 | private final int identityHashCode;
97 | private final transient Object ephemeralValue;
98 |
99 | /**
100 | * Reads and stores the supplied value's runtime type, string representation, and
101 | * identity hash code.
102 | */
103 | private ValueWrapper(Object value, String stringRepresentation) {
104 | this.value = value instanceof Serializable ? (Serializable) value : null;
105 | this.type = value != null ? value.getClass() : null;
106 | this.stringRepresentation = stringRepresentation == null ? safeValueToString(value) : stringRepresentation;
107 | this.identityHashCode = System.identityHashCode(value);
108 | this.ephemeralValue = value;
109 | }
110 |
111 | private ValueWrapper(Object value) {
112 | this(value, safeValueToString(value));
113 | }
114 |
115 | private static String safeValueToString(Object value) {
116 | try {
117 | return String.valueOf(value);
118 | }
119 | catch (Exception e) {
120 | return " The string representation is generated by invoking
146 | * {@link String#valueOf(Object) String.valueOf(value)} for the value
147 | * supplied to {@link #create(Object)}.
148 | *
149 | * @see #getValue()
150 | */
151 | public String getStringRepresentation() {
152 | return this.stringRepresentation;
153 | }
154 |
155 | /**
156 | * Returns the value's identity hash code.
157 | *
158 | * The identity hash code is generated by invoking
159 | * {@link System#identityHashCode(Object) System.identityHashCode(value)}
160 | * for the value supplied to {@link #create(Object)}.
161 | *
162 | * @see #getValue()
163 | */
164 | public int getIdentityHashCode() {
165 | return this.identityHashCode;
166 | }
167 |
168 | /**
169 | * Returns the original value supplied to {@link #create(Object) create()}.
170 | *
171 | * If this {@code ValueWrapper} was created by deserialization this method
172 | * returns {@code null}.
173 | *
174 | * @see #getValue()
175 | * @since 1.2
176 | */
177 | public Object getEphemeralValue() {
178 | return this.ephemeralValue;
179 | }
180 |
181 | /**
182 | * Returns the value's string representation along with its type and
183 | * identity hash code.
184 | */
185 | @Override
186 | public String toString() {
187 | if (this.type == null) {
188 | return "null";
189 | }
190 | return this.stringRepresentation + //
191 | " (" + this.type.getName() + "@" + Integer.toHexString(this.identityHashCode) + ")";
192 | }
193 |
194 | }
195 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015 the original 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 | # https://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 | # SPDX-License-Identifier: Apache-2.0
19 | #
20 |
21 | ##############################################################################
22 | #
23 | # Gradle start up script for POSIX generated by Gradle.
24 | #
25 | # Important for running:
26 | #
27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28 | # noncompliant, but you have some other compliant shell such as ksh or
29 | # bash, then to run this script, type that shell name before the whole
30 | # command line, like:
31 | #
32 | # ksh Gradle
33 | #
34 | # Busybox and similar reduced shells will NOT work, because this script
35 | # requires all of these POSIX shell features:
36 | # * functions;
37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39 | # * compound commands having a testable exit status, especially «case»;
40 | # * various built-in commands including «command», «set», and «ulimit».
41 | #
42 | # Important for patching:
43 | #
44 | # (2) This script targets any POSIX shell, so it avoids extensions provided
45 | # by Bash, Ksh, etc; in particular arrays are avoided.
46 | #
47 | # The "traditional" practice of packing multiple parameters into a
48 | # space-separated string is a well documented source of bugs and security
49 | # problems, so this is (mostly) avoided, by progressively accumulating
50 | # options in "$@", and eventually passing that to Java.
51 | #
52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54 | # see the in-line comments for details.
55 | #
56 | # There are tweaks for specific operating systems such as AIX, CygWin,
57 | # Darwin, MinGW, and NonStop.
58 | #
59 | # (3) This script is generated from the Groovy template
60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61 | # within the Gradle project.
62 | #
63 | # You can find Gradle at https://github.com/gradle/gradle/.
64 | #
65 | ##############################################################################
66 |
67 | # Attempt to set APP_HOME
68 |
69 | # Resolve links: $0 may be a link
70 | app_path=$0
71 |
72 | # Need this for daisy-chained symlinks.
73 | while
74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75 | [ -h "$app_path" ]
76 | do
77 | ls=$( ls -ld "$app_path" )
78 | link=${ls#*' -> '}
79 | case $link in #(
80 | /*) app_path=$link ;; #(
81 | *) app_path=$APP_HOME$link ;;
82 | esac
83 | done
84 |
85 | # This is normally unused
86 | # shellcheck disable=SC2034
87 | APP_BASE_NAME=${0##*/}
88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 |
118 |
119 | # Determine the Java command to use to start the JVM.
120 | if [ -n "$JAVA_HOME" ] ; then
121 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
122 | # IBM's JDK on AIX uses strange locations for the executables
123 | JAVACMD=$JAVA_HOME/jre/sh/java
124 | else
125 | JAVACMD=$JAVA_HOME/bin/java
126 | fi
127 | if [ ! -x "$JAVACMD" ] ; then
128 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
129 |
130 | Please set the JAVA_HOME variable in your environment to match the
131 | location of your Java installation."
132 | fi
133 | else
134 | JAVACMD=java
135 | if ! command -v java >/dev/null 2>&1
136 | then
137 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
138 |
139 | Please set the JAVA_HOME variable in your environment to match the
140 | location of your Java installation."
141 | fi
142 | fi
143 |
144 | # Increase the maximum file descriptors if we can.
145 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
146 | case $MAX_FD in #(
147 | max*)
148 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
149 | # shellcheck disable=SC2039,SC3045
150 | MAX_FD=$( ulimit -H -n ) ||
151 | warn "Could not query maximum file descriptor limit"
152 | esac
153 | case $MAX_FD in #(
154 | '' | soft) :;; #(
155 | *)
156 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
157 | # shellcheck disable=SC2039,SC3045
158 | ulimit -n "$MAX_FD" ||
159 | warn "Could not set maximum file descriptor limit to $MAX_FD"
160 | esac
161 | fi
162 |
163 | # Collect all arguments for the java command, stacking in reverse order:
164 | # * args from the command line
165 | # * the main class name
166 | # * -classpath
167 | # * -D...appname settings
168 | # * --module-path (only if needed)
169 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
170 |
171 | # For Cygwin or MSYS, switch paths to Windows format before running java
172 | if "$cygwin" || "$msys" ; then
173 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
174 |
175 | JAVACMD=$( cygpath --unix "$JAVACMD" )
176 |
177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
178 | for arg do
179 | if
180 | case $arg in #(
181 | -*) false ;; # don't mess with options #(
182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
183 | [ -e "$t" ] ;; #(
184 | *) false ;;
185 | esac
186 | then
187 | arg=$( cygpath --path --ignore --mixed "$arg" )
188 | fi
189 | # Roll the args list around exactly as many times as the number of
190 | # args, so each arg winds up back in the position where it started, but
191 | # possibly modified.
192 | #
193 | # NB: a `for` loop captures its iteration list before it begins, so
194 | # changing the positional parameters here affects neither the number of
195 | # iterations, nor the values presented in `arg`.
196 | shift # remove old arg
197 | set -- "$@" "$arg" # push replacement arg
198 | done
199 | fi
200 |
201 |
202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204 |
205 | # Collect all arguments for the java command:
206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207 | # and any embedded shellness will be escaped.
208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209 | # treated as '${Hostname}' itself on the command line.
210 |
211 | set -- \
212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
213 | -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
214 | "$@"
215 |
216 | # Stop when "xargs" is not available.
217 | if ! command -v xargs >/dev/null 2>&1
218 | then
219 | die "xargs is not available"
220 | fi
221 |
222 | # Use "xargs" to parse quoted args.
223 | #
224 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
225 | #
226 | # In Bash we could simply go:
227 | #
228 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
229 | # set -- "${ARGS[@]}" "$@"
230 | #
231 | # but POSIX shell has neither arrays nor command substitution, so instead we
232 | # post-process each arg (as a line of input to sed) to backslash-escape any
233 | # character that might be a shell metacharacter, then use eval to reverse
234 | # that process (while maintaining the separation between arguments), and wrap
235 | # the whole thing up as a single "set" statement.
236 | #
237 | # This will of course break if any of these variables contains a newline or
238 | # an unmatched quote.
239 | #
240 |
241 | eval "set -- $(
242 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
243 | xargs -n1 |
244 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
245 | tr '\n' ' '
246 | )" '"$@"'
247 |
248 | exec "$JAVACMD" "$@"
249 |
--------------------------------------------------------------------------------
/src/test/java/org/opentest4j/AssertionFailedErrorTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2025 the original author or authors.
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 org.opentest4j;
18 |
19 | import static org.junit.Assert.assertEquals;
20 | import static org.junit.Assert.assertFalse;
21 | import static org.junit.Assert.assertNull;
22 | import static org.junit.Assert.assertTrue;
23 |
24 | import java.io.ByteArrayInputStream;
25 | import java.io.ByteArrayOutputStream;
26 | import java.io.InputStream;
27 | import java.io.ObjectInputStream;
28 | import java.io.ObjectOutputStream;
29 | import java.io.OutputStream;
30 |
31 | import org.junit.Rule;
32 | import org.junit.Test;
33 | import org.junit.rules.ExpectedException;
34 |
35 | /**
36 | * Unit tests for {@link AssertionFailedError}.
37 | *
38 | * @author Marc Philipp
39 | * @author Sam Brannen
40 | * @since 1.0
41 | */
42 | public class AssertionFailedErrorTests {
43 |
44 | private static final String EMPTY = "";
45 | private static final String BLANK = " ";
46 |
47 | @Rule
48 | public ExpectedException expectedException = ExpectedException.none();
49 |
50 | @Test
51 | public void undefinedCauseDoesNotInitializeCause() {
52 | RuntimeException lateCause = new RuntimeException("lateCause");
53 | new AssertionFailedError().initCause(lateCause);
54 | new AssertionFailedError("my message").initCause(lateCause);
55 | new AssertionFailedError(null, "foo", "bar").initCause(lateCause);
56 | }
57 |
58 | @Test
59 | public void cannotReinitializeNullCauseForMessageCauseArgs() {
60 | RuntimeException lazyCause = new RuntimeException("cause");
61 |
62 | expectedException.expect(IllegalStateException.class);
63 | new AssertionFailedError(null, null).initCause(lazyCause);
64 | }
65 |
66 | @Test
67 | public void cannotReinitializeNullCauseForExpectedActualCauseArgs() {
68 | RuntimeException lazyCause = new RuntimeException("cause");
69 |
70 | expectedException.expect(IllegalStateException.class);
71 | new AssertionFailedError(null, "foo", "bar", null).initCause(lazyCause);
72 | }
73 |
74 | @Test
75 | public void defaultConstructorUsesEmptyMessage() {
76 | assertEquals(EMPTY, new AssertionFailedError().getMessage());
77 | }
78 |
79 | @Test
80 | public void nullMessageIsConvertedToEmptyMessage() {
81 | assertEquals(EMPTY, new AssertionFailedError(null).getMessage());
82 | assertEquals(EMPTY, new AssertionFailedError(null, null).getMessage());
83 | assertEquals(EMPTY, new AssertionFailedError(null, "foo", "bar").getMessage());
84 | assertEquals(EMPTY, new AssertionFailedError(null, "foo", "bar", null).getMessage());
85 | }
86 |
87 | @Test
88 | public void blankMessageIsConvertedToEmptyMessage() {
89 | assertEquals(EMPTY, new AssertionFailedError(BLANK).getMessage());
90 | assertEquals(EMPTY, new AssertionFailedError(BLANK, null).getMessage());
91 | assertEquals(EMPTY, new AssertionFailedError(BLANK, "foo", "bar").getMessage());
92 | assertEquals(EMPTY, new AssertionFailedError(BLANK, "foo", "bar", null).getMessage());
93 | }
94 |
95 | @Test
96 | public void toStringChecks() {
97 | String className = AssertionFailedError.class.getName();
98 | assertEquals(className, new AssertionFailedError().toString());
99 | assertEquals(className, new AssertionFailedError(null).toString());
100 | assertEquals(className, new AssertionFailedError(null, "foo", "bar").toString());
101 | assertEquals(className, new AssertionFailedError(null, new RuntimeException()).toString());
102 | assertEquals(className, new AssertionFailedError(null, "foo", "bar", new RuntimeException()).toString());
103 |
104 | assertEquals(className, new AssertionFailedError(EMPTY).toString());
105 | assertEquals(className, new AssertionFailedError(EMPTY, "foo", "bar").toString());
106 | assertEquals(className, new AssertionFailedError(EMPTY, new RuntimeException()).toString());
107 | assertEquals(className, new AssertionFailedError(EMPTY, "foo", "bar", new RuntimeException()).toString());
108 |
109 | assertEquals(className, new AssertionFailedError(BLANK).toString());
110 | assertEquals(className, new AssertionFailedError(BLANK, "foo", "bar").toString());
111 | assertEquals(className, new AssertionFailedError(BLANK, new RuntimeException()).toString());
112 | assertEquals(className, new AssertionFailedError(BLANK, "foo", "bar", new RuntimeException()).toString());
113 |
114 | assertEquals(className + ": message", new AssertionFailedError("message").toString());
115 | assertEquals(className + ": message", new AssertionFailedError("message", "foo", "bar").toString());
116 | assertEquals(className + ": message", new AssertionFailedError("message", new RuntimeException()).toString());
117 | assertEquals(className + ": message",
118 | new AssertionFailedError("message", "foo", "bar", new RuntimeException()).toString());
119 | }
120 |
121 | @Test
122 | public void messageAndCauseAreStored() {
123 | RuntimeException cause = new RuntimeException("cause");
124 |
125 | AssertionFailedError error = new AssertionFailedError("my message", cause);
126 |
127 | assertEquals("my message", error.getMessage());
128 | assertEquals(cause, error.getCause());
129 | assertFalse(error.isExpectedDefined());
130 | assertFalse(error.isActualDefined());
131 | }
132 |
133 | @Test
134 | public void expectedAndActualValuesAreStored() {
135 | AssertionFailedError errorWithExpectedAndActual = new AssertionFailedError(null, "foo", "bar");
136 | assertTrue(errorWithExpectedAndActual.isExpectedDefined());
137 | assertEquals("foo", errorWithExpectedAndActual.getExpected().getValue());
138 | assertTrue(errorWithExpectedAndActual.isActualDefined());
139 | assertEquals("bar", errorWithExpectedAndActual.getActual().getValue());
140 | }
141 |
142 | @Test
143 | public void returnsNullForExpectedAndActualWhenNotPassedToConstructor() {
144 | AssertionFailedError errorWithoutExpectedAndActual = new AssertionFailedError();
145 | assertFalse(errorWithoutExpectedAndActual.isExpectedDefined());
146 | assertNull(errorWithoutExpectedAndActual.getExpected());
147 | assertFalse(errorWithoutExpectedAndActual.isActualDefined());
148 | assertNull(errorWithoutExpectedAndActual.getActual());
149 | }
150 |
151 | @Test
152 | public void serializationWorksForAssertionFailedErrorWithMessageAndExpectedAndActualValues() throws Exception {
153 | AssertionFailedError error = serializeAndDeserialize(new AssertionFailedError("a message", "foo", "bar"));
154 |
155 | assertEquals("a message", error.getMessage());
156 | assertTrue(error.isExpectedDefined());
157 | assertEquals("foo", error.getExpected().getValue());
158 | assertTrue(error.isActualDefined());
159 | assertEquals("bar", error.getActual().getValue());
160 | }
161 |
162 | @Test
163 | public void serializationWorksForAssertionFailedErrorWithoutAnyValues() throws Exception {
164 | AssertionFailedError error = serializeAndDeserialize(new AssertionFailedError());
165 |
166 | assertEquals(EMPTY, error.getMessage());
167 | assertFalse(error.isExpectedDefined());
168 | assertNull(error.getExpected());
169 | assertFalse(error.isActualDefined());
170 | assertNull(error.getActual());
171 | }
172 |
173 | @Test
174 | public void deserializationOfAssertionFailedErrorWorksForVersion_1_0_0() throws Exception {
175 | // Generated using:
176 | // FileOutputStream outputStream = new FileOutputStream("src/test/resources/AssertionFailedError_serializedVersion_1_0_0.out");
177 | // serialize(new AssertionFailedError("message", "foo", "bar"), outputStream);
178 | // outputStream.close();
179 |
180 | AssertionFailedError error = (AssertionFailedError) deserializeClasspathResource(
181 | "/AssertionFailedError_serializedVersion_1_0_0.out");
182 |
183 | assertEquals("message", error.getMessage());
184 | assertTrue(error.isExpectedDefined());
185 | assertEquals("foo", error.getExpected().getValue());
186 | assertTrue(error.isActualDefined());
187 | assertEquals("bar", error.getActual().getValue());
188 | }
189 |
190 | @Test
191 | public void ephemeralValueIsOmittedFromSerialization() throws Exception {
192 | class NonSerializable {
193 | public final String guid = "8675309";
194 | }
195 |
196 | AssertionFailedError error = serializeAndDeserialize(
197 | new AssertionFailedError("a message", new NonSerializable(), new NonSerializable()));
198 | assertEquals("a message", error.getMessage());
199 | assertTrue(error.isExpectedDefined());
200 | assertNull(error.getExpected().getValue());
201 | assertNull(error.getExpected().getEphemeralValue());
202 | assertTrue(error.isActualDefined());
203 | assertNull(error.getActual().getValue());
204 | assertNull(error.getActual().getEphemeralValue());
205 | }
206 |
207 | private Object deserializeClasspathResource(String name) throws Exception {
208 | InputStream inputStream = getClass().getResourceAsStream(name);
209 | try {
210 | return deserialize(inputStream);
211 | }
212 | finally {
213 | inputStream.close();
214 | }
215 | }
216 |
217 | private AssertionFailedError serializeAndDeserialize(AssertionFailedError originalError) throws Exception {
218 | byte[] bytes = serialize(originalError);
219 | Object deserializedObject = deserialize(new ByteArrayInputStream(bytes));
220 | assertEquals(AssertionFailedError.class, deserializedObject.getClass());
221 | return (AssertionFailedError) deserializedObject;
222 | }
223 |
224 | private Object deserialize(InputStream inputStream) throws Exception {
225 | ObjectInputStream in = new ObjectInputStream(inputStream);
226 | return in.readObject();
227 | }
228 |
229 | private byte[] serialize(Object object) throws Exception {
230 | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
231 | serialize(object, byteArrayOutputStream);
232 | return byteArrayOutputStream.toByteArray();
233 | }
234 |
235 | private void serialize(Object object, OutputStream outputStream) throws Exception {
236 | ObjectOutputStream out = new ObjectOutputStream(outputStream);
237 | out.writeObject(object);
238 | out.flush();
239 | }
240 |
241 | }
242 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/etc/eclipse/eclipse-formatter-settings.xml:
--------------------------------------------------------------------------------
1 |
2 | foo`.
38 | - Favor literals (e.g., `{@literal @}`) over HTML entities.
39 | - Use `@since 1.0` instead of `@since 1.0.0`.
40 | - 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.
41 |
42 | ### Tests
43 |
44 | #### Naming
45 |
46 | - Tests are written using JUnit 4.
47 | - All test classes must end with a `Tests` suffix.
48 | - Example test classes that should not be picked up by the build must end with a `TestCase` suffix.
49 |
50 | #### Assertions
51 |
52 | - Use `org.junit.Assert` wherever possible.
53 | - Do not use `junit.framework.Assert`.
54 | - Use AssertJ when richer assertions are needed.
55 |
56 | #### Mocking
57 |
58 | - Use either Mockito or hand-written test doubles.
59 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | - 'releases/*'
8 | pull_request:
9 | branches:
10 | - '*'
11 |
12 | permissions: {}
13 |
14 | env:
15 | DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
16 |
17 | jobs:
18 | Linux:
19 | runs-on: ubuntu-latest
20 | steps:
21 | - name: Check out repository
22 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
23 | with:
24 | fetch-depth: 1
25 | - name: Build
26 | uses: ./.github/actions/run-gradle
27 |
28 | Windows:
29 | runs-on: windows-latest
30 | steps:
31 | - name: Check out repository
32 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
33 | with:
34 | fetch-depth: 1
35 | - name: Build
36 | uses: ./.github/actions/run-gradle
37 |
38 | macOS:
39 | runs-on: macos-latest
40 | steps:
41 | - name: Check out repository
42 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
43 | with:
44 | fetch-depth: 1
45 | - name: Build
46 | uses: ./.github/actions/run-gradle
47 |
48 | publish_artifacts:
49 | name: Publish Snapshot Artifacts
50 | needs: Linux
51 | runs-on: ubuntu-latest
52 | if: github.event_name == 'push' && github.repository == 'ota4j-team/opentest4j' && (startsWith(github.ref, 'refs/heads/releases/') || github.ref == 'refs/heads/main')
53 | steps:
54 | - name: Check out repository
55 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
56 | with:
57 | fetch-depth: 1
58 | - name: Publish
59 | uses: ./.github/actions/run-gradle
60 | env:
61 | ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
62 | ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
63 | with:
64 | arguments: publishAllPublicationsToMavenCentralSnapshotsRepository -x check
65 |
66 | update_documentation:
67 | name: Update documentation
68 | needs: Linux
69 | runs-on: ubuntu-latest
70 | if: github.event_name == 'push' && github.repository == 'ota4j-team/opentest4j' && github.ref == 'refs/heads/main'
71 | permissions:
72 | contents: write
73 | steps:
74 | - name: Check out repository
75 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
76 | with:
77 | fetch-depth: 1
78 | - name: Configure Git
79 | shell: bash
80 | run: |
81 | git config --global user.name "JUnit Team"
82 | git config --global user.email "team@junit.org"
83 | - name: Publish
84 | uses: ./.github/actions/run-gradle
85 | env:
86 | GIT_USERNAME: git
87 | GIT_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
88 | with:
89 | arguments: gitPublishPush
90 |
--------------------------------------------------------------------------------
/src/test/java/org/opentest4j/FileInfoTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2025 the original author or authors.
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 org.opentest4j;
18 |
19 | import static java.nio.charset.Charset.defaultCharset;
20 | import static java.nio.charset.StandardCharsets.UTF_8;
21 | import static org.junit.Assert.assertEquals;
22 | import static org.junit.Assert.assertSame;
23 |
24 | import java.io.ByteArrayInputStream;
25 | import java.io.ByteArrayOutputStream;
26 | import java.io.ObjectInputStream;
27 | import java.io.ObjectOutputStream;
28 |
29 | import org.junit.Test;
30 |
31 | /**
32 | * Unit tests for {@link FileInfo}.
33 | *
34 | * @author Marc Philipp
35 | * @author Reinhold Degenfellner
36 | * @since 1.3
37 | */
38 | public class FileInfoTests {
39 |
40 | FileInfo actual = new FileInfo("actual path", "actual contents".getBytes(UTF_8));
41 | FileInfo expected = new FileInfo("expected path", "expected contents".getBytes(UTF_8));
42 | AssertionFailedError assertionFailedError = new AssertionFailedError("message", expected, actual);
43 |
44 | @Test
45 | public void actualAndExpectedFileInfoAreAccessible() {
46 | assertSame(actual, assertionFailedError.getActual().getValue());
47 | assertSame(expected, assertionFailedError.getExpected().getValue());
48 | }
49 |
50 | @Test
51 | public void isSerializable() throws Exception {
52 | var out = new ByteArrayOutputStream();
53 |
54 | new ObjectOutputStream(out).writeObject(assertionFailedError);
55 | var deserialized = (AssertionFailedError) new ObjectInputStream(
56 | new ByteArrayInputStream(out.toByteArray())).readObject();
57 |
58 | assertEquals(actual, deserialized.getActual().getValue());
59 | assertEquals(expected, deserialized.getExpected().getValue());
60 | }
61 |
62 | @Test
63 | public void constructors() {
64 | var contents = "contents".getBytes(UTF_8);
65 | var fileInfo = new FileInfo("path", contents);
66 |
67 | assertSame(fileInfo.getContents(), contents);
68 | assertEquals(fileInfo.getContentsAsString(defaultCharset()), "contents");
69 | assertEquals(fileInfo.getPath(), "path");
70 |
71 | contents = "contents".getBytes();
72 | fileInfo = new FileInfo("path", contents);
73 |
74 | assertSame(fileInfo.getContents(), contents);
75 | assertEquals(fileInfo.getContentsAsString(defaultCharset()), "contents");
76 | assertEquals(fileInfo.getPath(), "path");
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 |
3 | # Specify which branches/tags that we do not want to be built: r5.0.0-M5
4 | branches:
5 | except:
6 | - /^r\d.*$/
7 |
8 | before_install:
9 | - unset _JAVA_OPTIONS # https://github.com/travis-ci/travis-ci/issues/8408
10 |
11 | install:
12 | - ./gradlew --version # Display Gradle, Groovy, JVM and other versions
13 |
14 | jdk:
15 | - openjdk11
16 |
17 | stages:
18 | - test
19 | - name: deploy
20 | if: (branch = master) AND (NOT type IN (pull_request))
21 |
22 | jobs:
23 | include:
24 | - script: ./gradlew --stacktrace build
25 | - stage: deploy
26 | name: "Publish snapshot artifacts"
27 | env:
28 | # ORG_GRADLE_PROJECT_ossrhUsername
29 | - secure: K3oEnLQ2ai8lmTHrfQsktkb8vc/W5ghP6NurUmb4E+SHWw/zqv2naxupbpVZqovhhTqYm1/I0rqHKrGrBIUDSFMhyTKYmqw4+Nck3BAnjXovotGuKyMrg6yqoBjaWhT8rJe/fR2hZgUi96vSjEKC/UDSGRRHhoEyX73qAwbA7CGJ3SMVRZpkBvs2GUubKZgXuJCpGSk2FWOtJpWK4sC87/yV8Arg1DgrCHUm7uc1we+CedjierPxfo6QX9Laohyn60D3BtojYw1xxsiX9Rv0KCxCqmZn5Qd6PLV4+0PzFXjO0xvrHecQ+NhyWfmMkfV5dO/zaF0OoxrHj/cFmvoGSHN4r1SIV2TwbtIuUCxypWqUTVrfejQyJ2Dhk2GbOa941EtXXX8i2zEDTBq56Tby4d44QvhK1v8QNmmev/o6j1YCBMKN+X59bSqUHF4PX8ap9m2iWYNCbvwET5YJAKnWLEj2QGBXn34GWZksyU/Fe+mvVJ0eRwZjUWKfOcS5xzrvRrNayyMIzUSUGKuTDeS+KR9eF7215hBDu6t8z+s+jSyoLD8+tttnHrgBkkUvwzctT8MeQP0JdpYhYyITuWYJ1OB9w2GKHE5ch9JYYOKUliJga42P6Hbx4NwTeCSNJ96mzQAKcDwwJZujzN2PDSr86uBlHwLdn+9cy0vndYUSYtY=
30 | # ORG_GRADLE_PROJECT_ossrhPassword
31 | - secure: NewZka3bmiDgrSP8+yfPQNf85K/sT4CQiIbrf9SWOTgI7Z6kq6kKXU94cEQue6Ugli0USreMZYhl5b6XvcCUzRF9kOh/mRk9VIaOOaOIloatmaF581mGiYNBn8AoBoQ/JURQ59dBxHxyyf4Wm5o63FW0RdZoBOb8FA+esLGdY8ZlpsSc3WdYmguJf6Ga2auT1FIGujDLjBYCaPBqx1xM8JckFWBU0QHhDGFo6CjGUUd62KTf72RVtsLmcMnEvoJ18s7txmWYY4H/BwONekTnmXw80+y6EVXP3K7kkD/9KL9xq/fDibcmP9UfbpCnEysu7hygMhPfMPB3KmPhFSP7GGlEZsLeGNhLBLXidpJmyNvcSHOdS+vaF8xbW/+DBJ3stNntS1TaPGPcIjAyKN67q4yayZBdJKzkIWzVkJy3akRwO7D0Lj1irs7mcLL0DSkP3YrgShIhcq34D+Iknblz4AykG1/ehv4eAipljrh66SGB41QlN6U0AZVpqi869sPfu55q8Piucnrps+3jo26q25mtPpurEIIQIX6SCwUyK4A+4Jvk4r8KUykkBS7HildiflKGwiLTRHgskGkAslm0ARZo4B50FQgqcJbytkSqe76y4WeVLZ648zNNTlX7oysKeizGjj6CxnXN3KLKmmXqKaht5UX6gCSbw2+O9/OlAgw=
32 | script: ./gradlew --stacktrace uploadArchives -x check
33 | - name: "Update snapshot documentation"
34 | env:
35 | # ORG_GRADLE_PROJECT_githubToken
36 | - secure: AW4jpuuv5MTIxUw1dlfIKyRgp5G9aj9/wsJx+XBVdZ6/+0Tj8BzBldUe9b4JeNEnDGIRIL83lPHMR0a/DbfF5Cg0Cpi0oLQE+JkKh/ucRZucrXXMjIg+3IEtpdUG/I4vqjwd1xUAYZ/URPP75NVr7b3RVY9+MTaSaZ2b+VtG/aMNJ5kih4PHfJ2wR0OobHrTSxOkyGwZTdG6ZvFplHcPtuZ/v6KJGaUrCFYRnXOZIE73dPDQjxqy90FQrNlscvkZ3cerqVeeQ1nK7eU60neNBrSP9PJsN6zqSyPfMfyfzGBiS7v2dlVktSjeOmdEn+NCSmR59a0wbVObhzisOgODqBMk3KLWOWwWHfA2M5URuQaNr/AsKQTr2FlVkwY/cHO52q58tKNE1m/3nPs5ZMEhlh6jtbBafUe8NA9JQ0LKppA/kMqd1vT97hCeMGR0B5rTZEYXK9pCKWmWg98YEAR9RA9gnNuRod07uI/T9dSvHVvg3T7K1jdFtnSs8TOYamxn3wo1I8jud34mUTv7v4Wdk7ujXZJIcIkHFWKon/OpRwiBHNh9w5w0d7qZVvH7dYFhxRYjbUP4d+QzYlUQUVcy1QvixHBr4eYRZ1q7v40OWBKb9lOXdD1I6x7XLtcNcZ08c3xKpiBFjwTPIMot87vw90PTPFigBAfRj1wDocdd9Sg=
37 | script: ./gradlew --stacktrace publishGhPages
38 |
--------------------------------------------------------------------------------
/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 https://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 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 |
74 |
75 | @rem Execute Gradle
76 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
77 |
78 | :end
79 | @rem End local scope for the variables with windows NT shell
80 | if %ERRORLEVEL% equ 0 goto mainEnd
81 |
82 | :fail
83 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
84 | rem the _cmd.exe /c_ return code!
85 | set EXIT_CODE=%ERRORLEVEL%
86 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
87 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
88 | exit /b %EXIT_CODE%
89 |
90 | :mainEnd
91 | if "%OS%"=="Windows_NT" endlocal
92 |
93 | :omega
94 |
--------------------------------------------------------------------------------
/src/main/java/org/opentest4j/MultipleFailuresError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2025 the original author or authors.
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 org.opentest4j;
18 |
19 | import java.util.ArrayList;
20 | import java.util.Collections;
21 | import java.util.List;
22 |
23 | /**
24 | * {@link MultipleFailuresError} is an {@link AssertionError} that aggregates
25 | * multiple failures thrown in a given context (i.e., typically within the
26 | * invocation of a single test).
27 | *
28 | * @author Johannes Link
29 | * @author Sam Brannen
30 | * @author Marc Philipp
31 | * @since 1.0
32 | */
33 | public class MultipleFailuresError extends AssertionError {
34 |
35 | private static final long serialVersionUID = 1L;
36 |
37 | private static final String EOL = System.getProperty("line.separator");
38 |
39 | private final String heading;
40 | private final List