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

Side affect mock DateTimeProvider #246

Closed
1 task done
Romancha opened this issue Jul 5, 2020 · 1 comment
Closed
1 task done

Side affect mock DateTimeProvider #246

Romancha opened this issue Jul 5, 2020 · 1 comment

Comments

@Romancha
Copy link
Contributor

Romancha commented Jul 5, 2020

Overview of the issue

Using mock for dateTimeProvider may side affect users test that use dateTimeProvider. To avoid side affect we need to use @MockBean

Motivation for or Use Case

I have my own integration tests, which use the createdDate, lastModifiedDate in the verification of business logic. I was a bit confused when my tests fell and saw that the createdDate, lastModifiedDate in my objects equals Instant.now() - minus 4 days. The reason for this is using @mock DateTimeProvider in UserServiceIT.

Reproduce the error

  1. Create a test in which an object with the createdDate, lastModifiedDate will be created.
  2. Compare createdDate, lastModifiedDate with current date.

Expected result: createdDate, lastModifiedDate have Instant.now() value
Actual result: createdDate, lastModifiedDate have Instant.now() - 4 days value

Related issues

n/a

Link to PR (if any)

#247

KHipster Version(s)

1.8.1

  • Checking this box is mandatory (this is just to show you read everything)
@Romancha
Copy link
Contributor Author

Romancha commented Jul 7, 2020

PR merged #247
Also fixed in generator-jhipster - jhipster/generator-jhipster#12042

@Romancha Romancha closed this as completed Jul 7, 2020
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

No branches or pull requests

1 participant