Run this notebook

Use Livebook to open this notebook and explore new ideas.

It is easy to get started, on your machine or the cloud.

Click below to open and run it in your Livebook at .

(or change your Livebook location)

# Calculator with TDD ## Livebook Button [![Run in Livebook](https://livebook.dev/badge/v1/blue.svg)](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

Have you already installed Livebook?

If you already installed Livebook, you can configure the default Livebook location where you want to open notebooks.
Livebook up Checking status We can't reach this Livebook (but we saved your preference anyway)
Run notebook

Not yet? Install Livebook in just a minute

Livebook is open source, free, and ready to run anywhere.

Run on your machine

with Livebook Desktop

Run in the cloud

on select platforms

To run on Linux, Docker, embedded devices, or Elixir’s Mix, check our README.

PLATINUM SPONSORS
SPONSORS
Code navigation with go to definition of modules and functions Read More ×