# How to mock auth0 calls in unit testing to avoid calling the api to many times

**URL:** <https://community.auth0.com/t/how-to-mock-auth0-calls-in-unit-testing-to-avoid-calling-the-api-to-many-times/97782>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [January 9, 2023, 6:08pm UTC](https://community.auth0.com/t/how-to-mock-auth0-calls-in-unit-testing-to-avoid-calling-the-api-to-many-times/97782 "2023-01-09T18:08:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![meaganh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/meaganh/32/42375_2.png) [@meaganh](https://community.auth0.com/u/meaganh)\
**Post date:** [January 9, 2023, 6:08pm UTC](https://community.auth0.com/t/how-to-mock-auth0-calls-in-unit-testing-to-avoid-calling-the-api-to-many-times/97782/1 "2023-01-09T18:08:52Z")

</div>

We utilize the Springboot java framework and we have unit testing. We use Mockito and Unirest, however unit tests are called when someone builds - so we could end up calling auth0 100’s of times per day.  
So we are trying to mock it.  
To really check auth0 requests we need to call them…but we don’t want to each time.

I realize this is very open questions, but I wondered what support auth0 for unit testing? What is the best way of doing this? Is there a testing endpoint or is the best way to have this test as a manual run only?

---

<div class="post-metadata">

**Author:** ![SaqibHussain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saqibhussain/32/42924_2.png) [@SaqibHussain](https://community.auth0.com/u/SaqibHussain)\
**Post date:** [January 28, 2023, 10:09pm UTC](https://community.auth0.com/t/how-to-mock-auth0-calls-in-unit-testing-to-avoid-calling-the-api-to-many-times/97782/2 "2023-01-28T22:09:01Z")

</div>

Hi @meaganh

Welcome to the Auth0 Community.

We have some pointers [here](https://auth0.com/docs/deploy-monitor/pre-deployment-checks/predeployment-tests) as to how you may mock the Auth0 API’s during testing.

We also have a blog [here](https://auth0.com/blog/mocking-api-calls-in-python/), it is a different stack but you can get an idea as to how it might work and perhaps do something similar in Java.

I hope this helps.

Warm regards.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 11, 2023, 10:11pm UTC](https://community.auth0.com/t/how-to-mock-auth0-calls-in-unit-testing-to-avoid-calling-the-api-to-many-times/97782/4 "2023-02-11T22:11:41Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
