Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I remember once when I was about to try out a new way of rounding monetary amounts in a big application. The rounding routine was low level stuff, called from the entire program. Ideally the outside API wouldn't change that much.

So I changed the routine (which wasn't a refactoring, but a minor but actual change in logic) and ran the test suit.

Only two out of maybe twenty sets contained failing tests. Hmmm... is this a good thing or a bad thing?

A little of both. It was a good thing, because my change broke very little of what I had bothered to test. But this also showed I had a blind spot in the tests wrt what I just changed, and had I written tests at a more detailed level, more tests probably would have failed. I had to write more tests to verify what I expected from the program. Without a test suite... eh, I don't even want to think about that.

My story is related to refactoring.

When you refactor, you increase your general knowledge about the code, and in what ways it may need to be further tested. This happens when looking for refactoring opportunities and while changing the code.

So if you know your tests and your code you'll hopefully understand where you may be vulnerable, and you can add tests, before, during and after you refactor to counter that.

/J


In reply to Re: Refactoring makes unit tests obsolete by jplindstrom
in thread Refactoring makes unit tests obsolete by FoxtrotUniform

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-28 20:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found