简体   繁体   中英

Do i need mockito in spring boot project

I am working on a REST Spring Boot sample project, which does:

  1. Client Application hits an end point with valid request
  2. Using request will run the database query
  3. Fetch the result and assign back to Model object and send as rest response.

In this process, I hardly write business conditional statements. Do I really need Mockito to the Controller , DAO and Service layers ?

I can do the same thing by hitting the end point with request.

Yes, you need a mockito. You can test your rest by hitting the rest by a valid request. But with writing tests, you can run many tests for the same rest for different scenarios with one click. SO you need to write tests to cover all the testing scenarios with one click. on the other hand, if you would test all scenarios through real requests, you need a lot of time and you may make invalid tests. Fianlly, you need a mockito so that you can proceed with unit tests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM