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

    C Offline
    C Offline
    CPallini
    wrote on last edited by
    #8

    Wow, I thought unit testing was all about focusing on the functionality of a quite logical independent unit, "not (a) test (that) cannot talk to a database, communicate across the network, touch the filesystem, run concurrently with another test, or require extensive setup. If they are any dependencies, they are mocked away". Dogmatic approaches are pretty useless for me. :)

    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
    [My articles]

    P K 2 Replies Last reply
    0
    • C CPallini

      Wow, I thought unit testing was all about focusing on the functionality of a quite logical independent unit, "not (a) test (that) cannot talk to a database, communicate across the network, touch the filesystem, run concurrently with another test, or require extensive setup. If they are any dependencies, they are mocked away". Dogmatic approaches are pretty useless for me. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

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

      Right. If I write a method that connects to a database and I want to unit test it, it had better connect to an actual database.

      J 1 Reply Last reply
      0
      • P PIEBALDconsult

        Right. If I write a method that connects to a database and I want to unit test it, it had better connect to an actual database.

        J Offline
        J Offline
        Judah Gabriel Himango
        wrote on last edited by
        #10

        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 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
          Joe Woodbury
          wrote on last edited by
          #11

          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 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

            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
                                          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