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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:47:54+00:00 2026-06-06T15:47:54+00:00

I am reading Code Complete. In that book, Steve McConnell warns that Developer tests

  • 0

I am reading Code Complete. In that book, Steve McConnell warns that “Developer tests tend to be ‘clean tests.’ Developers tend to test for whether the code works (clean test) rather than test for all the ways the code breaks (dirty tests).”

How do I write a test for the way the code breaks? I mean, I can write tests for bad input and make sure that it is blocked correctly. But aside from that, what sorts of things should I be thinking about? What does McConnell mean here? I am comfortable with basic unit testing but trying to master it.

  • 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-06T15:47:56+00:00Added an answer on June 6, 2026 at 3:47 pm

    I think you are on the right path here. Tests to prove that the code works would call a method with sensible, meaningful and expected inputs, with the program in normal state. While tests to break the code try to think “out of the box” regarding that piece of code, thus use any sort of senseless or unexpected input.

    What is IMHO important though is to understand that the two thought processes are very different. When a developer writes code in TDD fashion, (s)he tends to focus on the various bits of functionality to implement in the code, and the tests to prove that this and that bit of functionality or use case works as specified. Tests created this way are what McConnell calls “clean tests”.

    Thinking about how a piece of code could be broken requires a very different thought process and different experience too. It requires looking at your methods and APIs from a different angle, e.g. temporarily putting aside what you know about the aim of these methods and parameters, and focusing only what is technically possible to do with them. Also to think about all the – often implied – preconditions or dependencies required for this method to work correctly. Does it depend on a configuration parameter read from DB? Does it write to the file system? Does it call another component, expecting it to having been initialized properly beforehand? Does it use large amounts of memory? Does it display a message on a GUI?… And what if one or more of these doesn’t hold?

    All this leads to important questions: how should your method handle such dirty cases? Should it crash? Throw an exception? Continue as best as it can? Return an error code? Log an error report?… All these little or bigger decisions are actually quite important for defining the contract of a method or an API correctly and consistently.

    Kent Beck talks about switching between wearing “developer hat” and “tester hat” in the same sense. Fluently switching viewpoints and thought processes this way requires practice and experience.

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

Sidebar

Related Questions

Im currently reading Code Complete by Steve McConnell, specifically page 295 on floating-point numbers.
I began reading the book Code Complete 2nd edition, but stopped reading when I
Reading the code of many javascript libraries, I see that many developers use to
I am currently reading Code Complete where McConnell strongly encourages making all variables private.
I'm just reading Code Complete by Steve McConell and I'm thinking of an Example
I`m reading the code of some open source project. I see that in one
I'm currently reading Head First's Object Oriented Analysis and Design. The book states that
I've been reading Code Complete lately, based off of many references here and also
I've been reading code complete, not far in yet but one of the things
I am reading Code Complete as well as a couple of other programming books

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.