aravinth2094 / microservices

Example project for micro-services using spring boot
MIT License
2 stars 4 forks source link

[BUG] Need to correct dependencies between modules for JUnit test cases #1

Open aravinth2094 opened 4 years ago

aravinth2094 commented 4 years ago

Describe the bug The JUnit test cases are not properly executing (although a workaround has been made to force-success them) due to lack of module dependency. For instance, the discovery server and the config server has to be up and running in order for the rest of the services to be running test cases smoothly

To Reproduce Steps to reproduce the behavior:

  1. maven install or maven build from your IDE
  2. Each module gets built individually but independent of each other

Expected behavior Need to be built with dependent modules

Screenshots NA

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context NA

venkatrs-ch197 commented 4 years ago

Hi Aravinth,

Microservices should be independent as it always be loose coupling. There will be 'N' number of Microservices in the project. In order to execute the JUnit test cases properly, we can follow below approaches.

Approach 1: (Might be you already aware of it)

To execute JUnit test cases properly for the client services, you should start parent services (discovery, configserver,...) before Client services get executed.

Approach 2:

Using docker setup in your local environment, and add images to the docker during build. You have to be required to use "docker-maven-plugin" in both server and client. Please check the below URL for more information. https://github.com/sanjayvacharya/sleeplessinslc/tree/master/product-gateway-docker

For more information on Microservices testing strategies https://www.freecodecamp.org/news/these-are-the-most-effective-microservice-testing-strategies-according-to-the-experts-6fb584f2edde/

aravinth2094 commented 4 years ago

Hi Aravinth,

Microservices should be independent as it always be loose coupling. There will be 'N' number of Microservices in the project. In order to execute the JUnit test cases properly, we can follow below approaches.

Approach 1: (Might be you already aware of it)

To execute JUnit test cases properly for the client services, you should start parent services (discovery, configserver,...) before Client services get executed.

Approach 2:

Using docker setup in your local environment, and add images to the docker during build. You have to be required to use "docker-maven-plugin" in both server and client. Please check the below URL for more information. https://github.com/sanjayvacharya/sleeplessinslc/tree/master/product-gateway-docker

For more information on Microservices testing strategies https://www.freecodecamp.org/news/these-are-the-most-effective-microservice-testing-strategies-according-to-the-experts-6fb584f2edde/

Hi @venkatrs-ch197,

Approach 1:

Yes I did succeed in green test cases by running dependent services before hand, but my goal is to automate it using pom.xml plugins, so that the parent pom.xml will perform safe integration test even if one service is changed.

Approach 2:

I really don't think I want to go as far as spawning a whole docker container in a remote VM just to run my JUnit test cases, however the links that you sent are intriguing, will check them out thanks.