Unit Testing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • D. Yates

    Unit Testing

    Hi,

    In an effort to improve my own code and try to teach others that I work with
    that unit testing IS MANDATORY. I'm interested in examples of unit testing
    that other people are using.

    How many folks rely on NUNIT?

    Do you create a testing class per application, per class, per assembly to
    exercise your code?

    Do you know of any links that show examples of how the "Agile process"
    incorporates unit testing into its process?

    Know of any code in source forge that contains testing code?

    How have to standardized your testing classes/code so that it "looks" and
    "feels" the same and isn't totally confusing to outsiders that may have to
    maintain your code?

    Do you embed your test class into the same assembly as the class it tests?
    I like this idea because it keeps someone else from breaking your code (at
    least making sure it compiles) when they come in to do a "quick" change.

    I would appreciate any links or book recommendations on the subject.

    Thanks,
    Dave


  • Jon Skeet [C# MVP]

    #2
    Re: Unit Testing

    D. Yates <foeman@hotmail .com> wrote:[color=blue]
    > In an effort to improve my own code and try to teach others that I work with
    > that unit testing IS MANDATORY. I'm interested in examples of unit testing
    > that other people are using.
    >
    > How many folks rely on NUNIT?[/color]

    <raises hand>
    [color=blue]
    > Do you create a testing class per application, per class, per assembly to
    > exercise your code?[/color]

    Per class, usually.
    [color=blue]
    > Do you know of any links that show examples of how the "Agile process"
    > incorporates unit testing into its process?[/color]

    I suspect pretty much any description of Agile coding is likely to
    mention unit testing. I don't have any specific links off-hand though.
    [color=blue]
    > Know of any code in source forge that contains testing code?[/color]

    Pretty much any test tool project will have test code. Other examples
    are Spring and Hibernate - both Java projects, but I'd expect their
    ..NET equivalents to have test clode too.
    [color=blue]
    > How have to standardized your testing classes/code so that it "looks" and
    > "feels" the same and isn't totally confusing to outsiders that may have to
    > maintain your code?[/color]

    We tend to use m_subject as a member variable which refers to an
    instance of the class under test, for starters.
    [color=blue]
    > Do you embed your test class into the same assembly as the class it tests?
    > I like this idea because it keeps someone else from breaking your code (at
    > least making sure it compiles) when they come in to do a "quick" change.[/color]

    No, we use a different project in the same solution. You don't really
    want test code bloating the release DLL - especially if you embed test
    data files. On the other hand, if you don't mind a little bit of extra
    space and don't mind the possibility of people finding your tests, it's
    a great way to allow easy testing of internal members too.

    --
    Jon Skeet - <skeet@pobox.co m>
    http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
    If replying to the group, please do not mail me too

    Comment

    • nthomson

      #3
      Re: Unit Testing

      I would agree with Jon, we take a similar approach.

      Use NUnit, test per class and keep our test classes seperate from the
      main application.

      Comment

      • ampijanka

        #4
        Re: Unit Testing

        VS2005TS has sample code on the we fly 247 demo CD

        Comment

        • A Miller

          #5
          Re: Unit Testing

          D. Yates wrote:
          [color=blue]
          >
          > I would appreciate any links or book recommendations on the subject.[/color]

          Here are a couple of links which you might find useful:

          Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!





          Angus Miller





          Comment

          • D. Yates

            #6
            Re: Unit Testing

            Jon,

            Thanks for your response.

            How do you handle application testing provided that your unit testing
            passes? Do you just use human testers or is your testing automated in
            anyway?

            Dave


            Comment

            • D. Yates

              #7
              Re: Unit Testing

              Angus,

              Thanks for your response.

              I noticed that on the test driven site they reference a book called
              "Test-Driven Development in .NET". Do you own this book? If so, what are
              your thoughts as to its worth. In other words, do you refer to it often or
              almost never.....

              Thanks,
              Dave

              "A Miller" <angus@amlsoftw arexx.co.uk> wrote in message
              news:ek1jfKL$FH A.160@TK2MSFTNG P12.phx.gbl...[color=blue]
              > D. Yates wrote:
              >[color=green]
              >>
              >> I would appreciate any links or book recommendations on the subject.[/color]
              >
              > Here are a couple of links which you might find useful:
              >
              > http://groups.yahoo.com/group/TestDrivenDevelopment/
              >
              > http://www.testdriven.com
              >
              >
              > Angus Miller
              >
              >
              >
              >
              >[/color]


              Comment

              • Cool Guy

                #8
                Re: Unit Testing

                "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote:

                [...]
                [color=blue][color=green]
                >> Do you embed your test class into the same assembly as the class it tests?
                >> I like this idea because it keeps someone else from breaking your code (at
                >> least making sure it compiles) when they come in to do a "quick" change.[/color]
                >
                > No, we use a different project in the same solution. You don't really
                > want test code bloating the release DLL - especially if you embed test
                > data files. On the other hand, if you don't mind a little bit of extra
                > space and don't mind the possibility of people finding your tests, it's
                > a great way to allow easy testing of internal members too.[/color]

                Still, you can use conditional compilation to exclude test code from
                release builds.

                Comment

                • A Miller

                  #9
                  Re: Unit Testing

                  [color=blue]
                  > I noticed that on the test driven site they reference a book called
                  > "Test-Driven Development in .NET". Do you own this book? If so,
                  > what are your thoughts as to its worth. In other words, do you refer
                  > to it often or almost never.....[/color]


                  That's not a book I know. One I can recommend is 'Working Effectively
                  with Legacy Code' by Michael Feathers - which gives lots of examples of
                  how you can implement TDD with your currently untested code.


                  _1_1/102-3508174-2971300?s=books &v=glance&n=283 155


                  Angus Miller

                  Comment

                  • Jon Skeet [C# MVP]

                    #10
                    Re: Unit Testing

                    D. Yates <foeman@hotmail .com> wrote:[color=blue]
                    > Thanks for your response.
                    >
                    > How do you handle application testing provided that your unit testing
                    > passes? Do you just use human testers or is your testing automated in
                    > anyway?[/color]

                    We have some automated tests and some manual tests. Obviously, some
                    types of UI are easier to test than others - and many integration level
                    tests can be done at the web service level rather than at the visible
                    UI level.

                    --
                    Jon Skeet - <skeet@pobox.co m>
                    http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
                    If replying to the group, please do not mail me too

                    Comment

                    • Jon Skeet [C# MVP]

                      #11
                      Re: Unit Testing

                      Cool Guy <coolguy@abc.xy z> wrote:[color=blue][color=green]
                      > > No, we use a different project in the same solution. You don't really
                      > > want test code bloating the release DLL - especially if you embed test
                      > > data files. On the other hand, if you don't mind a little bit of extra
                      > > space and don't mind the possibility of people finding your tests, it's
                      > > a great way to allow easy testing of internal members too.[/color]
                      >
                      > Still, you can use conditional compilation to exclude test code from
                      > release builds.[/color]

                      Yes, but then you're not testing what you're releasing. There's a
                      definite appeal to running unit tests on the *real* code.

                      --
                      Jon Skeet - <skeet@pobox.co m>
                      http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
                      If replying to the group, please do not mail me too

                      Comment

                      • Jon Skeet [C# MVP]

                        #12
                        Re: Unit Testing

                        A Miller <angus@amlsoftw arexx.co.uk> wrote:[color=blue][color=green]
                        > > I noticed that on the test driven site they reference a book called
                        > > "Test-Driven Development in .NET". Do you own this book? If so,
                        > > what are your thoughts as to its worth. In other words, do you refer
                        > > to it often or almost never.....[/color]
                        >
                        > That's not a book I know. One I can recommend is 'Working Effectively
                        > with Legacy Code' by Michael Feathers - which gives lots of examples of
                        > how you can implement TDD with your currently untested code.
                        >
                        > http://www.amazon.com/gp/product/013.../sr=1-1/ref=sr
                        > _1_1/102-3508174-2971300?s=books &v=glance&n=283 155[/color]

                        While I haven't read that one myself, I believe it's the one my team
                        leader absolutely swears by. It's sort of "testing in the real world,
                        where things get icky."

                        --
                        Jon Skeet - <skeet@pobox.co m>
                        http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
                        If replying to the group, please do not mail me too

                        Comment

                        Working...