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

Unit testing

Scheduled Pinned Locked Moved The Lounge
testingbeta-testingquestion
32 Posts 19 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.
  • G Gary Huck

    Why do I read so much about unit testing? Is such a thing not part of every programmer's everyday life? Are not unit tests just something that is done for every little module one writes? Seriously, what am I missing?

    P Offline
    P Offline
    Pete OHanlon
    wrote on last edited by
    #5

    Ah, there's unit testing and then there's unit testing. Any idiot can write a test. Writing reasonable tests, however, is harder. You have to achieve a balance of coverage with practicality. The key things about unit tests is that they should force you to think about what your code is really doing, and they should help to identify if a change to the code has broken anything. Obviously, this is all a gross oversimplification and is completely wrong, except for the parts where it's right.

    *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

    "Mind bleach! Send me mind bleach!" - Nagy Vilmos

    CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

    1 Reply Last reply
    0
    • N Nish Nishant

      Colin Mullikin wrote:

      I don't think this is a question that other people can answer...

      Yeah, he is reading too much into other people's mind reading capabilities. :)

      Regards, Nish


      My technology blog: voidnish.wordpress.com

      C Offline
      C Offline
      Colin Mullikin
      wrote on last edited by
      #6

      Nish Sivakumar wrote:

      Yeah, he is reading too much into other people's mind reading capabilities.

      This seems like it could very quickly lead to Inception...:thumbsup:

      The United States invariably does the right thing, after having exhausted every other alternative. -Winston Churchill America is the only country that went from barbarism to decadence without civilization in between. -Oscar Wilde Wow, even the French showed a little more spine than that before they got their sh*t pushed in.[^] -Colin Mullikin

      1 Reply Last reply
      0
      • G Gary Huck

        Why do I read so much about unit testing? Is such a thing not part of every programmer's everyday life? Are not unit tests just something that is done for every little module one writes? Seriously, what am I missing?

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #7

        Good unit testing is quite hard on new code. Unit testing on existing code is nearly impossible to do.

        Watched code never compiles.

        1 Reply Last reply
        0
        • G Gary Huck

          Why do I read so much about unit testing? Is such a thing not part of every programmer's everyday life? Are not unit tests just something that is done for every little module one writes? Seriously, what am I missing?

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

          Gary Huck wrote:

          Why do I read so much about unit testing?

          Because software was buggy, and this was a way to do something fancy (make little lights turn green, some people tied unit testing to actual an actual traffic light or siren), and it was a way to automate testing so it was repeatable. Essentially, it gives everyone the illusion that stuff is working.

          Gary Huck wrote:

          Are not unit tests just something that is done for every little module one writes?

          No. Repeatable testing is as hard, if not harder, than writing the program itself, especially when you throw in mocking objects because the data sources come from places like RSS feeds, web services, databases, etc., things that you don't want to necessarily have a live connection to every time you run your tests.

          Gary Huck wrote:

          Seriously, what am I missing?

          Having worked on a project that failed due to bugs? Marc

          My Blog
          Computational Types in C# and F#

          1 Reply Last reply
          0
          • L Lost User

            There's a difference between doing something, doing it properly, and doing it so it is measurable, recordable, and properly covers your ass should the breasts go skywards.

            Every man can tell how many goats or sheep he possesses, but not how many friends. Shed Petition[^]

            A Offline
            A Offline
            Andrei Straut
            wrote on last edited by
            #9

            ChrisElston wrote:

            should the breasts go skywards.

            Till now, I actually thought that was a good thing (associating skyward breasts with firm, young breasts that are...oh, nevermind...) I'll just shut up now :laugh:

            Full-fledged Java/.NET lover, full-fledged PHP hater. Full-fledged Google/Microsoft lover, full-fledged Apple hater. Full-fledged Skype lover, full-fledged YM hater.

            1 Reply Last reply
            0
            • L Lost User

              There's a difference between doing something, doing it properly, and doing it so it is measurable, recordable, and properly covers your ass should the breasts go skywards.

              Every man can tell how many goats or sheep he possesses, but not how many friends. Shed Petition[^]

              S Offline
              S Offline
              Slacker007
              wrote on last edited by
              #10

              ChrisElston wrote:

              breasts go skywards

              Tits up still sounds better. Just saying... :)

              B 1 Reply Last reply
              0
              • G Gary Huck

                Why do I read so much about unit testing? Is such a thing not part of every programmer's everyday life? Are not unit tests just something that is done for every little module one writes? Seriously, what am I missing?

                S Offline
                S Offline
                Slacker007
                wrote on last edited by
                #11

                Unit testing should be done by someone else, IMHO. Someone who did not write the program. I, and many others, like to do our little mini unit tests, in order to sign off on the code for proper testing. My two cents.

                Gary Huck wrote:

                Why do I read so much about unit testing?

                People like to hear themselves talk and they like to see their names in print. Why else are their millions of pages on the web for anything from cooking to debugging knuckle heads. No one is saying anything new, different or beneficial, that hasn't been said already. How many articles do you really need on programming fundamentals? One.

                P G 2 Replies Last reply
                0
                • S Slacker007

                  Unit testing should be done by someone else, IMHO. Someone who did not write the program. I, and many others, like to do our little mini unit tests, in order to sign off on the code for proper testing. My two cents.

                  Gary Huck wrote:

                  Why do I read so much about unit testing?

                  People like to hear themselves talk and they like to see their names in print. Why else are their millions of pages on the web for anything from cooking to debugging knuckle heads. No one is saying anything new, different or beneficial, that hasn't been said already. How many articles do you really need on programming fundamentals? One.

                  P Offline
                  P Offline
                  Paul M Watt
                  wrote on last edited by
                  #12

                  I think unit-tests ARE the original implementers responsibility. Unit-tests is fundamental white-box verification on a very fine scope. Once the individual units are combined and a product is created, someone else should verify the product as a black-box for correctness and completeness. Unfortunately, I think this is one of many areas in software engineering where the vocabulary is not well defined and agreed upon, therefore everyone uses the same terms to mean different things.

                  All of my software is powered by a single Watt.

                  S 1 Reply Last reply
                  0
                  • P Paul M Watt

                    I think unit-tests ARE the original implementers responsibility. Unit-tests is fundamental white-box verification on a very fine scope. Once the individual units are combined and a product is created, someone else should verify the product as a black-box for correctness and completeness. Unfortunately, I think this is one of many areas in software engineering where the vocabulary is not well defined and agreed upon, therefore everyone uses the same terms to mean different things.

                    All of my software is powered by a single Watt.

                    S Offline
                    S Offline
                    Slacker007
                    wrote on last edited by
                    #13

                    I guess you are correct about vocabulary. I don't think that my "white-box" verification is unit testing. I guess it means different things to different people/shops. :)

                    1 Reply Last reply
                    0
                    • G Gary Huck

                      Why do I read so much about unit testing? Is such a thing not part of every programmer's everyday life? Are not unit tests just something that is done for every little module one writes? Seriously, what am I missing?

                      Sander RosselS Offline
                      Sander RosselS Offline
                      Sander Rossel
                      wrote on last edited by
                      #14

                      Gary Huck wrote:

                      Is such a thing not part of every programmer's everyday life? Are not unit tests just something that is done for every little module one writes?

                      Nope. There's probably lots of software out there that isn't even tested at all...

                      It's an OO world.

                      public class Naerling : Lazy<Person>{
                      public void DoWork(){ throw new NotImplementedException(); }
                      }

                      S C 2 Replies Last reply
                      0
                      • G Gary Huck

                        Why do I read so much about unit testing? Is such a thing not part of every programmer's everyday life? Are not unit tests just something that is done for every little module one writes? Seriously, what am I missing?

                        R Offline
                        R Offline
                        R Erasmus
                        wrote on last edited by
                        #15

                        Well... I think you're missing the fact that the little unit tests you write after you write you're gone gets done on a much greater scale than you think. Banking software, life critical software (medical systems, and military/commercial aircraft systems), ect. companies employ whole teams of unit testers to ensure some level of standard. Unit testing is only one type of testing that gets performed on these software systems in order to minimize failure. Yes unit testing your own stuff is good, however the real power of unit testing comes in where someone else tests your stuff, as one tends to not see your own mistakes. The topic of proper unit testing is a completely different one. Proper unit testing can only be done if the necessary things was done before hand in order for you to write your unit tests. You should have some form of a design document (preferable not generated from code) which enables you to right your tests. You should never write your tests from the actual source. (However can also find one or two bugs this way). Testing = Quality = Happy Customer = $$$ in an perfect world that is. Testing = Good marketing pitch

                        "Program testing can be used to show the presence of bugs, but never to show their absence." << please vote!! >>

                        R 1 Reply Last reply
                        0
                        • Sander RosselS Sander Rossel

                          Gary Huck wrote:

                          Is such a thing not part of every programmer's everyday life? Are not unit tests just something that is done for every little module one writes?

                          Nope. There's probably lots of software out there that isn't even tested at all...

                          It's an OO world.

                          public class Naerling : Lazy<Person>{
                          public void DoWork(){ throw new NotImplementedException(); }
                          }

                          S Offline
                          S Offline
                          Slacker007
                          wrote on last edited by
                          #16

                          Naerling wrote:

                          There's probably

                          No. There IS! You made a very good point, here.

                          1 Reply Last reply
                          0
                          • G Gary Huck

                            Why do I read so much about unit testing? Is such a thing not part of every programmer's everyday life? Are not unit tests just something that is done for every little module one writes? Seriously, what am I missing?

                            C Offline
                            C Offline
                            cmger
                            wrote on last edited by
                            #17

                            It might be due to a change that our industry is currently facing. No other industry than ours can decorate a new version with a huge list of bug fixes and call that a feature! Imagine your car is ready from maintenance and the report says "The breaks are now working when the car drives downhill also"... Someone, sometime in some place must have realised that shipping quality software with little bugs (I don't say "no bugs" because that is not achivable) is an attribute that gives you a better position in business competition. Better testing is seen as a (or one) cure to that. For us as developers that means unit testing as a tool and practices like test driven development, pair programming and / or scrum / kanban. The point why there is so much talk about unit testing IMHO is that it is relativley new to us, it is - as others already mentioned - sometimes hard to do if it should be done right and even though the management wants less bugs, they sometimes are not willing to spend the extra money that is needed to educate us in writing (good) unit tests or allow us the extra time that is (not always) needed to write the tests. Regs, Chris

                            1 Reply Last reply
                            0
                            • S Slacker007

                              ChrisElston wrote:

                              breasts go skywards

                              Tits up still sounds better. Just saying... :)

                              B Offline
                              B Offline
                              BrainiacV
                              wrote on last edited by
                              #18

                              In my day we called it "9 edge up".

                              Psychosis at 10 Film at 11 Those who do not remember the past, are doomed to repeat it. Those who do not remember the past, cannot build upon it.

                              P 1 Reply Last reply
                              0
                              • S Slacker007

                                Unit testing should be done by someone else, IMHO. Someone who did not write the program. I, and many others, like to do our little mini unit tests, in order to sign off on the code for proper testing. My two cents.

                                Gary Huck wrote:

                                Why do I read so much about unit testing?

                                People like to hear themselves talk and they like to see their names in print. Why else are their millions of pages on the web for anything from cooking to debugging knuckle heads. No one is saying anything new, different or beneficial, that hasn't been said already. How many articles do you really need on programming fundamentals? One.

                                G Offline
                                G Offline
                                Gary Huck
                                wrote on last edited by
                                #19

                                Slacker007 wrote:

                                Unit testing should be done by someone else, IMHO

                                Now, there's a [new to me] good idea. Glad I asked.

                                C 1 Reply Last reply
                                0
                                • R R Erasmus

                                  Well... I think you're missing the fact that the little unit tests you write after you write you're gone gets done on a much greater scale than you think. Banking software, life critical software (medical systems, and military/commercial aircraft systems), ect. companies employ whole teams of unit testers to ensure some level of standard. Unit testing is only one type of testing that gets performed on these software systems in order to minimize failure. Yes unit testing your own stuff is good, however the real power of unit testing comes in where someone else tests your stuff, as one tends to not see your own mistakes. The topic of proper unit testing is a completely different one. Proper unit testing can only be done if the necessary things was done before hand in order for you to write your unit tests. You should have some form of a design document (preferable not generated from code) which enables you to right your tests. You should never write your tests from the actual source. (However can also find one or two bugs this way). Testing = Quality = Happy Customer = $$$ in an perfect world that is. Testing = Good marketing pitch

                                  "Program testing can be used to show the presence of bugs, but never to show their absence." << please vote!! >>

                                  R Offline
                                  R Offline
                                  RafagaX
                                  wrote on last edited by
                                  #20

                                  R. Erasmus wrote:

                                  Testing = Good marketing pitch

                                  It should be: Testing = Good marketing pitch = Happy Customer (Until it buys the product) = $$$ :laugh:

                                  CEO at: - Rafaga Systems - Para Facturas - Modern Components for the moment...

                                  1 Reply Last reply
                                  0
                                  • G Gary Huck

                                    Slacker007 wrote:

                                    Unit testing should be done by someone else, IMHO

                                    Now, there's a [new to me] good idea. Glad I asked.

                                    C Offline
                                    C Offline
                                    ClockMeister
                                    wrote on last edited by
                                    #21

                                    IMO, even if you do have someone else unit-testing your code it's a good idea to write your own unit tests. I've always built a generic utility program that I use for that and just add onto it every time I write a significant routine. It's actually kind of fun and has resulted in handy utilities that I wound up using later! I've never used any of the "formal" unit testing stuff that are supposedly "best practice" nowadays, I've just always been in the habit of writing programs that test the boundaries of code I write. Guess I've been at this too long. -CB :-)

                                    S 1 Reply Last reply
                                    0
                                    • Sander RosselS Sander Rossel

                                      Gary Huck wrote:

                                      Is such a thing not part of every programmer's everyday life? Are not unit tests just something that is done for every little module one writes?

                                      Nope. There's probably lots of software out there that isn't even tested at all...

                                      It's an OO world.

                                      public class Naerling : Lazy<Person>{
                                      public void DoWork(){ throw new NotImplementedException(); }
                                      }

                                      C Offline
                                      C Offline
                                      ClockMeister
                                      wrote on last edited by
                                      #22

                                      Naerling wrote:

                                      Nope. There's probably lots of software out there that isn't even tested at all...

                                      You got that right. I have had to clean up more than my share of messes after people who threw code together and never ran it. I'm serious: I've seen code in our system that was obvious to me that no one put it to any kind of test *at all* as it could crash the system as soon as it was exercised. I've even seen an occasional section checked in where it was obviously not even compiled before being checked-in! :wtf: If you're writing a new code section or fixing a bug, at least run the code before turning it in, huh? I hate to say it, folks: but sometimes our work can be hard. It takes WORK. (Oops, there's that 4-letter word again!) Some people just don't need to be doing this. -CB

                                      Sander RosselS P 2 Replies Last reply
                                      0
                                      • C ClockMeister

                                        Naerling wrote:

                                        Nope. There's probably lots of software out there that isn't even tested at all...

                                        You got that right. I have had to clean up more than my share of messes after people who threw code together and never ran it. I'm serious: I've seen code in our system that was obvious to me that no one put it to any kind of test *at all* as it could crash the system as soon as it was exercised. I've even seen an occasional section checked in where it was obviously not even compiled before being checked-in! :wtf: If you're writing a new code section or fixing a bug, at least run the code before turning it in, huh? I hate to say it, folks: but sometimes our work can be hard. It takes WORK. (Oops, there's that 4-letter word again!) Some people just don't need to be doing this. -CB

                                        Sander RosselS Offline
                                        Sander RosselS Offline
                                        Sander Rossel
                                        wrote on last edited by
                                        #23

                                        CodeBubba wrote:

                                        people who threw code together and never ran it

                                        Yep, I know it. I've worked with someone who checked in some code after weeks of work. It was all set and ready to be delivered to the customer. So I thought I'd see what she made and the first button I pressed crashed the software. I assumed this was a minor bug that she had missed, but as I restarted it became appearent this wasn't a single bug. Crash after crash after crash... Here's the deal, the programmer had one test case which worked fine, but she never tested anything else. I removed her test data before testing and all hell broke loose. As I had promised our customer that we would deliver that same week I made a 30+ hour weekend just to be able to deliver on monday... :sigh:

                                        It's an OO world.

                                        public class Naerling : Lazy<Person>{
                                        public void DoWork(){ throw new NotImplementedException(); }
                                        }

                                        C 1 Reply Last reply
                                        0
                                        • Sander RosselS Sander Rossel

                                          CodeBubba wrote:

                                          people who threw code together and never ran it

                                          Yep, I know it. I've worked with someone who checked in some code after weeks of work. It was all set and ready to be delivered to the customer. So I thought I'd see what she made and the first button I pressed crashed the software. I assumed this was a minor bug that she had missed, but as I restarted it became appearent this wasn't a single bug. Crash after crash after crash... Here's the deal, the programmer had one test case which worked fine, but she never tested anything else. I removed her test data before testing and all hell broke loose. As I had promised our customer that we would deliver that same week I made a 30+ hour weekend just to be able to deliver on monday... :sigh:

                                          It's an OO world.

                                          public class Naerling : Lazy<Person>{
                                          public void DoWork(){ throw new NotImplementedException(); }
                                          }

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

                                          Naerling wrote:

                                          Here's the deal, the programmer had one test case which worked fine, but she never tested anything else. I removed her test data before testing and all hell broke loose. As I had promised our customer that we would deliver that same week I made a 30+ hour weekend just to be able to deliver on monday... :sigh:

                                          It's frightening to think about how much software there might be out there that is just "one scenario" away from blowing away a database, isn't it? :omg:

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