Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7560541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:55:49+00:00 2026-05-30T12:55:49+00:00

I have some experience with unit testing and mocks. In my limited experience I

  • 0

I have some experience with unit testing and mocks. In my limited experience I would use the two to test a service layer, for example, mocking (stubbing?) out the database to eliminate dependencies and concentrate on unit testing the business logic.

Now I’m creating a wrapper API implementation that will consume RESTful web services. The json result structure sent back to me is out of my hands, for example: Twitter. I’m simply building the client to interface with their api. I’m unsure how to go about unit testing the json result. Right now I’m just mocking the result of the http request with a static json structure. This ensures that the deserialzing of json to my pojos is correct, but I’m concerned about API changes. What if the api structure changes? What if the api currently returns “title” today and “groovy_title” tomorrow? My unit test wouldn’t catch that.

From my understanding though – unit tests are supposed to be quick. Previously I would mock the db and now I’m mocking http, but should I actually be using the concrete http implementation so I’m notified immediately of a breaking api change? Or is there a better way to approach this situation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:55:51+00:00Added an answer on May 30, 2026 at 12:55 pm

    I would continue to do what you are doing and mock the interface between your code and the external API. As you point out, this will not detect changes in the external API.

    You could write integration tests that actually go to the external server to test for API changes. I suspect you have separated out the code that does the interaction into its own server/module, so you can literally ping the external API without being obstructed by more than 1 abstraction layer in your app.

    Note, you could build these tests without using your app code; i.e. just wget or curl and do some analysis on the results…

    The issues with this are numerious; off the top of my head:

    You need a network connection
    Slower
    The external service could be down temporarily — i.e. failure could mean different things.
    etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I've done unit testing some, and have experience writing tests, but I have
Anybody out there have experience testing out of process assemblies? I'm testing some Com+
I don't have much experience doing unit testing. From what I learned, code should
I am a web-developer working in PHP. I have some limited experience with using
I want to introduce Unit Testing to some colleagues that have no or little
I have some experience making multiplayer turn-based games using sockets, but I've never attempted
I have some experience using parallel extensions in .Net development, but I was looking
I have some experience in ASP.Net and can work my way around it without
I have some experience writing web applications in Java for class projects. My first
Hi I have some experience with programming but I'm not very good with pointers.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.