October 2014
Intermediate to advanced
280 pages
7h 20m
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.
| project/0/issues/test/issues_test.exs | |
| | defmodule IssuesTest do |
| | use ExUnit.Case |
| | |
| | test "the truth" do |
| | assert(true) |
| | 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. We’ll test that the option parser successfully detects the -h and --help options, and that it returns the arguments otherwise. We’ll also check that ...
Read now
Unlock full access