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

JUnit5的MockApolloExtension方式会强制引入JUnit4依赖 #56

Closed
3 tasks done
kimmking opened this issue Apr 8, 2024 · 0 comments · Fixed by #57
Closed
3 tasks done

JUnit5的MockApolloExtension方式会强制引入JUnit4依赖 #56

kimmking opened this issue Apr 8, 2024 · 0 comments · Fixed by #57

Comments

@kimmking
Copy link
Contributor

kimmking commented Apr 8, 2024

描述bug

在应用使用mockserver做单元测试时,
我们期望:

  • 方式1:JUnit4使用 EmbeddedApollo 和ClassRule方式,
  • 方式2:JUnit5使用 MockApolloExtension 和ExtendWith方式。
    假如我们是一个新项目,使用JUnit5,我们在项目里不期望依赖 JUnit4,但是使用方式2时,MockApolloExtension内部封装的 ApolloTestingServer 有一句代码依赖了EmbeddedApollo,从而引入JUnit4:
private static final Logger logger = LoggerFactory.getLogger(EmbeddedApollo.class);

这样如果项目里没有JUnit4的依赖,就无法运行(EmbeddedApollo的父类是JUnit4中的org.junit.rules.ExternalResource,这个rule机制JUnit5没有了)。

期望

如上

截图

如上

额外的细节和日志

  • 版本:2.2.0
  • 错误日志:none
  • 配置:any
  • 平台和操作系统:all
kimmking added a commit to kimmking/apollo-java that referenced this issue Apr 8, 2024
nobodyiam pushed a commit that referenced this issue Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant