Grains.Support (Grains v1.6.0)

Support functions to simplify testing.

Link to this section Summary

Functions

Publish a message to the "Grain under Test"

Generate boiler plate to blackbox-test a grain.

Link to this section Functions

Link to this function

push_into_test(test_setup, message)

Publish a message to the "Grain under Test"

Example

iex> test_setup = setup_test!(Grains.Support.Cache, [])
iex> test_setup |> push_into_test(1) |> push_into_test(2)
iex> assert_receive 1
1
iex> assert_receive 2
2
Link to this function

setup_test!(module, args)

Generate boiler plate to blackbox-test a grain.

This helper starts a supervised setup to test a "Grain under Test" (GuT):

Publisher ---> GuT ---> Subscriber

By publishing messages through the Publisher, GuT can be blackbox-tested: the Subscriber forwards all messages to the process that called setup_test!/2.

Use push_into_test/2 to publish a message to GuT.

Arguments

  • module: The module of the GuT
  • args: The arguments to initialize a GuT