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

For @InjectTest only build new BeanScope when test has mocks or spies #503

Merged
merged 3 commits into from
Feb 13, 2024

Conversation

rbygrave
Copy link
Contributor

Currently, for each test using @InjectTest a new BeanScope is wired (and uses a parent scope with @TestScope beans in it).

This changes, such that the "global test scope" is a pair of BeanScope with

  • "testBaseScope" as scope with all @TestScope beans in it
  • "testAllScope" as all beans (with the testBaseScope as its parent).

Any test that just injects can reuse the "testAllScope" (and not write a new BeanScope).

Any test that uses mocks, spies, has a setup method, or uses profiles must work as before and wire a new BeanScope (and as before use the "testBaseScope" as its parent).

This change makes component testing faster

Currently, for each test using @InjectTest a new BeanScope is wired (and uses a parent scope with @TestScope beans in it).

This changes, such that the "global test scope" is a pair of BeanScope with
- "testBaseScope" as scope with all @TestScope beans in it
- "testAllScope" as all beans (with the testBaseScope as its parent).

Any test that just injects can reuse the "testAllScope" (and not write a new BeanScope).

Any test that uses mocks, spies, has a setup method, or uses profiles must work as before and wire a new BeanScope (and as before use the "testBaseScope" as its parent).

This change makes component testing faster
@rbygrave rbygrave self-assigned this Feb 13, 2024
@SentryMan SentryMan merged commit 06915ff into master Feb 13, 2024
7 checks passed
@rbygrave rbygrave added this to the 9.11 milestone Feb 13, 2024
rbygrave added a commit that referenced this pull request Feb 19, 2024
- Rename GlobalTestScope -> GlobalTestBeans
- Lift and rename GlobalTestScope.Pair to TestBeans
- The plugin scope lives in TestBeans and scoped with the associated test bean scope (created together, closed together)
- Rename PluginInitialise to PluginMgr
- Rename TSBuild to GlobalInitialise

Note the plugin for avaje-nima creates the nima http server, so now this will be started and stopped with the associated bean scope.
rbygrave added a commit that referenced this pull request Feb 19, 2024
- Rename GlobalTestScope -> GlobalTestBeans
- Lift and rename GlobalTestScope.Pair to TestBeans
- The plugin scope lives in TestBeans and scoped with the associated test bean scope (created together, closed together)
- Rename PluginInitialise to PluginMgr
- Rename TSBuild to GlobalInitialise

Note the plugin for avaje-nima creates the nima http server, so now this will be started and stopped with the associated bean scope.
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

Successfully merging this pull request may close these issues.

None yet

2 participants