Result-AssertJ provides assertions to test Result objects
This library provides fluent assertions to test Result objects.
Artifact coordinates:
com.leakyabstractions
result-assertj
0.9.1.0
Maven Central Repository provides snippets for different build tools to declare this dependency.
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
This library adheres to Pragmatic Versioning.
Artifacts are available in Maven Central.
Here you can find the full Javadoc documentation.
We’d love to help. Check out the support guidelines.
If you’d like to contribute to this project, please start here.
This project is governed by the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code.
Copyright 2024 Guillermo Calvo.
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: