实践Dubbo单元测试 Posted on 2019-10-24 | In 测试 | Visitors 把dubbo服务作为spring bean来测试,例如: 12345678910111213@RunWith(SpringRunner.class) @SpringBootTest(classes = {DubboRegistryZooKeeperProviderBootstrap.class}) public class TestRemoteServiceImplTests1 { @Autowired private TestRemoteService testRemoteService; @Test public void test1() { ApiResult apiResult = testRemoteService.test("abc"); Assert.assertEquals("OK", apiResult.getStatus().name()); } } 把dubbo服务通过远程调用来测试,例如: 12345678910111213@RunWith(SpringRunner.class) @SpringBootTest(classes = {DubboRegistryZooKeeperProviderBootstrap.class}) public class TestRemoteServiceImplTests { @Reference private TestRemoteService testRemoteService; @Test public void test1() { ApiResult apiResult = testRemoteService.test("abc"); Assert.assertEquals("OK", apiResult.getStatus().name()); } }