简体   繁体   中英

Unit/Mock testing with Paypal REST SDK best practices

I'm developing an application using the Paypal REST SDK for Java. I'm trying to develop tests for my application. The thing is, the development pattern suggested by Paypal in their documentation for the functionality I'm trying to use is very counterproductive to allowing stubbing and hooking for unit tests. I'd prefer not to make all of the Paypal API structs parameters to my method, because that would bloat my method signature, but I'd like to be able to test my code. What are some best practices or solutions others use to test applications with Paypal REST SDK?

I think this is a good question, however I fail to see how their API can be counterproductive for your testing strategy. Is there any specific coding problem you have; then add that code to your question.

In general you want to isolate all handing of 3-paty integration to a small part of your system (there is no need to use their classes in your own method signatures); then you can mock that part of the system if/when needed. And if you want to you can test that you have a correct integration in isolation (probably by mocking the protocol).

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