"So, You are telling me that...

I have to write a code to check if the code i wrote earlier is right?"

What can I answer to my student? 😅

  • 5
  • 3
    Welcome to unit testing lol
  • 8
    When some smartass starts asking "but who tests the test code?" then answer "only God can Tell"
  • 3
    As a teacher you can take the obvious teacher action, which is:
    1) Answer "Yes"
    2) Answer the why and how

    One of the reasons why I love the show SciShow on Youtube is because they explain the origins and resaons of something, which is crucial if you want to learn something.

    Provide him a full rationale on why you write tests to verify your code. At my uni they used the example of several mission-critical applications (an aeroplane, probe to Mars gone wrong, hospital equipment, etc) and the consequences if you don't test.
  • 4
    The goal is no to test the code you wrote now but to test the changes that you could potentially make after.
  • 2
    First learn TDD the right way:
    1. Write small test.
    2. Write small chunk of code satisfying that test.
    3. Go to 1. until it's finished.

    * You write better designed code unit (you have to use it before you even implement it).
    * You will more likely think about boundary cases. If you test afterwards you will test just only what you implemented.
    * Being ready for refactoring is additional benefit.
  • 3
    @Foobarbaz until your boss rushes you to finish the code without test.

    "We don't pay to write test, just finish the job"
  • 1
    @Clueless the ceo at my previous Job Had a great mentality on that. Basically "When you ask an engineer to create something it's part of the engineers job to make sure that the thing gets tested as he's the expert who should know when to test what and how. Testing is part of the product, it's part of the job. That's true for car manufacturing, aeroplane engineering and should be true for our domain. Just because our errors won't lead to killing people doesn't mean we should ship brittle products. Don't fucking ask me if it's okay to spend time testing. Write tests whenever necessary. Of course there are times when quick fixes and rushed development are necessary but it's management's job to keep those times to a minimum."
Add Comment