exkorpion v0.0.1 Release Notes

Release Date: 2016-08-29 // over 7 years ago
  • Exkorpion

    โœ… Exkorpion is a framework that will help developers to write tests in a BDD form.

    Installation

    ๐Ÿ“ฆ Library is available in Hex, the package can be installed as:

    โž• Add exkorpion to your list of dependencies in mix.exs:

    def deps do [{:exkorpion, "~\> 0.0.1"}]end
    

    Ensure exkorpion is started before your application:

    def application do [applications: [:exkorpion]]end
    

    Getting started with Exkorpion

    โœ… As was mentioned above Exkorpion is a test framework focused on helping developers to work under BDD. Then, as you could guess the syntax
    will look like Given-When-Then.

    Below you can find some very basic examples of how to use Exkorpion

    defmodule ExkorpionDemo.MathOperationsTest douse Exkorpiondef sum(a,b) do a + b enddef subs a, b do a - b end scenario "testing sum operation works as expected" do it "sum positive numbers works as expected" do %{ given: fn -\> %{a: 1, b: 2} end, when: fn ctx -\> %{c: ctx.a + ctx.b} end, then: fn ctx -\> assert ctx.c === 3end } end it "sum negative numbers and it should work as expected" do %{ given: fn-\> %{a: -1, b: -2} end, when: fn ctx -\> %{c: sum(ctx.a, ctx.b)} end, then: fn ctx -\> assert ctx.c === -3end } end it "does multiple operations depending on vairable input" do %{ with: fn -\> [%{param1: 2, param2: 3, result: 5}, %{param1: 3, param2: -2, result: 1}] end, given: fn ctx -\> %{a: ctx.param1, b: ctx.param2} end, when: fn ctx -\> %{c: sum(ctx.a, ctx.b)} end, then: fn ctx -\> assert ctx.c === ctx.result end } endendend
    

    โœ… In order to write new tests with Exkorpion, we need to consider the below:

    ๐Ÿ‘‰ 1. Add use Exkorpion after module declaration.

    1. A scenario will be compounds by one of multiple cases, which are represented by *it โœ… 3. So far, we can write two types of tests:
      • We can write basic tests with the required 3 steps: Given, When and Then and the tests will be performed in this order. An example of this
        type of tests can be found in the above example: it sum positive numbers works as expected and it does multiple operations depending on vairable input
      • We could extend the test by defining different inputs for the same tests. We can achieve by adding with to our map declaration, as we can see in
        it does multiple operations depending on vairable input

    Contributors