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

Fix order dependent test in handler test #1996

Merged

Conversation

SaaiVenkat
Copy link
Contributor

@SaaiVenkat SaaiVenkat commented Nov 14, 2023

Issue

  • In com.networknt.handler.HandlerTest, the unit test validConfig_init_handlersCreated() can trigger java.lang.RuntimeException when being run before the unit test invalidMethod_init_throws() in the same class because it pollutes state shared among tests.
  • It may be good to clean this state pollution so that some other tests do not fail in the future due to the shared state polluted by this test.

Fixes #2005

Solution

  • Resetting the HandlerConfig to default value before each test run using the Junit's @Before annotation, where the configuration is set to default value through Handler.setConfig('handler')
  • Adding initChain() because initPath() in setConfig, which expects handler or chain to already be created.

@SaaiVenkat
Copy link
Contributor Author

Greetings @stevehu, similar to #856, this PR also fixes the order dependency issue. I am happy to hear your feedback and discuss more about this issue.

@stevehu
Copy link
Contributor

stevehu commented Nov 19, 2023

@SaaiVenkat It makes sense. Thanks a lot for your help.

@stevehu stevehu merged commit fc11652 into networknt:master Nov 19, 2023
younggwon1 pushed a commit to younggwon1/light-4j that referenced this pull request Feb 10, 2024
* Fixed order dependent tests in HandlerTest by resetting HandlerConfig

* Added Code Comments
@SaaiVenkat SaaiVenkat deleted the fix-order-dependent-test-in-handler-test branch October 1, 2024 19:24
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.

Unit test validConfig_init_handlersCreated in HandlerTest is order dependent
2 participants