Skip to content

Support Spring autowire two and more different beans of one type #2421

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

Conversation

tepa46
Copy link
Collaborator

@tepa46 tepa46 commented Jul 17, 2023

Description

Fixes #2389

Now Spring unit tests can autowire two different beans of one type.

If all test executions use only one autowired bean of some class, then we can mock this variable by @mock annotation,
else we need to use simple mock.

How to test

Manual tests

Manually tested on a spring-boot-testing project and a project that does not use Spring framework.

Self-check list

  • I've set the proper labels for my PR (at least, for category and component).
  • PR title and description are clear and intelligible.
  • I've added enough comments to my code, particularly in hard-to-understand areas.
  • The functionality I've repaired, changed or added is covered with automated tests.
  • Manual tests have been provided optionally.
  • The documentation for the functionality I've been working on is up-to-date.

@tepa46 tepa46 added ctg-enhancement New feature, improvement or change request comp-codegen Issue is related to code generator comp-spring Issue is related to Spring projects support labels Jul 17, 2023
@tepa46 tepa46 requested a review from EgorkaKulikov July 17, 2023 14:40
@EgorkaKulikov EgorkaKulikov merged commit 1e571a9 into main Jul 18, 2023
@EgorkaKulikov EgorkaKulikov deleted the kirill/support-autowire-more-than-one-diff-beans-of-one-type branch July 18, 2023 11:26
@alisevych alisevych added this to the Spring Phase 4 milestone Jul 18, 2023
@alisevych
Copy link
Member

@tepa46
Please add the manual test scenario like following:

  1. Open project
  2. Open class
  3. Generate tests with following settings: ...
  4. Check that ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-codegen Issue is related to code generator comp-spring Issue is related to Spring projects support ctg-enhancement New feature, improvement or change request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Spring unit tests cannot autowire two different beans of one type
3 participants