51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 580|回复: 2
打印 上一主题 下一主题

Spring boot中的service中的一个function运用了@retryable,请问如何进行集合测试i...

[复制链接]
  • TA的每日心情
    无聊
    4 天前
  • 签到天数: 530 天

    连续签到: 2 天

    [LV.9]测试副司令

    跳转到指定楼层
    1#
    发表于 2021-10-14 13:34:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    1测试积点
    Spring boot中的service中的一个function运用了@retryable,请问如何进行集合测试integration test或者unit test
    Service1 代码

    Service2 代码

    Test代码

    POM file

    现在运行得到的exception如下:
    1. java.lang.IllegalStateException: Failed to load ApplicationContext
    2. at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
    3. at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
    4. at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
    5. at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
    6. at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)
    7. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
    8. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
    9. at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    10. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
    11. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
    12. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
    13. at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    14. at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    15. at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    16. at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    17. at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    18. at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    19. at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    20. at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    21. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
    22. at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    23. at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    24. at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    25. at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
    26. at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
    27. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.config.internalAutoProxyCreator': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Pointcut
    28. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)
    29. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
    30. at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
    31. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    32. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
    33. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)
    34. at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:258)
    35. at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:762)
    36. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:567)
    37. at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
    38. at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
    39. at org.springframework.boot.SpringApplication.run(SpringApplication.java:338)
    40. at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:123)
    41. at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
    42. at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
    43. ... 24 more
    44. Caused by: java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Pointcut
    45. at org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.<clinit>(AbstractAspectJAdvisorFactory.java:62)
    46. at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.initBeanFactory(AnnotationAwareAspectJAutoProxyCreator.java:82)
    47. at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.setBeanFactory(AbstractAdvisorAutoProxyCreator.java:65)
    48. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1826)
    49. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1791)
    50. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
    51. ... 38 more
    52. Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.annotation.Pointcut
    53. at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    54. at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    55. at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    56. ... 44 more
    57. Process finished with exit code 255
    复制代码
    希望可以测试service2中的sendNotification在碰到ConnectException的时候能不能retry,目前用的是Junit4,配置也并不是很清楚为什么要用RunWith(SpringRunner.class),希望可以有大神指点一下,不胜感激!!

    附件: 您需要 登录 才可以下载或查看,没有帐号?(注-册)加入51Testing
    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    5 小时前
  • 签到天数: 1522 天

    连续签到: 1 天

    [LV.Master]测试大本营

    2#
    发表于 2021-10-15 10:44:41 | 只看该作者
    去掉试试
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    4 小时前
  • 签到天数: 997 天

    连续签到: 1 天

    [LV.10]测试总司令

    3#
    发表于 2021-10-15 15:12:16 | 只看该作者
    不是很了解,等大神
    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-25 15:43 , Processed in 0.061593 second(s), 22 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表