Strongbox: Standardize tests assertions to AssertJ

Created on 3 Sep 2019  路  5Comments  路  Source: strongbox/strongbox

Task Description

Within tests, we have at least 3 kinds of libraries used for assertions:

  • org.hamcrest.Matchers.*
  • org.junit.jupiter.api.Assertions.*
  • org.assertj.core.api.Assertions.*

We should standardize them and prepare a doc on how to write test assertions. We decided to use AssertJ (https://joel-costigliola.github.io/assertj/) to replace JUnit 5 and Hamcrest assertions. See also https://joel-costigliola.github.io/assertj/assertj-core-converting-junit5-assertions-to-assertj.html for examples.

Note: During the course of standardizing the tests, @mkuligowski and @fuss86 noticed that dropping Hamcrest in the strongbox-web-core will introduce a lot of complications due to spring-projects/spring-framework#21178. We decided that until the mentioned issue is fixed, the strongbox-web-core will be the only module in the project which will continue to use hamcrest.

Tasks

The following tasks will need to be carried out in both the strongbox and strongbox-npm-metadata projects:

  • [ ] ~drop <groupId>org.hamcrest</groupId> dependency from pom.xml files~
  • [x] exclude <groupId>org.hamcrest</groupId> from dependency tree
  • [x] replace org.hamcrest.*Matchers by their AssertJ counterparts (except for strongbox-web-core)
  • [x] replace org.junit.jupiter.api.Assertions by their AssertJ counterparts
  • [ ] update https://strongbox.github.io/developer-guide/junit-user-guide.html doc

Additional Info

This task may be split into sub-tasks to perform the standardization per module for example.

Useful Links

Help

  • Our chat
  • Points of contact:

    • @carlspring

    • @fuss86

    • @sbespalov

    • @steve-todorov

enhancement good first issue help wanted in progress

Most helpful comment

There is an issue which prevents us from fully switching to AssertJ (spring-projects/spring-framework#21178). We have decided to leave it for now in the strongbox-web-core module to prevent introducing additional complexity into the test cases. Once spring-projects/spring-framework#21178 is fixed we can make the switch there as well.

// cc @fuss86

All 5 comments

I can take this

@tizzymac go for it :)

Can I take this?
It's been two weeks when task was taken

Yes, please, @mslowiak !

There is an issue which prevents us from fully switching to AssertJ (spring-projects/spring-framework#21178). We have decided to leave it for now in the strongbox-web-core module to prevent introducing additional complexity into the test cases. Once spring-projects/spring-framework#21178 is fixed we can make the switch there as well.

// cc @fuss86

Was this page helpful?
0 / 5 - 0 ratings