Skip to content

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

Merged
jmrunkle merged 2 commits into
exercism:mainfrom
ajablonski:assertj-a
Oct 12, 2021
Merged

Convert practice exercises starting with 'a' to use AssertJ#2046
jmrunkle merged 2 commits into
exercism:mainfrom
ajablonski:assertj-a

Conversation

@ajablonski
Copy link
Copy Markdown
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
Copy Markdown
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).

Comment thread exercises/practice/accumulate/src/test/java/AccumulateTest.java Outdated
Comment thread exercises/practice/accumulate/src/test/java/AccumulateTest.java Outdated
Comment thread exercises/practice/accumulate/src/test/java/AccumulateTest.java Outdated
Comment thread exercises/practice/acronym/src/test/java/AcronymTest.java Outdated
Comment thread exercises/practice/acronym/src/test/java/AcronymTest.java Outdated
Comment thread exercises/practice/all-your-base/src/test/java/BaseConverterTest.java Outdated
Comment thread exercises/practice/alphametics/src/test/java/AlphameticsTest.java Outdated
- 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
Copy Markdown
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