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

Investigate reducing the usage of Mockito #2534

Open
timyates opened this issue Jul 3, 2024 · 0 comments
Open

Investigate reducing the usage of Mockito #2534

timyates opened this issue Jul 3, 2024 · 0 comments
Labels
build Things related to building the software server

Comments

@timyates
Copy link
Collaborator

timyates commented Jul 3, 2024

We have made good use of Mockito in the tests, however it doesn't play well with GraalVM native image compilation. As part of adding Graal support in #2533 we had to exclude 22 of these tests from the nativeTest execution.

We should investigate how much of this mocking can be replaced with standard classes, or simply using the actual components after the database has been set up in the way we expect for the tests

@timyates timyates added server build Things related to building the software labels Jul 3, 2024
@timyates timyates mentioned this issue Jul 3, 2024
timyates added a commit that referenced this issue Jul 12, 2024
As part of investigating removing the mocking from the tests (for #2534), this switches from using a `mock(EmailSender)` to creating a bean under test which tracks the calls made to it in a simple list.

If the `replace.mailjet.factory` property is set in a test then the standard `MailJetFactory` is replaced by our factory.

This generates EmailSender instances (for HTML and TEXT) which track the calls to their methods in a list of strings.

We can also remove the `setEmailSender` methods which we had to use to force the mock bean into the running services.

I believe this has uncovered a bug in the Guild Service whereby too many emails are being sent.
(see `com.objectcomputing.checkins.services.guild.GuildControllerTest#testEmailSentToGuildLeadWhenGuildMembersAdded`)
I would have expected a single email, but we are sending 2... 🤔
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Things related to building the software server
Projects
None yet
Development

No branches or pull requests

1 participant