# Types 'n' Testing

**URL:** <https://forum.elixirforum.com/t/types-n-testing/57577>\
**Category:** Discussions\
**Tags:** testing, types\
**Created:** [August 11, 2023, 7:16pm UTC](https://forum.elixirforum.com/t/types-n-testing/57577 "2023-08-11T19:16:41Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![sodapopcan](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/32/34668_2.png) [@sodapopcan](https://forum.elixirforum.com/u/sodapopcan)\
**Post date:** [August 11, 2023, 11:33pm UTC](https://forum.elixirforum.com/t/types-n-testing/57577/4 "2023-08-11T23:33:14Z")

</div>

> [@stefanchrobot](#):
>
> the most important tests are black-box integration-level tests that exercise the public contract of the app

You write tests how I sometimes dream of writing tests, which is pure end-to-ends 🙂 We’re still very similar in that I don’t write unit tests but I do test my contexts. My only experience with Phoenix has been full stack LiveView apps, and I like to keep a very strict boundary between `MyApp` and `MyAppWeb`. I consider them separate applications with a strict one-way dependency (except for `MyAppWeb` showing up in `MyApp.Applcation`’s supervisor) even though I have yet to add another client served by `MyApp`. TDDing my contexts also helps keep their design honest even though I’ll fully admit that there is a lot of CRUD that end up being largely being the same boilerplate tests, though these are not the types of tests that would be eliminated by types. Also, because there are exceptions to every rule, I do write some unit tests for utility functions usually in the form of a doctest. These often live in a separate namespace from `MyApp` or `MyAppWeb` since they are essentially library functions.

> [@al2o3cr](#):
>
> For instance, a strict “functions must have type guards” practice combined with a strict “no code without a test” strong-TDD practice could produce code like:

You got me there as I’ve actually totally written tests like that before. I’d feel icky about it and it led me to start only writing guards for control flow. My generally strategy in the past couple of years has been to ensure that all data has been cast to a known shape at the outer bounds, so these types of things _shouldn’t_ happen. What I really should be doing on top of that is using property-based testing and I’m a little annoyed with myself that this thread has led to me exposing myself that I still don’t 🫣 Do you think types make property-based tests redundant?

---

_[View the full topic](https://forum.elixirforum.com/t/types-n-testing/57577)._
