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. Other Discussions
  3. The Weird and The Wonderful
  4. Bad, very bad, test unit test....

Bad, very bad, test unit test....

Scheduled Pinned Locked Moved The Weird and The Wonderful
testingbeta-testing
5 Posts 4 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.
  • R Offline
    R Offline
    richiej
    wrote on last edited by
    #1

    We've outsourced some of our dev work, everytime they do something we have to check it because they keep on making mistakes..... ...when testing a change one of the developers made I noticed that the expected change didn't happen. He said to me it should work, and he's created a unit test to test the change works... ...I then looked at his unit test: if (order.Allocations[0].TriPartyEligibilityCriteria != null) { Assert.IsTrue(order.Allocations[0].TriPartyEligibilityCriteria.Length > 0); } I had to walk him through this to explain to him just why his test was bad, very bad indeed and it took me over an hour to explain why that was bad and what he should have done instead! The amount of time we spend inspecting their code and refactoring makes this whole outsourcing exercise a joke

    R A 2 Replies Last reply
    0
    • R richiej

      We've outsourced some of our dev work, everytime they do something we have to check it because they keep on making mistakes..... ...when testing a change one of the developers made I noticed that the expected change didn't happen. He said to me it should work, and he's created a unit test to test the change works... ...I then looked at his unit test: if (order.Allocations[0].TriPartyEligibilityCriteria != null) { Assert.IsTrue(order.Allocations[0].TriPartyEligibilityCriteria.Length > 0); } I had to walk him through this to explain to him just why his test was bad, very bad indeed and it took me over an hour to explain why that was bad and what he should have done instead! The amount of time we spend inspecting their code and refactoring makes this whole outsourcing exercise a joke

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      Suffering in a similar fashion though the code, itself, works most of the time. They are just so untidy.

      "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

      1 Reply Last reply
      0
      • R richiej

        We've outsourced some of our dev work, everytime they do something we have to check it because they keep on making mistakes..... ...when testing a change one of the developers made I noticed that the expected change didn't happen. He said to me it should work, and he's created a unit test to test the change works... ...I then looked at his unit test: if (order.Allocations[0].TriPartyEligibilityCriteria != null) { Assert.IsTrue(order.Allocations[0].TriPartyEligibilityCriteria.Length > 0); } I had to walk him through this to explain to him just why his test was bad, very bad indeed and it took me over an hour to explain why that was bad and what he should have done instead! The amount of time we spend inspecting their code and refactoring makes this whole outsourcing exercise a joke

        A Offline
        A Offline
        Al_Brown
        wrote on last edited by
        #3

        Perhaps I'm missing the obvious, but why couldn't that be a valid part of a unit test?

        S 1 Reply Last reply
        0
        • A Al_Brown

          Perhaps I'm missing the obvious, but why couldn't that be a valid part of a unit test?

          S Offline
          S Offline
          Samuel Cragg
          wrote on last edited by
          #4

          You could certainly assert the length as part of the test, but the check for null is wrong - you should know if the value will be null or not and do an assertion on that (it may be valid for it to be null, for example if some other property is invalid, but this should be part of the spec).

          A 1 Reply Last reply
          0
          • S Samuel Cragg

            You could certainly assert the length as part of the test, but the check for null is wrong - you should know if the value will be null or not and do an assertion on that (it may be valid for it to be null, for example if some other property is invalid, but this should be part of the spec).

            A Offline
            A Offline
            Al_Brown
            wrote on last edited by
            #5

            I agree it should be part of the spec. There's nothing to indicate in the message or sample that it's incorrect for it to be optional element which can be null. (Only that if it isn't null then it should have a length greater than zero).

            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