spring-guides / spring-guides/gs-async-method
Missing unit test
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 90
- Forks
- 97
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to use @Async to do some optimize in my app recently, but I didn't found a proper article/guide to do unit test with @Async methods, eg: If the controller invoked a service's async method, how do I confirm the service's async method is done in controller's unit test. Inject a lock into service object when testing? Override the Executor when testing or something else?
Please add a test case to the project and the guide here https://spring.io/guides/gs/async-method/
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the project's asynchronous-method example and the linked Spring guide. Determine how a controller unit test can verify completion of an @Async service method, then add the requested test case and explain the testing approach in the guide. Done means the test covers the async invocation and the guide documents how completion is confirmed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, documentation, testing
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100