はじめにExUnit.startで:ex_unitを起動します。通常のMixプロジェクトでは、プロジェクト作成時に生成されるtest/test_helper.exsでこれが行われるので、自分で書くことは少ないでしょう。 次にテストモジュールを定義します。モジュール名は重複しなければ何でもOKですが、ファイル名は_test.exsで終わる必要があるので、これに合わせて、<プロジェクト名>.<テストしたいモジュール名>Testとするのが一般的です。 テストモジュールは、まずuse ExUnit.Caseから始めます。この中で、いくつかのモジュール属性の設定やテストに使う関数のimportなどをしています。async: trueオプションは、他のテストモジュールと並行に走らせるかを指定しています。Mockを使う場合など、特定のケース以外はtrueでよいと思います。デフォルトはfalseです。 テ
Lightweight Dependency Injection In Elixir (Without the Tears) Andrew Hao · March 19th, 2018 In our last Elixir blog post, “Functional Mocks with Mox in Elixir”, we discussed how testing across module boundaries could be made easier by creating a Behaviour for a collaborating module, then utilizing the wonderful framework Mox to substitute a lightweight mock module in tests. This approach is well
Functional Mocks with Mox in Elixir Andrew Hao · January 16th, 2018 If you’re like me, you came over to Elixir from Ruby and quickly found that certain development assumptions so common to Ruby (and object-oriented programming) require some adjustment in this new functional language. Recently, I was writing an Elixir-based Alexa skill that needed to reach out to an external service, the Alexa Devi
のような関数がある場合このadd関数の引数を2つとってそれぞれを足してその結果を返すという性質(特性)をPropertyと呼びます Propertyとは 以上のことからPropertyとは一言で言えばプログラムの特性と言えます なのでProperty-Based Testingは特性に基づいてテストすることといえます Example-Based Testingがプログラマが期待する入力値と出力値を元にテストすることと比較して、プログラムの特性に基づいてテストするというところが違います この特性をテストするためにProperty-Based Testingでは大量のサンプルデータを自動的に生成してテストをします Example-Based Testingがたった一つの正しい答えに基づいてプログラムの正当性を保障するのに対して、Property-Based Testingは一度の正しさを保障す
In this chapter, we will implement the code that parses the commands we described in the first chapter: CREATE shopping OK PUT shopping milk 1 OK PUT shopping eggs 3 OK GET shopping milk 1 OK DELETE shopping eggs OKAfter the parsing is done, we will update our server to dispatch the parsed commands to the :kv application we built previously. Doctests On the language homepage, we mention that Elixi
Hi there! This is Property-Based Testing with PropEr, Erlang, and Elixir, a book on Property-Based Testing. It's pretty much the friendliest intro to property testing you'll find. The book teaches you how to automatically generate test cases, test stateful programs, and change how you design your software for more principled and reliable approaches. You will be able to better explore the problem s
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く