Skip to content

only load the lifecycle, bus and event once to make test faster#1563

Merged
reta merged 1 commit intoapache:mainfrom
TestBoost:main
Dec 14, 2023
Merged

only load the lifecycle, bus and event once to make test faster#1563
reta merged 1 commit intoapache:mainfrom
TestBoost:main

Conversation

@TestBoost
Copy link
Copy Markdown
Contributor

The test class ClassUnwrapperTest tries to load the lifecycle, bus and event before every test runs in this test class.

For event, the test class ServletContextEvent creates it with a mocked class and it is only used when starting the application using lifecycle.

For lifecycle, it is only used to start an application with the event and called with getBeanManager().

For bus, it is only used to get certain properties of certain class name.

For all these three fields, the two tests inside the ClassUnwrapperTest are not trying to modify them but just accessing them. Repeatly creating lifecycle, bus and event object will increase the cost of running tests. When run on our own machine, the test runtime can jump from 5.4858 s to 4.5919 s after applying the changes.

@reta
Copy link
Copy Markdown
Member

reta commented Dec 14, 2023

Thank you for contribution @TestBoost !

@reta reta merged commit de62361 into apache:main Dec 14, 2023
reta pushed a commit that referenced this pull request Dec 14, 2023
reta pushed a commit that referenced this pull request Dec 14, 2023
(cherry picked from commit de62361)
(cherry picked from commit 7bd2e78)
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.

2 participants