Hacker News new | ask | show | jobs
by huijzer 38 days ago
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.
2 comments

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.