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 4601594
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:50:56+00:00 2026-05-21T23:50:56+00:00

Suppose you are required to use an unnecessarily complicated, difficult to mock (perhaps it

  • 0

Suppose you are required to use an unnecessarily complicated, difficult to mock (perhaps it has concrete classes with no virtual interface), and unreliable third-party library that integrates with some external resource such as a socket or a database. You decide to create “wrapper” interfaces/classes to greatly simplify the usage of this library and to allow developers using the wrapper to continue to write testable code. The wrapper’s interface looks nothing like the original interface.

I have a few questions about how to test this wrapper.

  1. Should the wrapper be tested without the external resource by developing a method-for-method layer over the bad library that can be mocked?

  2. When you test your wrapper classes with the 3rd party library (using the external resources) is this a unit test or an integration test? If the external resource can be embedded in memory during the automated test, is it still an integration test?

  3. At what point do we quit mocking and stubbing and say that we have a unit. According to wikipedia “A unit is the smallest testable part of an application.” but I am finding this difficult to measure. If speed is a factor in decide whether or not we are testing a unit, how do you decide how slow is too slow for the test to be called a unit test?

  • 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-21T23:50:57+00:00Added an answer on May 21, 2026 at 11:50 pm

    TDD doesn’t say that everything must be unit tested. TDD says that you should write a test first but it doesn’t have to be a unit test.

    1. Start with integration test – it will test your logic dependent on wrapper which will communicate with a real component. No mocks here. It is integration test because it tests multiple layers of your application and real component still uses sockets or database access.
    2. The integration test will fail because you don’t have your logic
    3. Write unit test with mocked wrapper to test the logic
    4. The unit test will fail because you don’t have your logic
    5. Write the logic to satisfy the unit test (4.)
    6. Repeat 3.-5. to get all logic necessary to satisfy the integration test (1.)
    7. Repeat whole process with the next integration test

    There is no need to write unit tests for wrapper. The main wrapper’s function is to wrap the component. If you write unit test for wrapper you will test that it calls method on the component but in such case you are back at the beginning – how to mock the component? If you write integration test just for wrapper calling the component you are retesting the component (OK this is sometimes handy but in normal scenario you don’t do that).

    I recommend reading Growing Object-Oriented Software guided by tests by Steve Freeman and Nat Pryce.

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

Sidebar

Related Questions

Suppose I have a pure virtual method in the base interface that returns to
Suppose i have the following Moose package: package GSM::Cell; use Moose; has 'ID' =>
Suppose I have a class Baz that inherits from classes Foo and Bar ,
I suppose a way to paraphrase this question is why can't HTTP just use
I have a question about Spring transaction propagation . Suppose I use @Transactional(propagation =
Suppose that a couple hundred Gigs after starting to use HIVE I want to
Suppose we need to embed a widget in third party page. This widget might
suppose i have a .on() function wherein i select multiple ids $(#i, #am, #your,
Suppose I have a large list of words. For an example: >>> with open('/usr/share/dict/words')
Suppose I have a static method of my class that returns an object of

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.