[BUG] SofaRpcFallbackRegistryTest has order dependent tests #3281
Closed
Description
Issue Description
Type: bug report
Describe what happened
- In
com.alibaba.csp.sentinel.adapter.sofa.rpc.fallback.SofaRpcFallbackRegistryTest
, the unit testtestDefaultfallback()
will fail when run after the unit testtestCustomFallback()
. - This is because the tests
SofaRpcFallbackRegistryTest.testCustomFallback()
pollutes the shared statesSofaRpcFallback.providerFallback
andSofaRpcFallback.consumerFallback
between tests at
- However, these states aren't cleaned after the test
testCustomFallback()
is run causing the above mentioned test to fail
Describe what you expected to happen
- The unit tests in
com.alibaba.csp.sentinel.adapter.sofa.rpc.fallback.SofaRpcFallbackRegistryTest
should pass when run in any order
How to reproduce it (as minimally and precisely as possible)
- In
com.alibaba.csp.sentinel.adapter.sofa.rpc.fallback.SofaRpcFallbackRegistryTest
, run the following unit tests in ordertestCustomFallback()
testDefaultFallback()
- Running the tests in the above manner will produce
java.lang.AssertionError
java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:86)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertTrue(Assert.java:52)
at com.alibaba.csp.sentinel.adapter.sofa.rpc.fallback.SofaRpcFallbackRegistryTest.testDefaultfallback(SofaRpcFallbackRegistryTest.java:42)
Tell us your environment
- Sentinel:
1.8.6
- OS:
Mac OS X 14.0 aarch64
- Java:
17.0.9
or1.8.0_381
Anything else we need to know?
- I have raised a PR Fix order dependent tests in SofaRpcFallbackRegistryTest #3282 to fix this issue by resetting the polluter states
SofaRpcFallback.providerFallback
andSofaRpcFallback.consumerFallback
to its default value after the testSofaRpcFallbackRegistryTest.testCustomFallback()
is executed.