Skip to content

Convert practice exercises starting with 'a' to use AssertJ #2046

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

Merged
merged 2 commits into from
Oct 12, 2021

Conversation

ajablonski
Copy link
Contributor

pull request

Updates the following exercises:

  • accumulate
  • acronym
  • affine-cipher
  • all-your-base
  • allergies
  • alphametics
  • anagraph
  • armstrong-numbers
  • atbash-cipher

to use AssertJ for the following assertion patterns

  • assertEquals(x, y) --> assertThat(y).isEqualTo(x)
  • assertTrue(x) --> assertThat(x).isTrue()
  • assertEquals(collectionA, collectionB) --> assertThat(collectionB).containsExactly[ElementsOf](collectionA)

I wanted to get feedback on these changes, as I'd seen some other PRs moving towards increased use of AssertJ, and inferred that that was the general direction. In my experience/opinion, AssertJ also gives clearer auto-generated failure messages for the above cases. But please let me know if I'm mistaken/this isn't the direction things are going in, as well as if there are any other tweaks to these patterns before I try making these changes more generally.


Reviewer Resources:

Track Policies

Copy link
Contributor

@jmrunkle jmrunkle left a comment

Choose a reason for hiding this comment

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

This is definitely an improvement, but I have some comments. Mostly I want the assertions to read as much like English as possible:

assertThat(someOperation)...(someResult)

This means we have to inline some of the bad setups that are just assertThat(result).isEqualTo(expected).

- accumulate
- acronym
- affine-cipher
- all-your-base
- allergies
- alphametics
- anagraph
- armstrong-numbers
- atbash-cipher
- Prefer list and map-specific assertions over generic equality
- Prefer inlined variables to separate simple setup
- Prefer .containsExactly & friends to .containsExactlyElementsOf & co
@ajablonski
Copy link
Contributor Author

@jmrunkle appreciate the feedback -- I went ahead and made those adjustments.

@jmrunkle jmrunkle merged commit 8fbd90e into exercism:main Oct 12, 2021
@ajablonski ajablonski deleted the assertj-a branch October 12, 2021 21:08
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.

2 participants