Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. It's OK Not to Write Unit Tests

It's OK Not to Write Unit Tests

Scheduled Pinned Locked Moved The Lounge
csharpc++comtestingbeta-testing
46 Posts 24 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Nemanja Trifunovic

    A very nice article that describes my pain points with unit testing as well[^].

    utf8-cpp

    M Offline
    M Offline
    Marc Clifton
    wrote on last edited by
    #12

    Nemanja Trifunovic wrote:

    A very nice article that describes my pain points with unit testing as well[^].

    Actually, I found the article to be overly abstract, convoluted, and ultimately pointless. It certainly didn't pass my "mental unit test." It was the comments to the article that kept my interest, and frankly were much better than the article itself (and a lot more entertaining!) Marc

    Will work for food. Interacx

    I'm not overthinking the problem, I just felt like I needed a small, unimportant, uninteresting rant! - Martin Hart Turner

    1 Reply Last reply
    0
    • J Judah Gabriel Himango

      That's not "against the law" when writing tests. What you just described is an integration test.

      Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon Judah Himango

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #13

      Judah Himango wrote:

      is an integration test

      I don't quite see it that way; in my opinion, connecting to A database isn't the same as connecting to THE database.

      M 1 Reply Last reply
      0
      • P peterchen

        I once was like you. Testing is nice and such, but mocking this and mocking that is a pain. That is, until I found the perfect product for me. Why should I ever have to mock a file system or database access, If there's a packaged product that does this for me? Once you recognize that it is silly of thousands of developers to individually mock tiny fragments, you realize there must be a complete, mroe holistic approach. MockOS[^] - all my unit tests run on it. :cool:

        Personally, I love the idea that Raymond spends his nights posting bad regexs to mailing lists under the pseudonym of Jane Smith. He'd be like a super hero, only more nerdy and less useful. [Trevel]
        | FoldWithUs! | sighist | µLaunch - program launcher for server core and hyper-v server

        S Offline
        S Offline
        Shog9 0
        wrote on last edited by
        #14

        peterchen wrote:

        Testing is nice and such, but mocking this and mocking that is a pain.

        I just mock my own code. It saves a lot of trouble (and bruised egos) in the long run... :rolleyes:

        1 Reply Last reply
        0
        • N Nemanja Trifunovic

          A very nice article that describes my pain points with unit testing as well[^].

          utf8-cpp

          M Offline
          M Offline
          Member 96
          wrote on last edited by
          #15

          Unit tests like so much methodology these days are simply ways to commoditize software development. Nothing more, nothing less and like cows to slaughter most developers eat up these kinds of methodologies like candy all the while ignoring the fact that these were designed primarily to make us replaceable worthless cogs in a big machine of corporate development. Unit tests are on most levels counterproductive and worthless to any decent software developer who can recognize bad code before or while they are writing it and nip it in the bud. They're great for accounting and managerial types though so .... yay for them! :) Software developers used to be gods in their domain, now they're just easily replaced cogs in a giant machine of mediocrity and have no one to blame but themselves when their work can be easily outsourced or indeed they themselves can be easily replaced with someone cheaper and less experienced.


          "Creating your own blog is about as easy as creating your own urine, and you're about as likely to find someone else interested in it." -- Lore Sjöberg

          C K 2 Replies Last reply
          0
          • N Nemanja Trifunovic

            A very nice article that describes my pain points with unit testing as well[^].

            utf8-cpp

            G Offline
            G Offline
            Giorgi Dalakishvili
            wrote on last edited by
            #16

            One more nice article about unit testing[^]

            Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion

            1 Reply Last reply
            0
            • N Nemanja Trifunovic

              A very nice article that describes my pain points with unit testing as well[^].

              utf8-cpp

              M Offline
              M Offline
              macu
              wrote on last edited by
              #17

              I think the main problem with unit testing is the assumption that anyone can right a "complete" set of tests. If anyone was capable of doing that their code probably wouldn't need testing in the first place because they'd have covered all scenarios in the code itself as well. But the thing I love about unit testing is the fact that you can test stuff in minutes that would literally take hours to test properly otherwise. For example you've got a web app in which you need to login, navigate down a couple of pages then fill in a form then click GO! The old approach to testing starts when you click GO! With unit testing you can simulate the login process and the form data and have a whole range of tests without needing to use a browser or make up another set of form data. In practice I've found it means you test stuff much more thouroughly even if that doesn't mean "completely" and also that you can test those bits of code that may never have been touched by navigating through some front end or other in order to do your testing.

              1 Reply Last reply
              0
              • M Member 96

                Unit tests like so much methodology these days are simply ways to commoditize software development. Nothing more, nothing less and like cows to slaughter most developers eat up these kinds of methodologies like candy all the while ignoring the fact that these were designed primarily to make us replaceable worthless cogs in a big machine of corporate development. Unit tests are on most levels counterproductive and worthless to any decent software developer who can recognize bad code before or while they are writing it and nip it in the bud. They're great for accounting and managerial types though so .... yay for them! :) Software developers used to be gods in their domain, now they're just easily replaced cogs in a giant machine of mediocrity and have no one to blame but themselves when their work can be easily outsourced or indeed they themselves can be easily replaced with someone cheaper and less experienced.


                "Creating your own blog is about as easy as creating your own urine, and you're about as likely to find someone else interested in it." -- Lore Sjöberg

                C Offline
                C Offline
                ciricivan
                wrote on last edited by
                #18

                Amin :)

                1 Reply Last reply
                0
                • P PIEBALDconsult

                  Judah Himango wrote:

                  is an integration test

                  I don't quite see it that way; in my opinion, connecting to A database isn't the same as connecting to THE database.

                  M Offline
                  M Offline
                  Member 3346080
                  wrote on last edited by
                  #19

                  So it's a mock database

                  1 Reply Last reply
                  0
                  • J Joe Woodbury

                    From the article: Unit testing is no substitute for adversarial testing. A man after my own heart. Too many companies think that testers should be chums with engineering. That's dumb. Testers should have an adversarial relationship with engineering; their job isn't to prove a product works, but that it doesn't. Another way to put it is that testers should think engineers are arrogant assholes and set out to prove it. Engineering should be attempting prove otherwise. That said, I do think "unit" testing has it's place. When I write libraries and classes, I want to make sure they work the way I designed them to work. Writing them in a slightly more organized way helps me to debug them as well. (One of the beefs I do have with many testing suites is that they are awful in helping you debug.) However, I never for a moment believe that I'm doing anything but testing low level functionality and that it's any substitute for system/integration testing. (I'd even say that if my company were big enough and we had a separate testing department, they wouldn't use any of my tests. They'd write their own!) (I should point out that I use "unit" testing quite loosely here. When testing classes, I test them as a class. I just rewrote a Trie class; my test put stuff in and looked it up--I tested only the public interfaces, which tests the protected/private interfaces. But what about those private interfaces that aren't used by the public interfaces? There aren't any.)

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #20

                    I don't have an adverserial relationship, I test to test. Some people test to pass, some test to fail and each approach has it's own risks.

                    Join the cool kids - Come fold with us[^]

                    1 Reply Last reply
                    0
                    • N Nemanja Trifunovic

                      A very nice article that describes my pain points with unit testing as well[^].

                      utf8-cpp

                      M Offline
                      M Offline
                      Mateusz Jakub
                      wrote on last edited by
                      #21

                      I don't understand article, or author is writing about writing unit test to his own code? If yes then, something like this is like leaving thief to judge himself. When you write app alone unit tests are pointless. "Let's be honest. Your tests mostly follow the “happy path”." Get a tester and You won't follow the "happy path" in tests.

                      K 1 Reply Last reply
                      0
                      • N Nemanja Trifunovic

                        A very nice article that describes my pain points with unit testing as well[^].

                        utf8-cpp

                        A Offline
                        A Offline
                        atverweij
                        wrote on last edited by
                        #22

                        The official definition of a unit and a unit test may be nice, but I test to see wheather my application still works as expected. My definition of a unit is a functional parts of the progam; in a winforms application this is a user form, in a webform application it is the webform, in a service application it are the functions the service is written for. In this case I write a database bound test that tests the userform by doing what the user would do. The test results should be as expected; exceptions when they are expected, no exceptions when they are not expected, and the output of the action should be as expected. If something changed in the expected behaviour, the test fails. When a bug arises in the application that I did not test for, I add that situation to the test to insure that this problem will not arise again in the future. It may be not a unit test as it is officially defined, but is ensures that my application still works after I added, changed or fixed something. And that is what a test is for, isn't it? :-D

                        1 Reply Last reply
                        0
                        • M MidwestLimey

                          I once spent 3 months writing a reporting API in C# that spat out Excel docs sucking data from a localized data cube. Now the sales guys and gals could wow potential clients and it was generally well received. 'Twas a thing of surprising beauty considering it featured the words "Excel" and "reporting" in it. Then a Java guy plodded over and wanted to see the Unit Tests. I had none. He pointed out it was policy, and demanded to know how I could qualify a generated report. I jokingly suggested that I build an Excel document parser and run it against different templates based on desired output. He was not amused. Then I ran the app, set it for one year for one product variety and ran the report. I handed the printout to an Argentinean sales rep who happened to be in the office to see a demo. He said it looked good. Unit test complete.

                          10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011

                          F Offline
                          F Offline
                          Fabio Franco
                          wrote on last edited by
                          #23

                          I've always built application without performing unit tests. They all worked and looked good. The client didn't need to know about that as they don't know what unit tests are. I performed my own tests and tried to catch as much workflows as possible, and it has always worked for me. I was afraid to tell anyone this but: "I don't do unit tests!!!!!!!!!" Phew, you helped me take this off my chest.

                          1 Reply Last reply
                          0
                          • N Nemanja Trifunovic

                            A very nice article that describes my pain points with unit testing as well[^].

                            utf8-cpp

                            C Offline
                            C Offline
                            Corsar
                            wrote on last edited by
                            #24

                            Completely disagree. Unit-tests allow to improve design, catch errors, etc, but only if they are written correctly. If you wrote unit-test just to have them, they doesn't make any sense. Another points: good unit-tests allow to understand complex pieces of functionality and easy illustrate/fix existing errors.

                            1 Reply Last reply
                            0
                            • M MidwestLimey

                              I once spent 3 months writing a reporting API in C# that spat out Excel docs sucking data from a localized data cube. Now the sales guys and gals could wow potential clients and it was generally well received. 'Twas a thing of surprising beauty considering it featured the words "Excel" and "reporting" in it. Then a Java guy plodded over and wanted to see the Unit Tests. I had none. He pointed out it was policy, and demanded to know how I could qualify a generated report. I jokingly suggested that I build an Excel document parser and run it against different templates based on desired output. He was not amused. Then I ran the app, set it for one year for one product variety and ran the report. I handed the printout to an Argentinean sales rep who happened to be in the office to see a demo. He said it looked good. Unit test complete.

                              10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011

                              K Offline
                              K Offline
                              Kenneth Kasajian
                              wrote on last edited by
                              #25

                              This is a very roundabout way of saying that there's a competency issue here and that you don't know how to write unit tests. If you did, you'd do it.

                              ken@kasajian.com / www.kasajian.com

                              M 1 Reply Last reply
                              0
                              • J Joe Woodbury

                                From the article: Unit testing is no substitute for adversarial testing. A man after my own heart. Too many companies think that testers should be chums with engineering. That's dumb. Testers should have an adversarial relationship with engineering; their job isn't to prove a product works, but that it doesn't. Another way to put it is that testers should think engineers are arrogant assholes and set out to prove it. Engineering should be attempting prove otherwise. That said, I do think "unit" testing has it's place. When I write libraries and classes, I want to make sure they work the way I designed them to work. Writing them in a slightly more organized way helps me to debug them as well. (One of the beefs I do have with many testing suites is that they are awful in helping you debug.) However, I never for a moment believe that I'm doing anything but testing low level functionality and that it's any substitute for system/integration testing. (I'd even say that if my company were big enough and we had a separate testing department, they wouldn't use any of my tests. They'd write their own!) (I should point out that I use "unit" testing quite loosely here. When testing classes, I test them as a class. I just rewrote a Trie class; my test put stuff in and looked it up--I tested only the public interfaces, which tests the protected/private interfaces. But what about those private interfaces that aren't used by the public interfaces? There aren't any.)

                                K Offline
                                K Offline
                                Kenneth Kasajian
                                wrote on last edited by
                                #26

                                There's a lot of truth here.

                                ken@kasajian.com / www.kasajian.com

                                1 Reply Last reply
                                0
                                • K Kenneth Kasajian

                                  This is a very roundabout way of saying that there's a competency issue here and that you don't know how to write unit tests. If you did, you'd do it.

                                  ken@kasajian.com / www.kasajian.com

                                  M Offline
                                  M Offline
                                  MidwestLimey
                                  wrote on last edited by
                                  #27

                                  So what you're saying is that it's worth spending the company's time and money for a few weeks to develop parsing algorithms to determine whether objects embedded in an Excel document correspond to the given API call and/or data instead of using human visual acuity for an hour in printing and verifying 20 odd reports? You are technically correct, it could be done, however we are not in the business of doing what could be done. We are in the business of doing what is required by our clients so that they improve efficiency and make money. Asinine unit testing, especially wrt UI and reporting where functional testing is vastly better at catching subtlties, is an obsessive scourge brought about by software engineers who found a new hammer and saw everything as nails.

                                  10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011

                                  K 1 Reply Last reply
                                  0
                                  • N Nemanja Trifunovic

                                    A very nice article that describes my pain points with unit testing as well[^].

                                    utf8-cpp

                                    U Offline
                                    U Offline
                                    User 4483848
                                    wrote on last edited by
                                    #28

                                    I personally really like unit testing and I am quite suprised by some of the replies here. It's an interesting comment about college students liking it. I left university a while back, and I think it's unfair to call me incompetent. Unit testing was never mentioned when I was at university though. What do people do instead of unit testing? Do you manually start the whole application and test every feature manually? With unit tests you can test a whole application very quickly. Even the best programmers make mistakes. What happens when you take over another project from somebody else eg. when joining a new company. You may not know what it does, how it does it, or even how obscure the code may be. If the code came with unit tests then you would have some confidence in changes that you make. Some code is very fragile, and like a mine field when making changes. Making developers write tests also forces them to write testable code. Although testable code isn't necessarily good, I think it will improve bad code in most cases. I also think it is very good for a developer to be writing the tests themselves. Only a developer will really understand the potential problems in the code. I find it useful to look at the code and think about what may happen eg. what if the parameters are NULL? It's very easy to write tests that make sure that special values like NULL are handled correctly, and these are the areas where we usually get problems. The tests also depend on how well they are written. Bad tests are almost useless, but good ones will highlight problems before they reach the customer. I'm not saying that unit tests are right or wrong, but I do think they have their place. I like them and want to use them more, but after seeing this thread I am starting to wonder whether I'm heading in the right direction. Any thoughts?

                                    1 Reply Last reply
                                    0
                                    • M MidwestLimey

                                      So what you're saying is that it's worth spending the company's time and money for a few weeks to develop parsing algorithms to determine whether objects embedded in an Excel document correspond to the given API call and/or data instead of using human visual acuity for an hour in printing and verifying 20 odd reports? You are technically correct, it could be done, however we are not in the business of doing what could be done. We are in the business of doing what is required by our clients so that they improve efficiency and make money. Asinine unit testing, especially wrt UI and reporting where functional testing is vastly better at catching subtlties, is an obsessive scourge brought about by software engineers who found a new hammer and saw everything as nails.

                                      10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011

                                      K Offline
                                      K Offline
                                      Kenneth Kasajian
                                      wrote on last edited by
                                      #29

                                      Okay, so it can be done. But are you capable of it? Again, a question of competency.

                                      ken@kasajian.com / www.kasajian.com

                                      M 1 Reply Last reply
                                      0
                                      • K Kenneth Kasajian

                                        Okay, so it can be done. But are you capable of it? Again, a question of competency.

                                        ken@kasajian.com / www.kasajian.com

                                        M Offline
                                        M Offline
                                        MidwestLimey
                                        wrote on last edited by
                                        #30

                                        Yes, but irrelevant. As much as you're trying to portray me as an incompetent boob, you're at risk of seeming to be an expensive liability. Unit testing has it's place, typically away from human interactive aspects of the application where, in my experience, most exceptions occur as a consequence of multiple interactions in unusual sequences. These are seldom caught by unit tests which are by design more atomic in their testing.

                                        10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011

                                        K 1 Reply Last reply
                                        0
                                        • N Nemanja Trifunovic

                                          A very nice article that describes my pain points with unit testing as well[^].

                                          utf8-cpp

                                          J Offline
                                          J Offline
                                          Jorgen Sigvardsson
                                          wrote on last edited by
                                          #31

                                          You're so controversial! I agree with the article. Some people test for the sake of testing, as if that's more important than actually getting something done. I've seen tests that ensures that a property getter returns the last value set by the setter. :wtf: I also don't buy the design methodology that tests should be written first and then the code. This will affect the overall design, in such a way that you might not find holes in the design until it's time to program the damn thing. What do you do then? Rewrite the old tests and/or write new tests. I've found that tests that can be automated, and that actually tests a fair amount of complexity, are more helpful than tests like the stupid getter/setter example above. Tests like "does this collection of objects sent through the DB-layer generate this set of rows in the tables?". I guess I'm swearing in the TDD church, but who cares. I want to deliver correct software on time.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups