https://github.com/tagbase-io/tracee
Trace function calls in concurrent Elixir processes.
https://github.com/tagbase-io/tracee
elixir tracing
Last synced: 3 months ago
JSON representation
Trace function calls in concurrent Elixir processes.
- Host: GitHub
- URL: https://github.com/tagbase-io/tracee
- Owner: tagbase-io
- License: mit
- Created: 2024-04-21T14:46:59.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-02T08:56:51.000Z (over 1 year ago)
- Last Synced: 2025-01-29T20:08:49.933Z (12 months ago)
- Topics: elixir, tracing
- Language: Elixir
- Homepage: https://hexdocs.pm/tracee
- Size: 27.3 KB
- Stars: 11
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tracee
[](https://hex.pm/packages/tracee)

This Elixir library offers functionality to trace and assert expected function
calls within concurrent Elixir processes.
This allows you to ensure that destructive and/or expensive functions are only
called the expected number of times. For more information, see [the Elixir forum
post](https://elixirforum.com/t/tracing-and-asserting-function-calls/63035) that
motivated the development of this library.
## Installation
Just add `tracee` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:tracee, "~> 0.2.0", only: :test}
]
end
```
## Usage
```elixir
defmodule ModuleTest do
use ExUnit.Case
import Tracee
setup :verify_on_exit!
describe "fun/0" do
test "calls expensive function only once" do
expect(AnotherModule, :expensive_fun, 1)
assert Module.fun()
end
test "calls expensive function only once from another process" do
expect(AnotherModule, :expensive_fun, 1)
assert fn -> Module.fun() end
|> Task.async()
|> Task.await()
end
test "never calls expensive function" do
expect(AnotherModule, :expensive_fun, 1, 0)
assert Module.fun()
end
end
end
```
## License
[MIT](./LICENSE)