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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:00:17+00:00 2026-05-25T11:00:17+00:00

I am trying to use TDD for my coding practice. I would like to

  • 0

I am trying to use TDD for my coding practice. I would like to ask should I test with a data that should not happen in a function BUT this data may possibly break your program.

Here is one of a easy example to illustrate to what I ask :

a ROBOT function that has a one INT parameter. In this function I know that the valid range would only be 0-100. If -1, 101 is used, the function will be break.

function ROBOT (int num){
...
...
...
return result;
}

So I decided some automated test cases for this function…

1. function ROBOT with input argument 0
2. function ROBOT with input argument 1
3. function ROBOT with input argument 10
4. function ROBOT with input argument 100

But should I write test cases with input argument -1 or 101 for this ROBOT function IF I would guard that in my other function that call function ROBOT???

5. function ROBOT with input argument -1
6. function ROBOT with input argument 101

I don’t know if it is necessary cause I think it is redundancy to test -1 and 101. And If it is really necessary to cover all the cases, I have to write more code to guard -1 and 101.

So in Common practice of TDD, will you write test case on -1 and 101 as well???

  • 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-25T11:00:18+00:00Added an answer on May 25, 2026 at 11:00 am

    In short, if it can break, then you should test it. Also validate data at the earliest point possible.

    The answer depends on whether you control the inputs passed to Robot. If Robot is an internal class (C#) ; values only flow in from RobotClientX which is a public type. Then I’d put the guard checks in RobotClientX, write tests for it. I’d not write tests for Robot, because invalid values cannot materialize in-between.
    e.g. if I put my validations in the GUI such that all invalid values are filtered off at the source, then I don’t check for invalid values in all classes below the GUI (Unless I’ve also exposed a public API which bypasses the GUI).

    On the other hand, if Robot is publicly visible i.e. Anyone can call Robot with any value that they please, then I need tests that document it’s behavior given specific kinds of input.. invalid being one of them. e.g. if you pass an out-of-range value, it’d throw an ArgumentException.

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

Sidebar

Related Questions

I'm currently trying to use PHPUnit to learn about Test Driven Development (TDD) and
I'm not very familiar with RhinoMocks and I'm trying to break into TDD on
I'm developing a Spring webflow, trying to use TDD so I've extended AbstractXmlFlowExecutionTests. I
I'm trying to improve my TDD/OO skills and each time I try and use
I use Assert.Fail a lot when doing TDD. I'm usually working on one test
I am trying out TDD and creating fake objects, I want to use XML
I started trying to learn tdd and wanted to use it on a real
I'm trying use jquery to remove a class from an element (not knowing ahead
I revieving the following error when trying use mysql_real_escape() function Fatal error: Call to
I was trying use a set of filter functions to run the appropriate routine,

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.