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. Test First , Test Last or Test At All?

Test First , Test Last or Test At All?

Scheduled Pinned Locked Moved The Lounge
wpftestingbeta-testingquestionlounge
36 Posts 18 Posters 1 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 Graham Bradshaw

    So how do you unit test the network access code in my example?

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

    If we follow the TDD approach, then I would mock this up so that the Mock object represented the network access. In other words, I might have an interface called INetworkAccess which I mocked up to represent the access. My test would then test the object which relied on INetworkAccess which would verify whether or not this code worked independent of the network access. Now, you will also need to test your physical network access code, so I would also mock up an object that you could guarantee would be there 100% of the test time. Your network access code would then be tested against this object. By doing all of this, you've broken the testing apart so that you can test code in isolation without having to rely on outside factors. I would really suggest that you take a look at frameworks such as RhinoMocks and areas such as Test Driven Development. They do take some getting used to, but once you are used to them you will find that they really do help.

    Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.

    1 Reply Last reply
    0
    • L Lost User

      Indeed, and obtaining anywhere close to full coverage is no mean feat!


      Kicking squealing Gucci little piggy.
      The Rob Blog

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

      Rob Caldecott wrote:

      Indeed, and obtaining anywhere close to full coverage is no mean feat!

      Sometimes you have to accept that you can't get 100%. You can become obsessed with generating absurd test cases just to get to a line of code, the development loses focus and the project slips.

      Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.

      L 1 Reply Last reply
      0
      • P Pete OHanlon

        Rob Caldecott wrote:

        Indeed, and obtaining anywhere close to full coverage is no mean feat!

        Sometimes you have to accept that you can't get 100%. You can become obsessed with generating absurd test cases just to get to a line of code, the development loses focus and the project slips.

        Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.

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

        Indeed. What do you do about private functions?


        Kicking squealing Gucci little piggy.
        The Rob Blog

        P 1 Reply Last reply
        0
        • L Lost User

          Indeed. What do you do about private functions?


          Kicking squealing Gucci little piggy.
          The Rob Blog

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

          Well - a private function must be there to satisfy a purpose. It shouldn't exist in isolation. Your testing of the exposed surface should attempt to exercise them. If you can't get at them though, it would suggest to me that they are layered too deep (e.g. you have lots of if/else conditions that need to be satisfied to get to them). That normally suggests, to me at least, that there is a more fundamental problem with the design.

          Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.

          1 Reply Last reply
          0
          • H hairy_hats

            Take the Microsoft option and get your users to test it after release.

            G Offline
            G Offline
            Gary Wheeler
            wrote on last edited by
            #27

            Who peed in your oatmeal today?


            Software Zen: delete this;

            1 Reply Last reply
            0
            • T TheIdleProgrammer

              Possibly, but I'm not too interested in the finer details. i just wanted a bit of an informal discussion about other people opinions.

              V Offline
              V Offline
              Vasudevan Deepak Kumar
              wrote on last edited by
              #28

              :) I think as a genuine case, even the Lounge Police seems to have accepted this as an exemption, considering the amount of bona fide responses that the thread has recieved. ;)

              Vasudevan Deepak Kumar Personal Homepage Tech Gossips

              1 Reply Last reply
              0
              • T TheIdleProgrammer

                Hi everyone, I'm curious about other peoples views on unit testing. The company I work for is quite small and there are only four full time developers. We all have different views on programming styles ranging from very old school, constantly questioning the need for object orientation, through to very modern, arguing for progress and trying to keep everybody up to date. We adopted unit testing around two years ago and, although the overall development process takes a little longer, I think everyone agrees that it's more than proved its worth. In general we have written our unit tests after we have written our code but, for me, it has never really seemed like the correct or logical way to do it so recently I have been trying test-driven development and I have found it to be quite useful. I guess really I am keen to know what other people think about the whole approach to unit testing.

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

                TDD - Test Driven Development. Get it started before the company gets big and you'll have a culture of doing it right. Elaine :rose:

                Visit http://www.readytogiveup.com/[^] and do something special today.

                1 Reply Last reply
                0
                • T TheIdleProgrammer

                  Hi everyone, I'm curious about other peoples views on unit testing. The company I work for is quite small and there are only four full time developers. We all have different views on programming styles ranging from very old school, constantly questioning the need for object orientation, through to very modern, arguing for progress and trying to keep everybody up to date. We adopted unit testing around two years ago and, although the overall development process takes a little longer, I think everyone agrees that it's more than proved its worth. In general we have written our unit tests after we have written our code but, for me, it has never really seemed like the correct or logical way to do it so recently I have been trying test-driven development and I have found it to be quite useful. I guess really I am keen to know what other people think about the whole approach to unit testing.

                  N Offline
                  N Offline
                  Nemanja Trifunovic
                  wrote on last edited by
                  #30

                  Test, schmest. If it compiles, ship it! Or even better, use some interpreted programming language so it doesn't even need to compile.


                  Programming Blog utf8-cpp

                  P 1 Reply Last reply
                  0
                  • N Nemanja Trifunovic

                    Test, schmest. If it compiles, ship it! Or even better, use some interpreted programming language so it doesn't even need to compile.


                    Programming Blog utf8-cpp

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

                    Is this the "Testing is for wimps. We make the big bucks in the support contracts" mindset?

                    Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.

                    1 Reply Last reply
                    0
                    • T TheIdleProgrammer

                      Hi everyone, I'm curious about other peoples views on unit testing. The company I work for is quite small and there are only four full time developers. We all have different views on programming styles ranging from very old school, constantly questioning the need for object orientation, through to very modern, arguing for progress and trying to keep everybody up to date. We adopted unit testing around two years ago and, although the overall development process takes a little longer, I think everyone agrees that it's more than proved its worth. In general we have written our unit tests after we have written our code but, for me, it has never really seemed like the correct or logical way to do it so recently I have been trying test-driven development and I have found it to be quite useful. I guess really I am keen to know what other people think about the whole approach to unit testing.

                      V Offline
                      V Offline
                      Vivi Chellappa
                      wrote on last edited by
                      #32

                      Ship the software and let the users discover the bugs for you. After all, God put users on this planet for a reason.:laugh:

                      P 1 Reply Last reply
                      0
                      • V Vivi Chellappa

                        Ship the software and let the users discover the bugs for you. After all, God put users on this planet for a reason.:laugh:

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

                        Vivic wrote:

                        After all, God put users on this planet for a reason.

                        Two words. Legitimate Targets.

                        Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.

                        1 Reply Last reply
                        0
                        • D Duncan Edwards Jones

                          Test immediately after writing (I should do test first but I find running a test to fail because I haven't written any code yet is a bit of a mind set change) However - how many contributions to Codeproject include the unit tests? maybe that should be a suggestion?

                          '--8<------------------------ Ex Datis: Duncan Jones Merrion Computing Ltd

                          A Offline
                          A Offline
                          Anna Jayne Metcalfe
                          wrote on last edited by
                          #34

                          By coincidence I was thinking about this the other day... :->

                          Anna :rose: Linting the day away :cool: Anna's Place | Tears and Laughter "If mushy peas are the food of the devil, the stotty cake is the frisbee of God"

                          1 Reply Last reply
                          0
                          • T TheIdleProgrammer

                            Hi everyone, I'm curious about other peoples views on unit testing. The company I work for is quite small and there are only four full time developers. We all have different views on programming styles ranging from very old school, constantly questioning the need for object orientation, through to very modern, arguing for progress and trying to keep everybody up to date. We adopted unit testing around two years ago and, although the overall development process takes a little longer, I think everyone agrees that it's more than proved its worth. In general we have written our unit tests after we have written our code but, for me, it has never really seemed like the correct or logical way to do it so recently I have been trying test-driven development and I have found it to be quite useful. I guess really I am keen to know what other people think about the whole approach to unit testing.

                            E Offline
                            E Offline
                            El Corazon
                            wrote on last edited by
                            #35

                            chambers-chris wrote:

                            The company I work for is quite small and there are only four full time developers. We all have different views on programming styles ranging from very old school, constantly questioning the need for object orientation, through to very modern, arguing for progress and trying to keep everybody up to date.

                            are you sure you don't work in my department and on my team?

                            chambers-chris wrote:

                            We adopted unit testing around two years ago and, although the overall development process takes a little longer, I think everyone agrees that it's more than proved its worth.

                            I guess not. :laugh: Honestly, I love test driven development, and unit tests. if you can't be TDD at least have regression tests and validation tests. But alas, I can't get anyone to sign on to even those... :((

                            _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                            1 Reply Last reply
                            0
                            • T TheIdleProgrammer

                              Hi everyone, I'm curious about other peoples views on unit testing. The company I work for is quite small and there are only four full time developers. We all have different views on programming styles ranging from very old school, constantly questioning the need for object orientation, through to very modern, arguing for progress and trying to keep everybody up to date. We adopted unit testing around two years ago and, although the overall development process takes a little longer, I think everyone agrees that it's more than proved its worth. In general we have written our unit tests after we have written our code but, for me, it has never really seemed like the correct or logical way to do it so recently I have been trying test-driven development and I have found it to be quite useful. I guess really I am keen to know what other people think about the whole approach to unit testing.

                              R Offline
                              R Offline
                              Roger Wright
                              wrote on last edited by
                              #36

                              It's been a long time since I've done any complex programming, but the old school way always worked well for my projects. Start with a spec. Write a test procedure to verify the spec. Define sub-specs for each module, and test procedures for each. Define interfaces between modules and enforce them with real change control. Design and code the modules, then test them individually. Correct as necessary until the spec is satisfied and the interfaces with other modules are verified. Integrate two or more modules and test again. Integrate the entire project and test some more. Give it to a user and watch him/her break it in a wholly unanticipated way.

                              "A Journey of a Thousand Rest Stops Begins with a Single Movement"

                              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