Creating a SchemaCase for Shared Test Code
Learn how to use our schema as data validation code.
We'll cover the following
Case template
Case templates are handy when identifying a pattern for test files that would benefit from shared code. Our refactors on the basic schema tests created two helper functions, valid_params/1
and invalid_params/1
, that would be good to move into a common place to be reused by all our schema tests.
We’ll create a case template called SchemaCase
and move the helper functions there. Let’s start by creating a new file called testing_ecto/test/schema_case.ex
and add the basic structure for a case template:
Get hands-on with 1400+ tech skills courses.