Real Programmers don't need to write test applications!






  • Well, I call myself a Senior Developer, having 20 years of experience,
    and I am doing Unit-Tests for the last 7 years or so. I am also trying
    to convince all of the colleages I get to work with, if they don't
    already unit-test their stuff. But I was simply baffled at the answer I
    got from someone "more senior" than me:

    "If
    you program correctly from the start and do a little thinking
    beforehand, then you don't need no stinking test cases, then they're
    all superfluous"

    Oh well. Can I go and shoot the guy?



  • Nah.  Just wait until he commits a WTF, then point out to him that he would have caught that in unit testing.

     



  • Actually, that particular guy got fired 1.5 years ago for not delivering promised results. No need to wait...



  • This isn't really a WTF, unless it turns out that the story isn't actually a satire.

    Of course, it's definitely an interesting story/satire, just not WTFish.



  • I guesss I'm just a poor lowly newbie seeing as how when I read the article, I was in the middle of writing a small test application for Java nio, since I'm not overly familiar with it, before integrating the new procedure into my project.  I have a lot to learn.      :p



  • @rbowes said:

    This isn't really a WTF, unless it turns out that the story isn't actually a satire.

    Of course, it's definitely an interesting story/satire, just not WTFish.

    I don't think it even qualifies as a story - more a sort of rambling narrative that peters out without really going anywhere. I spent a couple of minutes hunting for a "next page" button... 



  • Curiously enough, I've never found a use for unit tests. I always use fully automated whole-system tests - where necessary, constructing a test harness to drive the application in that mode. Once I've got that up and running, I find it fairly easy to generate (programmatically where necessary) test cases which cover all the interesting parts of the code - there'd be a set of test cases targeting each 'module' in the program, but they all run through the entire program. When you've done all that, there doesn't seem to be much use for unit testing.

    I hypothesise that if you need unit tests, there's something funky about your design that might need rethinking. But I've never run into a case for study, so I'm not really sure.

    I've looked into things like JUnit and CUnit before now - and every time, I've found that it's significantly harder to use them than it is to run the tests through the full application. You spend all your time writing *code* to wrap tests with those things, while on whole-system tests I can spend my time generating more test cases (because one harness handles the entire application, I don't have to write new wrappers for every class/module/function/whatever).

    Maybe it's just the kind of code that I've tended to work on. But I can't help but feel there is something wrong with the unit testing mythos.



  • @asuffield said:

    Curiously enough, I've never found a use for unit tests. I always use fully automated whole-system tests - where necessary, constructing a test harness to drive the application in that mode. Once I've got that up and running, I find it fairly easy to generate (programmatically where necessary) test cases which cover all the interesting parts of the code - there'd be a set of test cases targeting each 'module' in the program, but they all run through the entire program. When you've done all that, there doesn't seem to be much use for unit testing.

    I hypothesise that if you need unit tests, there's something funky about your design that might need rethinking. But I've never run into a case for study, so I'm not really sure.

    I've looked into things like JUnit and CUnit before now - and every time, I've found that it's significantly harder to use them than it is to run the tests through the full application. You spend all your time writing code to wrap tests with those things, while on whole-system tests I can spend my time generating more test cases (because one harness handles the entire application, I don't have to write new wrappers for every class/module/function/whatever).

    Maybe it's just the kind of code that I've tended to work on. But I can't help but feel there is something wrong with the unit testing mythos.

    This is still up in the air for me and for a good number of my colleagues, because we've noticed that making minor changes to code usually result in even more changes to the test harness (after writing tests for each piece of functionality). This comes up even worse with Rails controller refactoring.

    So the question is, is it better to write more integration/acceptance tests, while making sure to have 100% code coverage over writing lots of per-functional unit tests? With only acceptance tests, the idea is that the tests themselves do not change much, if at all. However, then when a test does fail, it seems that, unless there's a ton of acceptance tests, you don't know precisely where the problem is and have to resort to debugging through print statements or a debugger. Granted, I've yet to take a project through this type of testing, so I'm curious as to how it actually works out.

    I wouldn't say that something is "wrong", just not the most efficient. Full unit testing has made me an much better programmer, but I'm always striving to do things faster, better, both in code and in tests. And man have I written a lot of tests.

     



  • I've used JUnit on many different levels. It helps to run test cases for

    - a single class at hand

    - components (i.e. sets of classes that cooperate to provide a functionality)

    - integration tests (similar to component testing, but for checking cooperation between components)

    - system tests (to check existence and functionality of external systems / systems we interface to)

    - acceptance tests (using JUnit as a test bed for running complete applications with user-specified parameters and verifying results)

     

    I would even dare to say that I don't write a single line of code without the appropriate JUnit-Test(s). I am not sure if the test-harness helps me do the testing at the detail level I need at any given moment (and there are many refinement levels, as can be seen above). But maybe it does and I am certainly willing to learn more. The level of testing that I like to use as described above most certainly helps me attain a good measure of repeatability, which supports constant refactoring and thus improvement of my (and other people's) code. There are plenty of WTFs in there anyway, so we need to have means to quickly resolve them as soon as we recognize them. 

    JUnit, of course, is not a big help in testing GUIs. But a) there are other tools for that purpose and b) good architecture and design lets you test most of your applications's functionality at the business layer. GUIs should only be a thin layer on top of the business layer anyway.



  • @asuffield said:

    @rbowes said:

    This isn't really a WTF, unless it turns out that the story isn't actually a satire.

    Of course, it's definitely an interesting story/satire, just not WTFish.

    I don't think it even qualifies as a story - more a sort of rambling narrative that peters out without really going anywhere. I spent a couple of minutes hunting for a "next page" button... 

    it is definitely rambling, no question about that (I wrote it!), but if you read the end you might discover the "hidden" point .... (clue: it's the opposite of what the title states)

    Anyway, I posted it here because I thought some people might enjoy it, since it covers lots of the same general topics we discuss here: "enterprisey" programmers and applications and consultants who have no clue what they are doing and never keep it simple ...



     



  • @asuffield said:

    I don't think it even qualifies as a story - more a sort of rambling narrative that peters out without really going anywhere. I spent a couple of minutes hunting for a "next page" button... 

    I think that, if you recognize the satire (irony? whatever), it makes a pretty good, albeit rambling story.  



  • @TheRider said:



    "If you program correctly from the start and do a little thinking beforehand, then you don't need no stinking test cases, then they're all superfluous"

    Wouldn't "programming correctly" and "thinking" be prerequisites for programming?  So as long as you know how to program, you should never have to test.  He was just too lazy.  I'm glad for your luck that you don't have to work with him any more.


Log in to reply