Use Livebook to open this notebook and explore new ideas.
It is easy to get started, on your machine or the cloud.
# Calculator with TDD
## Livebook Button
[](https://livebook.dev/run?url=https%3A%2F%2Fgist.github.com%2Fadolfont%2F45cd57d2e9ef020ed164419f970235ad)
## Code
```elixir
defmodule Calculator do
def add(a, b) do
a + b
end
def multiply(a, b) do
a * b
end
end
```
## Tests
```elixir
ExUnit.start(auto_run: false)
defmodule CalculatorTest do
use ExUnit.Case, async: false
describe "Testing the addition function" do
test "2 plus 3 is 5" do
assert Calculator.add(2, 3) == 5
end
test "2 plus 2 is 4" do
assert Calculator.add(2, 2) == 4
end
end
describe "Testing the multiplication function" do
test "2 times 3 is 6" do
assert Calculator.multiply(2, 3) == 6
end
test "2 times 20 is 40" do
assert Calculator.multiply(2, 20) == 40
end
end
end
ExUnit.run()
```
See source