If you’re familiar with writing tests in most mainstream languages, you know it can take a while to learn the different assertion functions of testing frameworks. For example, let’s see how a few basic assertions for popular test frameworks in Ruby and JavaScript compare to Elixir. You don’t need to be familiar with these languages; just be mindful of the different assertion APIs.
JavaScript:
| expect(value).toBe(true); |
| expect(value).toEqual(12); |
| expect(value).toBeGreaterThan(100); |
Ruby:
| assert value |
| assert_equal value, 12 |
| assert_operator value, :<=, 100 |
Elixir:
| assert value |
| assert value == 12 |
| assert value <= 100 |
Notice how such simple assertions took on arbitrary method and function names in Ruby and JavaScript? ...
No credit card required