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

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

Merged
merged 29 commits into from
Aug 25, 2023

Conversation

Peng-YM
Copy link
Contributor

@Peng-YM Peng-YM commented Aug 8, 2023

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.

长霁 added 2 commits August 8, 2023 20:49
…ions

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
Copy link

sofastack-cla bot commented Aug 8, 2023

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
Copy link
Contributor

This resolves #1172

@sofastack-cla sofastack-cla bot added cla:yes and removed cla:no labels Aug 14, 2023
@codecov
Copy link

codecov bot commented Aug 25, 2023

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%) ⬇️
...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

Copy link
Contributor

@HzjNeverStop HzjNeverStop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -25,6 +25,22 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runtime-sofa-boot 和 isle-sofa-boot 设置 true,test 功能和这两个不强耦合

commons-lang3 依赖移除,替换为 spring 自己的工具类

lombok 依赖移除,框架代码不能依赖动态代码生成,需要直接编写相应代码

@@ -22,6 +22,7 @@
<modules>
<module>sofa-boot-smoke-tests</module>
<module>sofa-boot-jacoco-report</module>
<module>sofa-boot-smoke-tests/sofa-boot-smoke-tests-integration-test</module>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sofa-boot-smoke-tests-integration-test 应该是 sofa-boot-smoke-tests 的子模块,而不是 sofa-boot-tests

<groupId>com.alipay.sofa</groupId>
<artifactId>runtime-sofa-boot-starter</artifactId>
</dependency>
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只需要保留 runtime-sofa-boot-starter 依赖,和 test-sofa-boot-starter 依赖

* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alipay.sofa.testing;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

包名统一修改为 com.alipay.sofa.test,和spring的风格保持一致,用 test 而不是 testing

@HzjNeverStop HzjNeverStop merged commit df7b980 into sofastack:master Aug 25, 2023
1 of 3 checks passed
HzjNeverStop pushed a commit to HzjNeverStop/sofa-boot that referenced this pull request Aug 25, 2023
HzjNeverStop pushed a commit to HzjNeverStop/sofa-boot that referenced this pull request Aug 25, 2023
HzjNeverStop added a commit that referenced this pull request Aug 25, 2023
* cherrypick:Added side-effect-free stubbing framework for SOFABoot applications #1224

---------

Co-authored-by: 致节 <hzj266771@antgroup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants