-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Mock Tests to assist with developing REST API's locally. #1311
Comments
Relates to #1297 |
Relates to #1026 |
@UmenR Actually, the unit tests under So even if a developer's computer is offline (or the test server is down), the unit tests will pass when running |
@nya-elimuai I have changed the title of the issue to better convey what we are looking for, My primary goal is to have some tests that can be run locally so that a developer can test the functionality of a particular endpoint without having to rely on the changes being pushed to TEST env. |
@UmenR Ok, then let's also think about code coverage. By mocking the REST controller's response, which part(s) of the REST controller's code is actually being tested? |
@nya-elimuai All handler methods within a REST controller should Ideally be covered In my opinion But for now, we can stick with adding tests for the controllers that we are currently working on and deal with the other when required. However, I'm also a little stumped when it comes to this matter especially with Creation/Update type of requests. We can discuss and fine-tune the details here. What I have in mind is for Handler methods that handle GET type of requests[1], the entire handler method can be tested by mocking any read operations [1]. The PR already covers this [2] But, the most useful part of adding mocks is to test requests that handle the creation/updating of resources. Especially since these are not covered anywhere as far as I know. But I need to do more research on this part E.G : The new WordContributionRestController[3] that is intended to be used by the crowdsource APP[3] Here we need to mock the persistence, and validation etc. will be covered by the test. What do you think? [1]https://github.com/elimu-ai/webapp/blob/master/src/main/java/ai/elimu/rest/v2/crowdsource/LetterToAllophoneMappingsController.java#L37toL56 |
@UmenR I think Sorry, I still don't properly understand what will be tested if you mock a REST controller. Could you explain which lines of code will be covered with this type of test? |
@UmenR Note that another pending issue is to configure code coverage on Jenkins: https://github.com/elimu-ai/webapp/projects/7#card-45361508 A code coverage tool would enable us to see how many lines of code have been covered by a unit test in each class/method. Maybe this would be useful to have before writing unit tests for mocked functionality? |
Currently, all unit tests are written in a way that the test environment REST API's need to be available for them to pass. Instead, we need to improve the tests so that they are not dependent on using the test environment REST API's. Eg: using mocks.
The text was updated successfully, but these errors were encountered: