Supertester.TestableGenServer (Supertester v0.5.1)
View SourceA behavior that makes GenServers testable with Supertester.
This module injects a __supertester_sync__ handler that allows tests to
synchronize with the GenServer without using Process.sleep/1.
Usage
defmodule MyServer do
use GenServer
use Supertester.TestableGenServer
# Your GenServer implementation
endSynchronization
The injected handler responds to two message formats:
:__supertester_sync__- Returns:okafter processing{:__supertester_sync__, return_state: true}- Returns{:ok, state}
Example
{:ok, server} = MyServer.start_link()
GenServer.cast(server, :some_operation)
# Ensure cast is processed before continuing
GenServer.call(server, :__supertester_sync__)
# Now safe to verify results
state = :sys.get_state(server)