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. General Programming
  3. C#
  4. Automatic unit tests

Automatic unit tests

Scheduled Pinned Locked Moved C#
csharptestingbeta-testingquestion
8 Posts 4 Posters 9 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.
  • H Offline
    H Offline
    Hila Berger
    wrote on last edited by
    #1

    Which unit testing framework for C# can create unit tests automatically?

    P L B 3 Replies Last reply
    0
    • H Hila Berger

      Which unit testing framework for C# can create unit tests automatically?

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

      What do you mean by creating unit tests automatically? Are you referring to tests like PEX and MOLES or Intellitest?

      This space for rent

      H 1 Reply Last reply
      0
      • H Hila Berger

        Which unit testing framework for C# can create unit tests automatically?

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

        No framework can predict your expected results; so there's no such thing as creating tests automatically.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        H 1 Reply Last reply
        0
        • H Hila Berger

          Which unit testing framework for C# can create unit tests automatically?

          B Offline
          B Offline
          Bohdan Stupak
          wrote on last edited by
          #4

          You could try some Property-Based Testing[^]. Frameworks like FsCheck automaticaly generate random values to verify your properties. But you have to come up with properties that you need to verify yourself. Such approach is more reliable then unit-testing against magic-numbers and is helpful to spot bugs but can only be used in the limited cases Also again I'm not 100% sure whether this is what you're looking for

          1 Reply Last reply
          0
          • P Pete OHanlon

            What do you mean by creating unit tests automatically? Are you referring to tests like PEX and MOLES or Intellitest?

            This space for rent

            H Offline
            H Offline
            Hila Berger
            wrote on last edited by
            #5

            I mean that I have a code that contains some methods... I'm looking for a tool that would go over my code and create unit tests for the methods automatically... Does a tool like that exist in the market?

            P 1 Reply Last reply
            0
            • L Lost User

              No framework can predict your expected results; so there's no such thing as creating tests automatically.

              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

              H Offline
              H Offline
              Hila Berger
              wrote on last edited by
              #6

              Is it possible to test several cases of the method under test?

              L 1 Reply Last reply
              0
              • H Hila Berger

                Is it possible to test several cases of the method under test?

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

                Yes, you can throw random values at it.

                Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                1 Reply Last reply
                0
                • H Hila Berger

                  I mean that I have a code that contains some methods... I'm looking for a tool that would go over my code and create unit tests for the methods automatically... Does a tool like that exist in the market?

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

                  To a certain extent, yes it does (see the links in my original post to PEX and Moles from Microsoft research). The real question is, how much value do these tools provide? For instance, it's simple enough to automatically check whether or not a value is null but what about range checks? Would a tool know that your code expected a value between 0 and 5? Don't fall into the trap of just blindly adding tests, which is the problem with this idea. Your tests should really be there to exercise the expected logic of your code; for instance, if you changed the acceptable range from 0 to 6 and passed 6 into the code expecting the test to follow the fail path, it would suddenly follow a different path through your code so you would know that your test needs to change.

                  This space for rent

                  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