Skip to content

Instantly share code, notes, and snippets.

View josegalaviz's full-sized avatar

José Galaviz josegalaviz

  • Perro Azul
  • Seattle, WA
View GitHub Profile
@josegalaviz
josegalaviz / void-unit-tests.md
Created September 21, 2021 17:03
About void unit tests

When a function that accepts input and returns a value of a certain type is tested it is straightforward: we pass values as parameters to the function and we verify that the output of that function equals to the expected value. An obvious example is when we’re testing a function that sums two numbers. Let's use the prototype addIntegers(A → Integer, B → Integer) → Integer. We can test with the input values 2 and 3 and we can expect that the outcome is 5.

When the function you’re testing does not emit an output, you can’t test the result of it. Instead, you verify that an effect occurred, but you also have to make sure that the effect occurred because you wanted it to occur. For example, testing the function honkIfYouSupportCanada() → Void is a hard problem to solve. You could run the function and track the sound emitting subsystem to verify if a honk occurred. If you run the function and honking doesn’t happen, was it because the function failed or was it because the computer does not like Canada and the

Keybase proof

I hereby claim:

  • I am josegalaviz on github.
  • I am josegalaviz (https://keybase.io/josegalaviz) on keybase.
  • I have a public key whose fingerprint is 8338 5028 FAFA 0D8C F0CF 4370 F44C 4924 C0BE 350A

To claim this, I am signing this object: