Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
After constantly reading about the joys of testing, I finally decided to buckle down and implement some tests for a piece of code I'm working on. After I got the first couple of tests written, I was hooked! I had to keep writing more tests. It was fun seeing exactly what contortions I had to do to test various bits of my application.

The pay off was immediate it. Soon after getting a basic test suite in place, I noticed that I had a spare file in my testing directory. I was pretty sure I didn't need it, but not totally. So I simple moved the file away and re-ran my test suite. Everything passed. Now I can delete the file and *know* I don't need it.

That's really what testing buys you. Not some vauge buzzword compliance or some random restriction, but security. Real peace of mind as you can make any change and *know* everything still works as it should.

For me, automated testing was really the obvious next step. I came to realize that I had been doing my own sort of informal testing. Everytime I made a change to my app, I would load it up and navigate through some of the screens, making sure it worked. But automated testing far surpasses this. With one press of a button I can instantly know that *everything* still works, not just the bits I remembered to test.

However while I was coding my tests, it occurred to me that what I was really doing was translating my project specification from a high level language (english) to a lower level one (perl) and in doing so creating something that could be actually used to check functionality. Which made me wonder, what about a way to check functionality without requiring this translation?

At first blush, it seemed rather simple. The majority of my tests were simple things, "ok($foo=~/bar/)" which you could easily translate to english (or keep in english, if you're thinking that way). Simply: $foo should contain bar. and you have an english statement that does the same thing as perl.

But thats not really much of a win, you're simply replacing a bit of perl syntax with the exact equivalent in english, and you still need the code to get the value in to the variable in the first place. You'd also need to repeat your self to test for all of the basic assumptions/restrictions you place on your product, such as what a method should return for no value and things of that nature.

At the moment I can think of no real way to translate between all of the high level assumptions we make when we're describing the project specification, sense so many of these are context sensitive in various ways, I would need a English->Perl translator, which would probably put programmers out of a job if such a thing could actually be written. Anyone else have any ideas on describing the project spec in a higher level / more natural language but still being able to be used as a test?

In reply to Testing: Fun for the family by BUU

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (8)
    As of 2014-09-19 21:17 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (147 votes), past polls