{"result":{"depiction_url":null,"edges":{"hasreference":{"objects":[{"created":"2026-10-07T11:13:50Z","object_id":{"id":2983,"is_a":["text","documentation","developerguide"],"name":"developer_testing_strategy","title":{"_type":"trans","tr":{"en":"Choose checks for a change"}},"uri":"https:\/\/zotonic.com\/id\/2983"},"seq":1},{"created":"2026-10-07T11:13:50Z","object_id":{"id":2984,"is_a":["text","documentation","developerguide"],"name":"developer_testing_erlang","title":{"_type":"trans","tr":{"en":"Test Erlang behavior with focused examples"}},"uri":"https:\/\/zotonic.com\/id\/2984"},"seq":2},{"created":"2026-10-07T11:13:50Z","object_id":{"id":2985,"is_a":["text","documentation","developerguide"],"name":"developer_testing_templates","title":{"_type":"trans","tr":{"en":"Check a rendered template"}},"uri":"https:\/\/zotonic.com\/id\/2985"},"seq":3},{"created":"2026-10-07T11:13:50Z","object_id":{"id":2937,"is_a":["text","documentation","developerguide"],"name":"developer_cli_tests","title":{"_type":"trans","tr":{"en":"Run tests and site checks"}},"uri":"https:\/\/zotonic.com\/id\/2937"},"seq":4}],"predicate":{"id":2774,"is_a":["meta","predicate"],"name":"hasreference","title":{"_type":"trans","tr":{"en":"Documentation reference"}},"uri":"https:\/\/zotonic.com\/id\/hasreference"}},"references":{"objects":[{"created":"2020-05-30T05:47:25Z","object_id":{"id":1353,"is_a":["text","documentation","developerguide"],"name":"doc_developerguide_modules","title":{"_type":"trans","tr":{"en":"Create a reusable module"}},"uri":"https:\/\/zotonic.com\/id\/1353"},"seq":1000000},{"created":"2020-05-30T05:47:25Z","object_id":{"id":1547,"is_a":["text","documentation","reference"],"name":"doc_reference_cli_index","title":{"_type":"trans","tr":{"en":"Command-line reference"}},"uri":"https:\/\/zotonic.com\/id\/1547"},"seq":1000000}],"predicate":{"id":332,"is_a":["meta","predicate"],"name":"references","title":{"_type":"trans","tr":{"en":"References"}},"uri":"https:\/\/zotonic.com\/id\/references"}},"subject":{"objects":[{"created":"2026-10-07T11:13:50Z","object_id":{"id":2556,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_explanation","title":"Explanation","uri":"https:\/\/zotonic.com\/id\/2556"},"seq":1},{"created":"2026-10-07T11:13:50Z","object_id":{"id":2564,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_backend_developer","title":"Backend developer","uri":"https:\/\/zotonic.com\/id\/2564"},"seq":2},{"created":"2026-10-07T11:13:50Z","object_id":{"id":2640,"is_a":["categorization","keyword","keyword_task"],"name":"zotonic_topic_validate","title":"Validate","uri":"https:\/\/zotonic.com\/id\/2640"},"seq":3},{"created":"2026-10-07T11:13:50Z","object_id":{"id":2613,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_development_and_debugging","title":"Development and debugging","uri":"https:\/\/zotonic.com\/id\/2613"},"seq":4}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":1546,"is_a":["text","documentation","developerguide"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1546"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_developerguide_testing","page_url":{"en":"https:\/\/zotonic.com\/docs\/1546\/choose-checks-for-a-change","x-default":"https:\/\/zotonic.com\/docs\/1546\/choose-checks-for-a-change"},"preview_url":null,"resource":{"body":{"_type":"trans","tr":{"en":"<p>Start with the behavior that could break. A pure helper needs focused input and result checks. A resource write also needs permission and persistence checks. A template change needs a rendered page with representative content.<\/p>\n<p>Compile changed Erlang code before running tests. Run the smallest relevant test first, then checks for affected integrations. Use a disposable database for tests that write data.<\/p>\n<p>Record what was checked and what was not. A successful compile does not verify a browser interaction, and a successful admin request does not verify anonymous access.<\/p>\n<h2>Test Erlang behavior with focused examples<\/h2>\n<p>Keep domain logic in small functions that accept explicit inputs. Test expected results, boundary values, and meaningful error cases without starting a full site when the function does not need one.<\/p>\n<p>For code that uses Zotonic models, use the repository&#39;s existing test setup and a dedicated site context. Clean up created resources so later tests do not depend on execution order.<\/p>\n<p>Select a known test module with the supported test runner. Check that the runner actually discovers it: this workspace&#39;s <code>runtests<\/code> command scans the core <code>apps\/zotonic_*\/test<\/code> directories, not every user application&#39;s test directory.<\/p>\n<p>For the pure filter example, create <code>test\/filter_garden_label_tests.erl<\/code> in the Garden application:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">-module(filter_garden_label_tests).\n-include_lib(&quot;eunit\/include\/eunit.hrl&quot;).\n\nlabel_test() -&gt;\n    ?assertEqual(&lt;&lt;&quot;Open to visitors&quot;&gt;&gt;,\n        filter_garden_label:garden_label(&lt;&lt;&quot;open&quot;&gt;&gt;, undefined)),\n    ?assertEqual(&lt;&lt;&quot;Check visiting times&quot;&gt;&gt;,\n        filter_garden_label:garden_label(undefined, undefined)).\n<\/code><\/pre>\n<p>After building the application, compile this test into a temporary directory and run it with the application&#39;s <code>ebin<\/code> on the path:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-sh\">mkdir -p \/tmp\/garden-eunit\nerlc -o \/tmp\/garden-eunit apps_user\/zotonic_mod_garden\/test\/filter_garden_label_tests.erl\nerl -noshell -pa _build\/default\/lib\/zotonic_mod_garden\/ebin \/tmp\/garden-eunit -eval &#39;case eunit:test(filter_garden_label_tests, [verbose]) of ok -&gt; halt(0); _ -&gt; halt(1) end.&#39;\n<\/code><\/pre>\n<p>Expect one passing EUnit test. These commands run a pure helper test without a site; use the site&#39;s integration test setup for database or permission behaviour.<\/p>\n<h2>Check a rendered template<\/h2>\n<p>Render the changed page with realistic content. Include missing optional fields, a long title, several list items, and a second language when applicable.<\/p>\n<p>Check links, image descriptions, heading order, and keyboard access. For category-specific markup, test a resource in the exact category and one that uses the fallback template.<\/p>\n<p>Run the template cross-reference check for missing dependencies. Then check the browser console and network responses for scripts or styles that did not load. Save a screenshot when the visual result matters to review.<\/p>\n<h2>Run tests and site checks<\/h2>\n<p>Use the project&#39;s test workflow in a dedicated development or test environment. Two CLI entry points have different scopes:<\/p>\n<ul><li><code>runtests<\/code> starts the configured test runner and accepts test selections.<\/li><li><code>sitetest garden<\/code> stops the site, drops and uses the <code>z_sitetest<\/code> database schema, runs site tests, then restarts with normal configuration. Use a disposable test environment and avoid concurrent runs sharing the database.<\/li><\/ul>\n<p>Read the relevant reference page before choosing arguments. Tests may create or change data; a passing startup check is not a complete test of models, permissions, and browser behavior.<\/p>\n<p>Run a focused test for the change, then the repository&#39;s required broader checks. Preserve the first meaningful error and reproduce it with a minimal case rather than repeatedly restarting the whole node.<\/p>"}},"category_id":{"id":317,"is_a":["meta","category"],"name":"developerguide","title":"Developer guide","uri":"https:\/\/zotonic.com\/id\/developerguide"},"content_group_id":{"id":339,"is_a":["meta","content_group"],"name":"default_content_group","title":{"_type":"trans","tr":{"en":"Default Content Group"}},"uri":"https:\/\/zotonic.com\/id\/default_content_group"},"created":"2020-05-30T05:47:25Z","creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"doc_editorial_bundle":true,"doc_editorial_edges":{"hasreference":[2937,2983,2984,2985],"subject":[2556,2564,2613,2640]},"github_url":"https:\/\/github.com\/zotonic\/zotonic\/tree\/master\/doc\/developer-guide\/testing.rst","is_authoritative":true,"is_dependent":false,"is_featured":false,"is_protected":false,"is_published":true,"is_unfindable":false,"language":["en"],"modified":"2026-10-07T11:14:03Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"name":"doc_developerguide_testing","pivot_geocode":null,"pivot_location_lat":null,"pivot_location_lng":null,"privacy":0,"publication_end":"9999-06-01T00:00:00Z","publication_start":"2022-02-15T10:01:31Z","slug":"choose-checks-for-a-change","summary":{"_type":"trans","tr":{"en":"Choose checks for a change."}},"title":{"_type":"trans","tr":{"en":"Choose checks for a change"}},"title_slug":{"_type":"trans","tr":{"en":"choose-checks-for-a-change"}},"tz":"UTC","uri":null,"version":36,"visible_for":0},"uri":"https:\/\/zotonic.com\/id\/1546","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1546"}},"status":"ok"}