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.94k stars 1.26k forks source link

feat: Added side-effect-free stubbing framework for SOFABoot applications #1224

Closed Peng-YM closed 1 year ago

Peng-YM commented 1 year ago

With the support of @SofaMockBeanFor and @SofaSpyBeanFor annotations, you can easily mock/spy external dependencies when writing integration tests. More importantly, these annotations does not produce any side-effects, which means that the Spring ApplicationContext can be efficiently cached and reused among different test cases, thus greatly reduce test cost.

sofastack-cla[bot] commented 1 year ago

Hi @Peng-YM, welcome to SOFAStack community, Please sign Contributor License Agreement!

After you signed CLA, we will automatically sync the status of this pull request in 3 minutes.

HzjNeverStop commented 1 year ago

This resolves #1172

codecov[bot] commented 1 year ago

Codecov Report

Merging #1224 (7428693) into master (4d3052d) will decrease coverage by 0.39%. Report is 3 commits behind head on master. The diff coverage is 83.37%.

@@             Coverage Diff              @@
##             master    #1224      +/-   ##
============================================
- Coverage     84.51%   84.13%   -0.39%     
- Complexity     2711     2864     +153     
============================================
  Files           308      323      +15     
  Lines          8837     9316     +479     
  Branches       1049     1113      +64     
============================================
+ Hits           7469     7838     +369     
- Misses          898      973      +75     
- Partials        470      505      +35     
Files Changed Coverage Δ
...toconfigure/health/ReadinessAutoConfiguration.java 100.00% <ø> (ø)
...a/test/mock/injector/definition/SpyDefinition.java 39.47% <39.47%> (ø)
...sofa/test/mock/injector/definition/Definition.java 72.72% <72.72%> (ø)
...ay/sofa/boot/compatibility/VerificationResult.java 74.07% <74.07%> (ø)
...t/autoconfigure/runtime/SofaRuntimeProperties.java 80.76% <75.00%> (-0.49%) :arrow_down:
...boot/compatibility/AbstractJarVersionVerifier.java 81.81% <81.81%> (ø)
...ility/AbstractSwitchableCompatibilityVerifier.java 81.81% <81.81%> (ø)
.../test/mock/injector/definition/MockDefinition.java 83.33% <83.33%> (ø)
...ck/injector/InjectorMockTestExecutionListener.java 86.36% <86.36%> (ø)
.../mock/injector/definition/QualifierDefinition.java 87.09% <87.09%> (ø)
... and 8 more

... and 9 files with indirect coverage changes