# Testing a function with guards

**URL:** <https://forum.elixirforum.com/t/testing-a-function-with-guards/32166>\
**Category:** Questions\
**Tags:** testing, guards, unit-testing\
**Created:** [June 7, 2020, 11:52am UTC](https://forum.elixirforum.com/t/testing-a-function-with-guards/32166 "2020-06-07T11:52:17Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![NobbZ](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/32/27235_2.png) [@NobbZ](https://forum.elixirforum.com/u/NobbZ)\
**Post date:** [June 7, 2020, 11:57am UTC](https://forum.elixirforum.com/t/testing-a-function-with-guards/32166/3 "2020-06-07T11:57:39Z")

</div>

Usually you do not test calling with a string when the contract is “ints only”.

Though if you really want to, you can use [`assert_raise/2,3`](https://hexdocs.pm/ex_unit/ExUnit.Assertions.html#assert_raise/2).

---

_[View the full topic](https://forum.elixirforum.com/t/testing-a-function-with-guards/32166)._
