Fluent Assertions for Result Objects

Result-AssertJ provides assertions to test Result objects

Result Assertions

This library provides fluent assertions to test Result objects.

Adding Assertions to Your Build

Artifact coordinates:

Maven Central Repository provides snippets for different build tools to declare this dependency.

Asserting Result objects

You can use Result assertions in your tests via assertThat:

/**Import result assertions */
import static com.leakyabstractions.result.assertj.ResultAssertions.assertThat;

/* Use result assertions */
@Test
public void should_pass() {
  // Given
  final int zero = 0;
  // When
  final Result<Integer, String> result = success(zero);
  // Then
  assertThat(zero).isZero();
  assertThat(result).hasSuccess(zero);
} // End

If, for some reason, you cannot statically import static method ResultAssertions.assertThat() you can use static method assertThatResult instead:

/**Import result assertions */
import static com.leakyabstractions.result.assertj.ResultAssert.assertThatResult;
import static org.assertj.core.api.Assertions.assertThat;

/* Use result assertions */
@Test
public void should_pass_too() {
  // Given
  final int zero = 0;
  // When
  final Result<Integer, String> result = success(zero);
  // Then
  assertThat(zero).isZero();
  assertThatResult(result).hasSuccess(zero);
} // End

Additional Info

Releases

This library adheres to Pragmatic Versioning.

Artifacts are available in Maven Central.

Javadoc

Here you can find the full Javadoc documentation.

Looking for Support?

We’d love to help. Check out the support guidelines.

Contributions Welcome

If you’d like to contribute to this project, please start here.

Code of Conduct

This project is governed by the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code.

Author

Copyright 2024 Guillermo Calvo.

License

This library is licensed under the Apache License, Version 2.0 (the “License”); you may not use it 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.

Permitted:

Required:

Forbidden: