sofastack / sofa-boot

SOFABoot is a framework that enhances Spring Boot and fully compatible with it, provides readiness check, class isolation, etc.
https://www.sofastack.tech/sofa-boot/docs/Home
Apache License 2.0
4.95k stars 1.26k forks source link

Implement a mock component that does not dirty the application context #1172

Closed HzjNeverStop closed 1 year ago

HzjNeverStop commented 1 year ago

Application scenario: You need to Mock some fields of some instance, such as a downstream RPC service, during the execution of a test method

Advantage: There is no need to refresh the Spring context.

Disadvantage: You cannot handle instances of mocks that require Spring context refreshes.