function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Suman KuchSuman Kuch 

How to write unit testing on controller contains Http callouts?

Hello Experts,

I'm new to salesforce development and recently started writing apex classes. I got a requirement that uploads/download files using BOX external storage, for this I wrote visualforce page for upload/download and controllet to Http callouts to Box. In order to push this to prod we need to have a Unit test on this apex class. Here how can we write a test on this controller which contains https callouts? Please suggest.

Thanks,
Sumant K
Arkadiy GolovkoArkadiy Golovko
Hi! Usually unit testing can be time-consuming and tedious. That demands patience and thoroughness on the part of the development team. Rigorous documentation must be maintained. Unit testing must be done with an awareness that it may not be possible to test a unit for every input scenario that will occur when the program is run in a real-world environment.
Suman KuchSuman Kuch
thanks for replying Golovko. But in order to pass the code we must have to cover the 75% of code in unit testing so we have to have that code. Please advise.
umesh atryumesh atry
if you are trying to write test class for callout method. you have to write mock response for that.it is very tedious task. practice make you perfect.