May 2018
Intermediate to advanced
412 pages
9h 3m
English
At this point, I get a little nervous if I don’t have some tests. Fortunately, Elixir comes with a wonderful (and simple) testing framework called ExUnit.
Have a look at the file test/issues_test.exs.
| | defmodule IssuesTest do |
| | use ExUnit.Case |
| | doctest Issues |
| | |
| | test "greets the world" do |
| | assert Issues.hello() == :world |
| | end |
| | end |
It acts as a template for all the test files you write. I just copy and paste the boilerplate into separate test files as I need them. So let’s write tests for our CLI module, putting those tests into the file test/cli_test.exs. (Test file names must end with _test.) We’ll test that the option parser successfully detects the -h and ...
Read now
Unlock full access