JJCSA / backend

0 stars 1 forks source link

[Test case fix] delete test fix #55

Closed sanketshah1997 closed 3 years ago

sanketshah1997 commented 3 years ago

Description

## Issue Fixes # ## Checklist - [x] I have commented my code in hard-to-understand areas - [x] I have created relevant Unit Tests for the feature I implemented - [x] I have pulled and merged the latest code and resolved all merge conflicts - [x] I have added someone to review this PR, and informed the team on Slack
shah-tejas commented 3 years ago

Well it will test against stage keycloak, every time the unit test is run. Sure it works when stage is up. But when not, it'll not work. If it's working, that's fine to keep it for now.

But as I mentioned earlier, we should focus on unit testing individual components and other things should be mocked. In this case, you should be testing only UserService and all other services should be mocked.

I will try to write some examples when I can. But if not, you can look into Mockito. It fits perfectly with Spring Boot and especially with our use case.

An example: https://howtodoinjava.com/spring-boot2/testing/spring-boot-mockito-junit-example/

On Sat, May 22, 2021, 9:14 AM Sanket A Shah @.***> wrote:

@.**** commented on this pull request.

In src/test/resources/application-test.yml https://github.com/JJCSA/backend/pull/55#discussion_r637402785:

@@ -29,7 +29,7 @@ keycloak: bearer-only: true ssl-required: none resource: jjcsa

no, I don't think so. actually, I tested it locally and it's working but curious why you feel it will fail?

— You are receiving this because your review was requested. Reply to this email directly, view it on GitHub https://github.com/JJCSA/backend/pull/55#discussion_r637402785, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKSKZTOT2ALVPD574BQEILTTO6U4BANCNFSM45IFFFMA .

sanketshah1997 commented 3 years ago

Well it will test against stage keycloak, every time the unit test is run. Sure it works when stage is up. But when not, it'll not work. If it's working, that's fine to keep it for now. But as I mentioned earlier, we should focus on unit testing individual components and other things should be mocked. In this case, you should be testing only UserService and all other services should be mocked. I will try to write some examples when I can. But if not, you can look into Mockito. It fits perfectly with Spring Boot and especially with our use case. An example: https://howtodoinjava.com/spring-boot2/testing/spring-boot-mockito-junit-example/ On Sat, May 22, 2021, 9:14 AM Sanket A Shah @.> wrote: @*.** commented on this pull request. ------------------------------ In src/test/resources/application-test.yml <#55 (comment)>: > @@ -29,7 +29,7 @@ keycloak: bearer-only: true ssl-required: none resource: jjcsa - auth-server-url: http://localhost:8080/auth + auth-server-url: http://backend.jjcsausa.com:8080/auth/ no, I don't think so. actually, I tested it locally and it's working but curious why you feel it will fail? — You are receiving this because your review was requested. Reply to this email directly, view it on GitHub <#55 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKSKZTOT2ALVPD574BQEILTTO6U4BANCNFSM45IFFFMA .

yeah that will def fail because we have dependency over keycloak for performing actual functions. I already looked up this example and working on the test case to improve it using mocking the beans. So my test case is actually using the user service, repository and aws3service to save it into the actual s3 bucket,DB and keycloak. so if I use mocked beans it will inject the beans but not able to perform these actual functions. I am working on how I can define the mocked behaviour for these and will improve it moving ahead.