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

  • Home
  • SEARCH
  • 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 8536615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:42:36+00:00 2026-06-11T10:42:36+00:00

I am trying to figure out how to properly write unit tests for number

  • 0

I am trying to figure out how to properly write unit tests for number conversion to have 100% test coverage and to cover all possibilities.

Let’s say, I have a function which converts integer to roman numeral. It works from 1 to 3999:

function integerToRoman(integer) { ... }

How can I make sure it actually works? Writing 4000 unit tests for every number between 1 and 3999 doesn’t seem like a good option. On the other hand, if I just pick some random numbers and write tests for them, then I cannot be 100% sure the function is working.

  • 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-11T10:42:38+00:00Added an answer on June 11, 2026 at 10:42 am

    100% coverage doesn’t mean testing every single possible input value. But it means that you:

    1. Cover with test every function line
    2. Cover with test normal (generic) input values (not all possible, but from the different ranges if they are processed differently)
    3. Cover all edge cases you can think of
    4. Cover various invalid input values (including no input values as well)

    That’s it.

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

Sidebar

Related Questions

I have been having trouble trying to figure out how to properly convert the
I'm trying to figure out how to properly serialize my XmlDocument and send it
Trying to figure out how I can do this properly. The print_r looks like
Trying to figure out how to identify unique users properly with cookies and perhaps
trying to figure out why this is happening - I have an input text
i am trying to figure out how to write a linq query that will
I am trying to figure out how to write a simple if condition in
I'm trying to figure out the proper way to write this using Razor syntax:
I am trying to figure out what the best way to write the HQL
I am going nuts trying to figure out this all day but without success.

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.