You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/09/23 13:16:26 UTC

[GitHub] [dubbo] linxiaobai commented on issue #8306: how to refer dubbo service in unit test

linxiaobai commented on issue #8306:
URL: https://github.com/apache/dubbo/issues/8306#issuecomment-925807176


   ```java
   @RunWith(SpringRunner.class)
   @SpringBootTest(classes = MicroServiceApplication.class)
   public class MicroServiceApplicationTest {
   
       @DubboReference(injvm = false)
       private HelloService helloService;
   
       @Test
       public void test() {
           System.out.println(helloService);
           String hello = helloService.hello();
           System.out.println(hello);
       }
   }
   ```
   
   
   ![image](https://user-images.githubusercontent.com/7956413/134512400-142be7b7-e338-4c92-9944-73f193e8214a.png)
   
   
   
   @kevinw66 我这边测试还是不行。你那边本地单测有加@RunWith(SpringRunner.class) 这个吗?需要将spring容器跟单测case一起run才行。
   
   我用的注册中心是nacos的,不知道我们验证的环境是否一致。
   
   目前最新的复现问题的dubbo版本是:
   
   org.apache.dubbo:dubbo:2.7.13
   org.apache.dubbo:dubbo-registry-nacos:2.7.13
   com.alibaba.nacos:nacos-client:1.4.2
   
   
   ---
   之前提问题的时候用的版本是2.7.10,也是一样的问题。
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org