spring-guides / spring-guides/gs-async-method

Missing unit test

Open
#26 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.