In a microservice architecture, service testing faces an increasing number of challenges. You can configure a local registry so that you can use Alibaba Cloud Toolkit to test microservices. Alibaba Cloud Toolkit allows you to test microservices in the High-speed Service Framework (HSF) and Apache Dubbo frameworks. The feature of testing microservices in the Spring Cloud framework is being developed.
Prerequisites
- IntelliJ IDEA version 2018.3 or later is installed.
- Alibaba Cloud Toolkit is installed and configured in IntelliJ IDEA. For more information, see Install and configure Alibaba Cloud Toolkit in IntelliJ IDEA.
Notice You must select Alibaba Cloud Toolkit V2020.4.1 or later.
Configure and start a registry
http://<IP address of the instance>:8080
in Step 3 to view the microservice version and microservice group.
Start a local registry for a provider application
Configure a custom registry for a consumer application
- Open a consumer project in IntelliJ IDEA.
- In the top navigation bar of IntelliJ IDEA, choose .
- In the Settings dialog box, choose .
- On the registry configuration page, select Join Self-managed Nacos Registry, enter the IP address of the registry to be used in the text box, and then click OK.
Test microservices
This section uses a Dubbo microservice as an example to describe how to test microservices. The procedure for testing HSF microservices is the same as that for testing Dubbo microservices.
Result
- Compile the current project.
- Open the terminal to perform a test task.
The test code and the relevant dependencies are generated in the .edas/service-test/dubbo-test directory in the home directory. If the compilation fails, you can view the test code in the .edas/service-test/dubbo-test directory.