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. Unit Testing... yay or nay?

Unit Testing... yay or nay?

Scheduled Pinned Locked Moved The Lounge
testingbeta-testingquestion
78 Posts 21 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.
  • Greg UtasG Greg Utas

    Titles also mean nothing to me. The fact that I have some respect for Coplien is therefore telling. Maybe unit tests work for you. I developed frameworks for most of my career. To test them, I developed applications that used them.

    Robust Services Core | Software Techniques for Lemmings | Articles
    The fox knows many things, but the hedgehog knows one big thing.

    J Offline
    J Offline
    Jeremy Falcon
    wrote on last edited by
    #23

    Greg Utas wrote:

    Titles also mean nothing to me. The fact that I have some respect for Coplien is therefore telling.

    Fair enough.

    Greg Utas wrote:

    Maybe unit tests work for you. I developed frameworks for most of my career

    There's absolutely no reason a framework would prevent unit testing. If you think that, and I swear I'm not trying to be mean, but you don't know unit testing. And that's ok... I don't know everything. So, just say you don't wanna do it because you don't wanna do it. :laugh:

    Jeremy Falcon

    Greg UtasG 1 Reply Last reply
    0
    • N Nelek

      Jeremy Falcon wrote:

      Come to the dark side Nelek... come... (evil smiley)

      I would, but I am too lazy and procrastinator to do it now. Maybe tomorrow?

      Jeremy Falcon wrote:

      (evil smiley)

      Something like 😈 this?

      M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

      J Offline
      J Offline
      Jeremy Falcon
      wrote on last edited by
      #24

      Nelek wrote:

      I would, but I am too lazy and procrastinator to do it now.

      Thanks for being honest, buddy. :laugh: :laugh: :laugh: This is why we get along.

      Nelek wrote:

      Something like 😈 this?

      Yes!!!! :omg:

      Jeremy Falcon

      N 1 Reply Last reply
      0
      • J Jeremy Falcon

        Greg Utas wrote:

        Titles also mean nothing to me. The fact that I have some respect for Coplien is therefore telling.

        Fair enough.

        Greg Utas wrote:

        Maybe unit tests work for you. I developed frameworks for most of my career

        There's absolutely no reason a framework would prevent unit testing. If you think that, and I swear I'm not trying to be mean, but you don't know unit testing. And that's ok... I don't know everything. So, just say you don't wanna do it because you don't wanna do it. :laugh:

        Jeremy Falcon

        Greg UtasG Offline
        Greg UtasG Offline
        Greg Utas
        wrote on last edited by
        #25

        Quote:

        There's absolutely no reason a framework would prevent unit testing.

        I wasn't talking about a framework preventing it. I was talking about testing the framework itself.

        Robust Services Core | Software Techniques for Lemmings | Articles
        The fox knows many things, but the hedgehog knows one big thing.

        <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
        <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

        J 1 Reply Last reply
        0
        • J Jeremy Falcon

          So I got to thinking... dangerous I know. But curious to know how many peeps unit test their code. IMO _some_ arguments can be made for not doing BDD/functional testing, but unit testing is hard to say "that's a bad thing" for. I know for me, I used to loathe the concept of unit testing. It was like just as boring and tedious as documentation (that nobody ever reads). That was right up until it saved my bacon a few times. Prior to that experience, I've only ever seen devs write crappy tests that were useless and thus considered it a feel-good exercise for a green checkmark. Didn't really think about the dev just being lousy at writing tests. Still don't do TDD though, but fo sho do unit tests after development. Anyone here big into unit testing? Yay? Nay? Has cooties?

          Jeremy Falcon

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #26

          Yay for unit tests, because I like to sleep easy at night. :) Our DOD requires the creation/modification of unit tests when new functionality is implemented and existing functionality modified.  We don't yet do TDD but are in the process of implementing integration test projects that would make it easy for devs to write the test before writing the code. Note: IMHO best practices like these require the buy in of management.  Thankfully all our dev managers are ex-developers. /ravi

          My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

          D J 2 Replies Last reply
          0
          • J Jeremy Falcon

            Daniel Pfeffer wrote:

            IMO, it only makes sense to do unit testing when the inputs & outputs from a function/module can be specified.

            Fo sho, that's actually a unit test. There other type of larger tests (functional tests) that get a bit more abstract, which one can make a case for or against. But, a unit test should test a very small unit. Typically that will equate to a routine, um... unless you have 5 page long functions. :laugh:

            Daniel Pfeffer wrote:

            In cases where the output is not easy to check (for example a trigonometric function), exhaustive testing is impractical. In this case, only very simple "sanity" tests can be performed.

            Keep in mind, I don't know trig like at all... but most testing frameworks allow you to test all kinds of output. If by not being able to test trig you mean like a picture on the screen, you can even test that too whether it's against a fixture or something else. Or perhaps test the routine before it gets sent to a renderer than then also visually compare and so on. It's like riding a bike, the more you do it the mo' easy it becomes to test.

            Jeremy Falcon

            D Offline
            D Offline
            Daniel Pfeffer
            wrote on last edited by
            #27

            One can only test a trigonometric function by comparing its results to the results of another implementation coded using a different approximation. The problem is that one has to write this additional implementation, at least doubling the work that must be performed. One can perform spot checks by comparing the results to known result calculated by another implementation, but that is hardly an exhaustive test of one's implementation.

            Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

            J 1 Reply Last reply
            0
            • R Ravi Bhavnani

              Yay for unit tests, because I like to sleep easy at night. :) Our DOD requires the creation/modification of unit tests when new functionality is implemented and existing functionality modified.  We don't yet do TDD but are in the process of implementing integration test projects that would make it easy for devs to write the test before writing the code. Note: IMHO best practices like these require the buy in of management.  Thankfully all our dev managers are ex-developers. /ravi

              My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

              D Offline
              D Offline
              Daniel Pfeffer
              wrote on last edited by
              #28

              Ravi Bhavnani wrote:

              Note: IMHO best practices like these require the buy in of management.  Thankfully all our dev managers are ex-developers.

              Upvoted for this. Over the decades, I have tried many times to get better practices to be adopted in my places of employment. My attempts have failed, usually when the managers realized that it isn't a magic bullet, and that there is a learning curve for adoption.

              Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

              J 1 Reply Last reply
              0
              • J Jeremy Falcon

                So I got to thinking... dangerous I know. But curious to know how many peeps unit test their code. IMO _some_ arguments can be made for not doing BDD/functional testing, but unit testing is hard to say "that's a bad thing" for. I know for me, I used to loathe the concept of unit testing. It was like just as boring and tedious as documentation (that nobody ever reads). That was right up until it saved my bacon a few times. Prior to that experience, I've only ever seen devs write crappy tests that were useless and thus considered it a feel-good exercise for a green checkmark. Didn't really think about the dev just being lousy at writing tests. Still don't do TDD though, but fo sho do unit tests after development. Anyone here big into unit testing? Yay? Nay? Has cooties?

                Jeremy Falcon

                L Offline
                L Offline
                lmoelleb
                wrote on last edited by
                #29

                Sometimes I am lazy and skip them - typically when I am not quite sure I have the main "flow" worked out. It gives a short term benefit not spending time on them, but of course that has to be paid later - so I do at least make sure to write decoupled code that I can easily add the test. If I am reasonable certain of the flow, I write the test along with the code (sometimes even before as TDD, but that is rare). It is often much faster to itterate over a code block in the test than running an application. And of course, when I do go back and write the tests I skipped I find a bug or two.... In general it works as an investment: loose an hour writing a test now, or waste a day at a later time due to lack of tests... Sometimes the hour now is worth more than the day in the future. It only becomes a problem if the cost of the day in the future isn't even considered when skipping the test.

                J 1 Reply Last reply
                0
                • R RickZeeland

                  Nay, we tried it for a while, but our code is changing so rapidly that maintaining the unit tests proved to be a daunting task for our small team of developers. But it might be fine if you have enough developers to maintain the tests and your code base is not changing too rapidly.

                  L Offline
                  L Offline
                  lmoelleb
                  wrote on last edited by
                  #30

                  Funny how experience can be different. For me, unit tests speed up changing code.

                  R J 2 Replies Last reply
                  0
                  • L lmoelleb

                    Sometimes I am lazy and skip them - typically when I am not quite sure I have the main "flow" worked out. It gives a short term benefit not spending time on them, but of course that has to be paid later - so I do at least make sure to write decoupled code that I can easily add the test. If I am reasonable certain of the flow, I write the test along with the code (sometimes even before as TDD, but that is rare). It is often much faster to itterate over a code block in the test than running an application. And of course, when I do go back and write the tests I skipped I find a bug or two.... In general it works as an investment: loose an hour writing a test now, or waste a day at a later time due to lack of tests... Sometimes the hour now is worth more than the day in the future. It only becomes a problem if the cost of the day in the future isn't even considered when skipping the test.

                    J Offline
                    J Offline
                    Jeremy Falcon
                    wrote on last edited by
                    #31

                    Same man. Not every piece of code is tested, but for the code I know that has to work correctly or else... it is.

                    Jeremy Falcon

                    1 Reply Last reply
                    0
                    • Greg UtasG Greg Utas

                      Quote:

                      There's absolutely no reason a framework would prevent unit testing.

                      I wasn't talking about a framework preventing it. I was talking about testing the framework itself.

                      Robust Services Core | Software Techniques for Lemmings | Articles
                      The fox knows many things, but the hedgehog knows one big thing.

                      J Offline
                      J Offline
                      Jeremy Falcon
                      wrote on last edited by
                      #32

                      Greg Utas wrote:

                      I wasn't talking about a framework preventing it. I was talking about testing the framework itself.

                      I know. Try again. I also know it's clear this conversation isn't gonna go anywhere. You can't say "bruh I don't know it and I don't wanna use it just because". Which means, we're just wasting time here.

                      Jeremy Falcon

                      Greg UtasG 1 Reply Last reply
                      0
                      • D Daniel Pfeffer

                        One can only test a trigonometric function by comparing its results to the results of another implementation coded using a different approximation. The problem is that one has to write this additional implementation, at least doubling the work that must be performed. One can perform spot checks by comparing the results to known result calculated by another implementation, but that is hardly an exhaustive test of one's implementation.

                        Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

                        J Offline
                        J Offline
                        Jeremy Falcon
                        wrote on last edited by
                        #33

                        Daniel Pfeffer wrote:

                        One can only test a trigonometric function by comparing its results to the results of another implementation coded using a different approximation.

                        There's nothing preventing you from unit testing that. It's call mocking and just about every testing framework supports that. Testing approximations with even random values is completely doable in just about any testing framework.

                        Daniel Pfeffer wrote:

                        One can perform spot checks by comparing the results to known result calculated by another implementation, but that is hardly an exhaustive test of one's implementation.

                        There's always more code to write a unit test even if you're testing how to cross the street with grandma. That's not the point. The point is, it's worth it. And tests are an art just like software development, it's as exhaustive as you make it. Just because I don't know trig, doesn't mean I don't know things like cryptography and randomness. You can test that. Promise. But, let's pretend you can't test that one tiny part. Just for the sake of argument. You can still test 80-90% of the rest of the application. Edit: Btw, I hope this post didn't come across as sour man. I never know these days, and well most online chats are... you know. :~

                        Jeremy Falcon

                        D 1 Reply Last reply
                        0
                        • R Ravi Bhavnani

                          Yay for unit tests, because I like to sleep easy at night. :) Our DOD requires the creation/modification of unit tests when new functionality is implemented and existing functionality modified.  We don't yet do TDD but are in the process of implementing integration test projects that would make it easy for devs to write the test before writing the code. Note: IMHO best practices like these require the buy in of management.  Thankfully all our dev managers are ex-developers. /ravi

                          My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                          J Offline
                          J Offline
                          Jeremy Falcon
                          wrote on last edited by
                          #34

                          Ravi Bhavnani wrote:

                          Yay for unit tests, because I like to sleep easy at night. :)

                          Preach brother.

                          Ravi Bhavnani wrote:

                          Our DOD requires the creation/modification of unit tests when new functionality is implemented and existing functionality modified.

                          What's DOD mean? I think Dept of Defense when I hear that. Just curious.

                          Ravi Bhavnani wrote:

                          We don't yet do TDD but are in the process of implementing integration test projects that would make it easy for devs to write the test before writing the code.

                          Be curious to know how it goes. I've never done full blown TDD (I'm stubborn), but would love to hear a use case about it.

                          Ravi Bhavnani wrote:

                          Thankfully all our dev managers are ex-developers.

                          The best ones are, buddy. :thumbsup:

                          Jeremy Falcon

                          R D 2 Replies Last reply
                          0
                          • D Daniel Pfeffer

                            Ravi Bhavnani wrote:

                            Note: IMHO best practices like these require the buy in of management.  Thankfully all our dev managers are ex-developers.

                            Upvoted for this. Over the decades, I have tried many times to get better practices to be adopted in my places of employment. My attempts have failed, usually when the managers realized that it isn't a magic bullet, and that there is a learning curve for adoption.

                            Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

                            J Offline
                            J Offline
                            Jeremy Falcon
                            wrote on last edited by
                            #35

                            And I upvoted your upvote... because why not. :laugh:

                            Jeremy Falcon

                            1 Reply Last reply
                            0
                            • J Jeremy Falcon

                              Greg Utas wrote:

                              I wasn't talking about a framework preventing it. I was talking about testing the framework itself.

                              I know. Try again. I also know it's clear this conversation isn't gonna go anywhere. You can't say "bruh I don't know it and I don't wanna use it just because". Which means, we're just wasting time here.

                              Jeremy Falcon

                              Greg UtasG Offline
                              Greg UtasG Offline
                              Greg Utas
                              wrote on last edited by
                              #36

                              If you develop a framework, you need to eat your own dog food. A cliche, I know. But building an application to test it uncovers not only bugs, but things that should be added or reworked to make developers' lives easier. We're undoubtedly wasting time here. You're not interested in any contrary opinions but just want to virtue signal.

                              Robust Services Core | Software Techniques for Lemmings | Articles
                              The fox knows many things, but the hedgehog knows one big thing.

                              <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
                              <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

                              J 1 Reply Last reply
                              0
                              • L lmoelleb

                                Funny how experience can be different. For me, unit tests speed up changing code.

                                R Offline
                                R Offline
                                RickZeeland
                                wrote on last edited by
                                #37

                                It's also a question of discipline I think, or better the lack of it in our company. :-\

                                1 Reply Last reply
                                0
                                • J Jeremy Falcon

                                  Ravi Bhavnani wrote:

                                  Yay for unit tests, because I like to sleep easy at night. :)

                                  Preach brother.

                                  Ravi Bhavnani wrote:

                                  Our DOD requires the creation/modification of unit tests when new functionality is implemented and existing functionality modified.

                                  What's DOD mean? I think Dept of Defense when I hear that. Just curious.

                                  Ravi Bhavnani wrote:

                                  We don't yet do TDD but are in the process of implementing integration test projects that would make it easy for devs to write the test before writing the code.

                                  Be curious to know how it goes. I've never done full blown TDD (I'm stubborn), but would love to hear a use case about it.

                                  Ravi Bhavnani wrote:

                                  Thankfully all our dev managers are ex-developers.

                                  The best ones are, buddy. :thumbsup:

                                  Jeremy Falcon

                                  R Offline
                                  R Offline
                                  Ravi Bhavnani
                                  wrote on last edited by
                                  #38

                                  DOD = "definition of done" as applied to a work item.  Before a work item can be marked complete, we require that it be unit tested and documented (this applies more to APIs).

                                  Jeremy Falcon wrote:

                                  The best ones are, buddy.

                                  Agreed.  I've found this to be the case more at early stage companies, which are the only places I've worked at since 2000. /ravi

                                  My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                                  J 1 Reply Last reply
                                  0
                                  • R Ravi Bhavnani

                                    DOD = "definition of done" as applied to a work item.  Before a work item can be marked complete, we require that it be unit tested and documented (this applies more to APIs).

                                    Jeremy Falcon wrote:

                                    The best ones are, buddy.

                                    Agreed.  I've found this to be the case more at early stage companies, which are the only places I've worked at since 2000. /ravi

                                    My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                                    J Offline
                                    J Offline
                                    Jeremy Falcon
                                    wrote on last edited by
                                    #39

                                    Ravi Bhavnani wrote:

                                    DOD = "definition of done" as applied to a work item.

                                    Oh crap. I should've figured that out. I need coffee. :laugh: :laugh: Thanks tho.

                                    Ravi Bhavnani wrote:

                                    I've found this to be the case more at early stage companies, which are the only places I've worked at since 2000.

                                    I've been the enterprise world for a while, but I'm starting to think you're onto something. Need a change, might have to give that a go.

                                    Jeremy Falcon

                                    1 Reply Last reply
                                    0
                                    • Greg UtasG Greg Utas

                                      If you develop a framework, you need to eat your own dog food. A cliche, I know. But building an application to test it uncovers not only bugs, but things that should be added or reworked to make developers' lives easier. We're undoubtedly wasting time here. You're not interested in any contrary opinions but just want to virtue signal.

                                      Robust Services Core | Software Techniques for Lemmings | Articles
                                      The fox knows many things, but the hedgehog knows one big thing.

                                      J Offline
                                      J Offline
                                      Jeremy Falcon
                                      wrote on last edited by
                                      #40

                                      Stop with the insults Greg. You do not amuse nor impress me. Also, I never said to not write a consuming application. You assume. And, it's clear you cannot absorb my posts by virtue of not understanding what I said when you misunderstood "framework". So just stop. You don't know a thing about unit testing and you would rather devolve into trite narcissism and demonstrate your lack of maturity.

                                      Jeremy Falcon

                                      1 Reply Last reply
                                      0
                                      • J Jeremy Falcon

                                        So I got to thinking... dangerous I know. But curious to know how many peeps unit test their code. IMO _some_ arguments can be made for not doing BDD/functional testing, but unit testing is hard to say "that's a bad thing" for. I know for me, I used to loathe the concept of unit testing. It was like just as boring and tedious as documentation (that nobody ever reads). That was right up until it saved my bacon a few times. Prior to that experience, I've only ever seen devs write crappy tests that were useless and thus considered it a feel-good exercise for a green checkmark. Didn't really think about the dev just being lousy at writing tests. Still don't do TDD though, but fo sho do unit tests after development. Anyone here big into unit testing? Yay? Nay? Has cooties?

                                        Jeremy Falcon

                                        N Offline
                                        N Offline
                                        Nelson Goncalves Oct2022
                                        wrote on last edited by
                                        #41

                                        I always write tests for the small components in the code (aka unit tests) for two reasons: 1. 1 day of writing unit tests saves me a week of looking for bugs in the small crevices of a larger project 2. unit tests describe the behaviour of the component, so they double as documentation Also, since I have mostly worked at small companies there is usually nobody to double check my code. So testing is fundamental to avoid big mistakes.

                                        J 1 Reply Last reply
                                        0
                                        • J Jeremy Falcon

                                          So I got to thinking... dangerous I know. But curious to know how many peeps unit test their code. IMO _some_ arguments can be made for not doing BDD/functional testing, but unit testing is hard to say "that's a bad thing" for. I know for me, I used to loathe the concept of unit testing. It was like just as boring and tedious as documentation (that nobody ever reads). That was right up until it saved my bacon a few times. Prior to that experience, I've only ever seen devs write crappy tests that were useless and thus considered it a feel-good exercise for a green checkmark. Didn't really think about the dev just being lousy at writing tests. Still don't do TDD though, but fo sho do unit tests after development. Anyone here big into unit testing? Yay? Nay? Has cooties?

                                          Jeremy Falcon

                                          P Offline
                                          P Offline
                                          Private Dobbs
                                          wrote on last edited by
                                          #42

                                          It's a "yay" from me! However I'm a bigger fan of integration testing, whereby one can test the full functionality of a system or part of it. Not a believer in TDD.

                                          J 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