I took all of your feedback into account; except the use of a random because having non predictable tests fears me ![]()
This is how I would write it now:
defmodule Kata.FizzBuzz.Test do
use ExUnit.Case
import Kata.FizzBuzz
test "non multiples of 3 and 5 returns the number as a string" do
for n <- 1..100, rem(n, 3) != 0, rem(n, 5) != 0 do
assert fizz_buzz(n) == Integer.to_string(n)
end
end
test "multiples of 3 but not of 5 returns Fizz" do
for n <- 1..100, rem(n, 3) == 0, rem(n, 5) != 0 do
assert fizz_buzz(n) == "Fizz"
end
end
test "multiples of 5 but not of 3 returns Fizz" do
for n <- 1..100, rem(n, 3) != 0, rem(n, 5) == 0 do
assert fizz_buzz(n) == "Buzz"
end
end
test "multiples of 3 and 5 returns Fizz" do
for n <- 1..100, rem(n, 3 * 5) == 0 do
assert fizz_buzz(n) == "FizzBuzz"
end
end
end
Seems nice to me! ![]()
However, this testing strategy seems to be a bit CPU intensive for a trivial test? Maybe that’s why you suggest the use of a random? ![]()


















