Live data from Hacker News

Ask HN: Best Way to Mock APIs in 2020?

news.ycombinator.com

11–20 of 63 posts

Re: Ask HN: Best Way to Mock APIs in 2020?

#13
If you have a database - try this https://github.com/xgenecloud/xgenecloud

Automatically generates REST & GraphQL APIs within seconds from your database schema.

Here is a demo on how to create 8000+ REST APIs within 10 seconds - https://youtu.be/NtCwnlLudnk

Not just mock - you may even consider writing the full backend on it.

Im the creator - happy to answer any questions.

edit : added demo link

Re: Ask HN: Best Way to Mock APIs in 2020?

#14
post #12

Can someone explain to me what this is all about? Shouldn't you hide all your API calls behind an interface, and then mock that interface? Dependency inversion principle, depend upon abstractions and all that.

I personally am not a fan of too many abstractions.

If the only reason for abstraction is testing, then mocking an interface seems like a more valid choice to me.

Re: Ask HN: Best Way to Mock APIs in 2020?

#15
post #12

Can someone explain to me what this is all about? Shouldn't you hide all your API calls behind an interface, and then mock that interface? Dependency inversion principle, depend upon abstractions and all that.

I personally am not a fan of too many abstractions. If the only reason for abstraction is testing, then mocking an interface seems like a more valid choice to me.

The abstraction is there because in many static languages you will immediately have two implementations, the infrastructure one (database, API call, 3rd party) and the tests.

Re: Ask HN: Best Way to Mock APIs in 2020?

#18
post #12

Can someone explain to me what this is all about? Shouldn't you hide all your API calls behind an interface, and then mock that interface? Dependency inversion principle, depend upon abstractions and all that.

I personally am not a fan of too many abstractions. If the only reason for abstraction is testing, then mocking an interface seems like a more valid choice to me.

> I personally am not a fan of too many abstractions.

Then you're likely in the wrong business, since most of what programming is is dealing with the various facets of one abstraction or another.

Re: Ask HN: Best Way to Mock APIs in 2020?

#19
post #18

Earlier quoted context omitted.

I personally am not a fan of too many abstractions. If the only reason for abstraction is testing, then mocking an interface seems like a more valid choice to me.

> I personally am not a fan of too many abstractions. Then you're likely in the wrong business, since most of what programming is is dealing with the various facets of one abstraction or another.

This is definitely a valid approach to software development, e.g. in embedded development (where you still might need to call APIs).
Post reply on HN