Hacker News new | ask | show | jobs
by AndrewKemendo 39 days ago
It’s a question of the degree to which you want a self audit to be native to your structure or not

if you are confident that the complexity of what you have built can be fully tracked in your head then either you are some sort of God or you’re not used to building complicated enough things with critical failures attached to them

1 comments

Say we have a trivial function like this

    func below_ten()
      if 10 < x
        println(“true”)
      else
        println(“false”)
      end
    end
Now what would a test for these two paths test? It would basically be writing down the same - easy to understand logic - in a less generalized way. Good perhaps to ensure that this function doesn’t accidentally change over time but apart from that it wouldn’t add much value.
A test would possibly have caught that the condition in this trivial function is backwards.
Lol, yes. This also demonstrates why tests ought to be written by an independent party.
> It would basically be writing down the same - easy to understand logic

Perhaps this is a sign that this function isn't necessary.

Exactly. If the function is already verified to be correct, then the unit and integration tests will determine if the function is appropriate for the context.

Unit tests aren't for verifying functions.