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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:56:35+00:00 2026-05-30T22:56:35+00:00

I’m fairly new to unit testing but I completely get the idea of testing

  • 0

I’m fairly new to unit testing but I completely get the idea of testing individual units of code that perform a specific, testable task, however, I’m in a position where I need to write tests and provide confidence in the accuracy of an output of a method that acts on an object with over 50 properties. The combinations of the values of these properties produce an output based on rules injected from a rule definition object (using lambda expressions) which essentially equates to a percentage. These output percentages are “mission critical” and have been rather lazily tested previously, for example the quality of the rule definition class (do all the attributable percentages for each rule add up to 100%) but the actual properties of the object haven’t been.

The “data” object comes from a database but I can, of course, mock it. My problem is the number of permutations of data that would need mocking and the amount of tests that would need to be written to ensure that data x,y,z (times 50 odd exponential) feels near impossible.

So, the question is, how are these situations testable in a real sense. Is scripting tests based on a known “correct” state and “correct” results even possible/sensible? Are unit tests applicable in this case and if not what alternatives are there.

By the way, this is legacy code here with a small opportunity to refactor but only if I can guarantee accuracy etc within timescales of a couple of days to do both the refactor and the tests!

  • 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-30T22:56:36+00:00Added an answer on May 30, 2026 at 10:56 pm

    I think you’ve given half of your answer yourself:

    The combinations of the values of these properties produce an output
    based on rules injected from a rule definition object (using lambda
    expressions) which essentially equates to a percentage.

    In your current unit test, you’d be mocking both the data and the rule. Therefore, you’d need only to ensure that the in- and output methods behave correctly.

    Testing the rule is a different task. I can only guess, but usually, you’ll have an Excel table, or something like that, of possible in- and output values to specify the requirements for this rule. I would convert that same table to a readable (csv) format, and use it directly to drive the rule’s unit test.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported

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.