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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:08:38+00:00 2026-05-11T03:08:38+00:00

I am starting out with automated testing and I would like to test one

  • 0

I am starting out with automated testing and I would like to test one of my data access methods. I am trying to test what the code does if the database returns no records.

Is this something that should be done in a unit test or an integration test?

Thanks

  • 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. 2026-05-11T03:08:39+00:00Added an answer on May 11, 2026 at 3:08 am

    If your test code connects to an actual database and relies on the presence of certain data (or lack of data) in order for the test to pass, it’s an integration test.

    I ususally prefer to test something like this by mocking out the component that the ‘data access method’ used to get the actual data, whether that’s a JDBC connection or web service proxy or whatever else. With a mock, you say ‘when this method is called, return this’ or ‘make sure that this method is called N times’, and then you tell the class under test to use the mock component rather than the real component. This then is a ‘unit test’, because you are testing how the class under test behaves, in a closed system where you’ve declared exactly how the other components will behave. You’ve isolated the class under test completely and can be sure that your test results won’t be volatile and dependent on the state of another component.

    Not sure what language/technology you are working with, but in the Java world, you can use JMock, EasyMock, etc for this purpose.

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

Sidebar

Related Questions

I am just starting out with Django and would like to know the best
When starting out with a new application, would you rather just use an existing
I am just starting out with DI & unit testing and have hit a
I'm just starting out with Ruby and Rails, trying out Devise with Rails 3.
Starting out with an int variable unix time stamp (something like 1290341015), is there
Just starting out using MVC3 and hit a problem trying to build a drop-down
I'm just starting out with WiX as I need to be able to automate
Just starting out in asp.net. Have just created a login.aspx page in my site
I am just starting out with Silverlight (2 RC0) and can’t seem to get
So I am just starting out developing PHP web applications and have finished setting

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.