Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThrowsOnFalse #1692

Closed
wants to merge 3 commits into from
Closed

ThrowsOnFalse #1692

wants to merge 3 commits into from

Conversation

h1alexbel
Copy link
Contributor

closes #1175

@h1alexbel
Copy link
Contributor Author

@yegor256 take a look, please

@yegor256
Copy link
Owner

@victornoel what do you think?

Copy link
Collaborator

@victornoel victornoel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h1alexbel thank you for your contribution, here are a few comments.

* @param sclr Scalar
* @param msg Message
*/
public ThrowsOnFalse(final Scalar<Boolean> sclr, final String msg) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h1alexbel can you also add a constructor ThrowsOnFalse(final Scalar<Boolean> sclr, final Scalar<Exception> exception) to allow the user to choose which exception will be thrown

void throwsOnFalse() {
final String msg = "test message";
final String message =
Assertions.assertThrows(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h1alexbel please use the Assertion class to write assertions, see other tests for some examples.

@h1alexbel
Copy link
Contributor Author

@victornoel fixed, check again, please

) {
this(
sclr, () -> new IllegalArgumentException(message)
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h1alexbel please put the constructor in this order in the file: first secondary constructor (the one taking a String) and last primary constructor (the one taking the two scalars).

);
@Test(expected = IllegalArgumentException.class)
public void throwsOnFalse() throws Exception {
new ThrowsOnFalse(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h1alexbel please use org.llorllale.cactoos.matchers.Throws with Assertion to check for exception (instead of using expected = IllegalArgumentException.class)

@Test(expected = IllegalArgumentException.class)
public void throwsOnFalse() throws Exception {
new ThrowsOnFalse(
() -> false, "test message"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h1alexbel also check for the error message itself, not only that the exception is thrown

@h1alexbel
Copy link
Contributor Author

@victornoel fixed, take a look again, please

@victornoel
Copy link
Collaborator

@h1alexbel looks good, thank you :)

@victornoel
Copy link
Collaborator

@rultor merge

@rultor
Copy link
Collaborator

rultor commented Sep 10, 2023

@rultor merge

@h1alexbel @victornoel Can't merge it. Some CI checks were failed. Apparently, the pull request is not ready to be merged since it has some problems. Please, fix them first.

@victornoel
Copy link
Collaborator

@yegor256 not sure why we have to codacy checks, but they make no sense with how we write tests, the error is:

JUnit tests should include assert() or fail()

How can we disable them?

@yegor256
Copy link
Owner

@victornoel disabled. Once something new is pushed to this branch, CI checks will be re-run (without codacy)

@victornoel
Copy link
Collaborator

@h1alexbel please could you push again to this branch, for example squash all commits as one, it would be perfect.

@h1alexbel h1alexbel mentioned this pull request Sep 11, 2023
@h1alexbel
Copy link
Contributor Author

@victornoel sure, squashed, new pr is here: #1696

@h1alexbel h1alexbel closed this Sep 11, 2023
@0crat
Copy link
Collaborator

0crat commented Sep 11, 2023

Job gh:yegor256/cactoos#1692 is not assigned, can't get performer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TrueOrThrow class
5 participants