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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:46:09+00:00 2026-06-01T18:46:09+00:00

Just having a conversation with someone in the office about using a business logic

  • 0

Just having a conversation with someone in the office about using a business logic class to build up some data in order to test another class.

Basically, he has class A which takes a complex type as a parameter and then generates a collection of a different complex type as a result. He’s written tests around this class already. Now he’s moved on to testing another class (class B) which takes the result of class A then performs some logic on it.

He’s asked the question, “should I use class A to build up a scenario to test class B with”.

At first I said yes as class A has tests around it. But then I figured well what if there’s some bugs in class A that we haven’t found yet… so I guess there must be a better way to address this scenario.

Does anyone have any thoughts on this? Is it OK to use existing logic to save time writing other tests?

Regards,

James

  • 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-06-01T18:46:11+00:00Added an answer on June 1, 2026 at 6:46 pm

    Stances on that might differ. Generally, if code is tested and you assume it works, you’re free to use it. This is especially true when using already tested methods to help with testing others (within single class/unit). However, as this happens within single unit it’s a bit different from your case.

    Now, when dealing with 2 separate classes I’d say you should avoid such approach. Purely for the reason that those two classes might not be related in obvious way or their context/scope of usage might vastly differ. As in, somebody might change class A without even knowing class B exists. Class B tests suddenly break even though no changes were made to B code. This brings unnecessary confusion and is situation you usually don’t want to find yourself in.

    Instead, I suggest creating helper method within tested class B file. With stubs/fakes and tools like AutoFixture, you should be able to easily reproduce generation logic used by class A and have your own “copy” contained in class B tests.

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

Sidebar

Related Questions

... after having just read http://www.cocoadev.com/index.pl?CocoaInsecurity ... I am curious to know about your
I having an app so i just added some event or remainder (football match,movie)
I'm just getting started using ADO.NET and DataSets and DataTables. One problem I'm having
I'm just having a play with Roslyn but unsure on how to do the
I'm completely new to Flex and am just having a play with a sample
Sorry for my inpatience but after weeks staying up late and just having put
Having just read the first four chapters of Refactoring: Improving the Design of Existing
Having just pulled my hair off because of a difference, I'd like to know
Having just updated Mono to 2.6.3 (on OS X), I noticed in the installer
Having just started with MVC 2 I notice that in their starter template they

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.