Skip to content

gamezop/testing_elixir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TestingElixir

  • Tests are implemented as Elixir scripts, hence .exs file format
  • ExUnit.start() starts ExUnit than runs the test

Steps:

  • mix test runs the tests

Testing macros

  • assert -> truthy expression
  • refute -> falsy expression

Tests Covered ->

  • Example test
  • Doc test
  • Db test
  • Mock test
  • GenServer test
  • Property test

Utilities ->

  • unit_test -> normal function test
  • doctests -> tests the iex> block in the function documentation Extremely useful as it demonstrates the user how to use the library and tests at the same time.
  • describe -> to group block of tests with independent setup calls

Testing functions that interacts with DB

Configuring DB connections

  • Ecto

  • configure the repo in config/test.exs

  • Direct Db insert testing.

  • Mox - Mocking library

  • Async running test using async: true

  • mix test --cover

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published