spring-cloud-alibaba icon indicating copy to clipboard operation
spring-cloud-alibaba copied to clipboard

Fix 7 order-dependent tests by adding a precondition

Open lxb007981 opened this issue 1 year ago • 3 comments

Describe what this PR does / why we need it

This PR fix seven order-dependent tests by always adding a precondition.

Related test: com.alibaba.cloud.nacos.configdata.NacosConfigDataLocationResolverTest.testResolveProfileSpecific_givenNothing_thenReturnDefaultProfile com.alibaba.cloud.nacos.configdata.NacosConfigDataLocationResolverTest.testStartWithASlashIsOK com.alibaba.cloud.nacos.configdata.NacosConfigDataLocationResolverTest.testDataIdMustBeSpecified com.alibaba.cloud.nacos.configdata.NacosConfigDataLocationResolverTest.testInvalidDataId com.alibaba.cloud.nacos.configdata.NacosConfigDataLocationResolverTest.whenCustomizeSuffix_thenOverrideDefault com.alibaba.cloud.nacos.configdata.NacosConfigDataLocationResolverTest.testUrisInLocationShouldOverridesProperty com.alibaba.cloud.nacos.configdata.NacosConfigDataLocationResolverTest.whenNoneInBootstrapContext_thenCreateNewConfigClientProperties

These seven tests are order-dependent flaky. they depend on the environment properties, but these properties are not properly set during the setup(). Some other tests set the properties individually (like testCommonPropertiesHasLowerPriority), which make the tests relying on these properties order-dependent.

Does this pull request fix one issue?

https://github.com/alibaba/spring-cloud-alibaba/issues/3503

Describe how you did it

Properties are now set in the setup() method, which is executed before each test.

Describe how to verify it

Using a test order randomizer can trigger this order-dependent flakiness. Or one can directly run one of the flaky tests individually (instead of run the whole test class), and it will throw some error.

Special notes for reviews

lxb007981 avatar Nov 19 '23 17:11 lxb007981

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Nov 19 '23 17:11 CLAassistant

@lxb007981 Can you open issue to explain pr purpose?

yuluo-yx avatar Nov 22 '23 13:11 yuluo-yx

@lxb007981 Can you open issue to explain pr purpose?

Thank you for reviewing. This pr aims to fix the flakyness within this test class. The detailed issue is linked here. I'm willing to improve this pr is needed.

lxb007981 avatar Nov 22 '23 14:11 lxb007981