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

test execution time is not accurate #43

Open
bearxc opened this issue Dec 13, 2023 · 10 comments
Open

test execution time is not accurate #43

bearxc opened this issue Dec 13, 2023 · 10 comments

Comments

@bearxc
Copy link

bearxc commented Dec 13, 2023

Hi,
I am running java/maven/JUnit4 on multiple test classes from testparameterinjector 1.14 , I do find the first method of first test class execution is very slow , it takes more than 3-4 mins compared with Junit Parameterized , any suggestion on this ?

I can not find this delay on sequently method/class .

@nymanjens
Copy link
Collaborator

Can you replicate this issue in a minimal example and share that example, please?

@bearxc
Copy link
Author

bearxc commented Dec 13, 2023

the test project is running against our internal spring context /bean app , it is very hard to have a simple example.

we found 3-4 mins increase for first test method in Junit test xml , does testparameterinjector overwrite the way calculating test execution time ?

@nymanjens
Copy link
Collaborator

does testparameterinjector overwrite the way calculating test execution time ?

Not that I know

@bearxc
Copy link
Author

bearxc commented Dec 13, 2023

we add time stamp on before/after method , execution time is not different , but execution time from junit report has increased a lot .

@bearxc
Copy link
Author

bearxc commented Dec 13, 2023

I take a quick look on PluggableTestRunner ,
getTestMethodProcessors().postProcessTestInstance(testInstance, testInfo);

I think this method would take a longer time to process at the first time , considering there are multiple inherence in test class , and each test class have spring beans such as
@Autowired
private TestA testa;
......
@Autowired
private TestB testb;

It would be slow at beginning when going through on parent classes from java reflection .

@nymanjens
Copy link
Collaborator

What would you suggest to fix this?

@bearxc
Copy link
Author

bearxc commented Dec 14, 2023

Maybe we could exclude parsing /scan effort as part of test case execution itself , that cause confusion .

Also , it looks like PluggableTestRunner is running postProcessTestInstance/scan on every test method which is ver heavy.

Not sure how JUnitParamsRunner handle this .

@bearxc
Copy link
Author

bearxc commented Dec 15, 2023

One more suggestion is maybe we need move parse/scan out of methodBlock , otherwise Junit treats that as part of method execution time.

Ideally , we need parse/scan/inject before test class start .

@nymanjens
Copy link
Collaborator

So if I understand you correctly, this is more about the confusing timings reported by JUnit than it is about the actual slowness?

I do wonder why it is so slow for you though. Do you have many test methods? I'd think that the @Autowired stuff gets done after the TestParameterInjector stuff. It would really be helpful if you have a minimal test that you can share that reproduces this issue, so that I can investigate where all the time is being spent. There is definitely a lot of work that's happening multiple times that could be cached if the need arises.

About the time reporting: I had a look at JUnitParamsRunner, and they seem to be interfacing with JUnit in a completely different way, and it's a bit hard to see which one is best.

If you have a proof of concept of what we could do differently, I'm happy to run it against all Google tests and see if it works.

@bearxc bearxc changed the title Run verify slow on first test method test execution time is not accurate Dec 15, 2023
@bearxc
Copy link
Author

bearxc commented Dec 15, 2023

yes, you are right , sorry for confusion , that is not slowness actually , I changed title just now .

Our test classes are inherence from many layers, each layer is spring context with huge @Autowired , there are around 10000 test class/context need to be initialized, it takes 3-4 mins , we compared between JUnitParamsRunner and testparameterinjector , that initialization time is same , only difference is , JUnitParamsRunner trigger initialization before test class start while for testparameterinjector , it happens after test class start .

I think JUnitParamsRunner handle different way as yours for sure .

We will take a look and ping you back once we have good solution .

Thanks for help and support !!!

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

No branches or pull requests

2 participants