{"id":22951800,"url":"https://github.com/domaindrivenarchitecture/data-test","last_synced_at":"2025-08-13T00:32:47.922Z","repository":{"id":65350757,"uuid":"186754259","full_name":"DomainDrivenArchitecture/data-test","owner":"DomainDrivenArchitecture","description":"framework for data-driven tests","archived":false,"fork":false,"pushed_at":"2023-08-02T12:14:20.000Z","size":70,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-28T11:49:03.064Z","etag":null,"topics":["clojure","data","test","test-driven-development"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DomainDrivenArchitecture.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-15T05:22:10.000Z","updated_at":"2023-09-10T16:13:43.000Z","dependencies_parsed_at":"2023-01-30T18:30:26.537Z","dependency_job_id":null,"html_url":"https://github.com/DomainDrivenArchitecture/data-test","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DomainDrivenArchitecture%2Fdata-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DomainDrivenArchitecture%2Fdata-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DomainDrivenArchitecture%2Fdata-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DomainDrivenArchitecture%2Fdata-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DomainDrivenArchitecture","download_url":"https://codeload.github.com/DomainDrivenArchitecture/data-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229718374,"owners_count":18113516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","data","test","test-driven-development"],"created_at":"2024-12-14T15:18:34.880Z","updated_at":"2024-12-14T15:18:35.408Z","avatar_url":"https://github.com/DomainDrivenArchitecture.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# data-test\n\n[![Clojars Project](https://img.shields.io/clojars/v/dda/data-test.svg)](https://clojars.org/dda/data-test)\n[![Build Status](https://travis-ci.org/DomainDrivenArchitecture/data-test.svg?branch=master)](https://travis-ci.org/DomainDrivenArchitecture/data-test)\n\n[![Slack](https://img.shields.io/badge/chat-clojurians-green.svg?style=flat)](https://clojurians.slack.com/messages/#dda-pallet/) | [\u003cimg src=\"https://meissa-gmbh.de/img/community/Mastodon_Logotype.svg\" width=20 alt=\"team@social.meissa-gmbh.de\"\u003e team@social.meissa-gmbh.de](https://social.meissa-gmbh.de/@team) | [Website \u0026 Blog](https://domaindrivenarchitecture.org)\n\n## About\n\ndata-test separates test data from test code and allows a more data driven approach for testing. In case of having huge amounts of test-input \u0026 -expectations your test code will remain readable and concise. data-test is founded on and compatible with `clojure.test`. Integration in your test environments will work without any changes. For explicit, intentful and obvious data, data-test uses [aero](https://github.com/juxt/aero).\n\n## Usage\n\nImport data-test to your project\n\n```clojure\n[dda/data-test \"0.1.1\"]\n```\n\nDefine your data test similar to `deftest` and express your test e.g. with `is` macro. The given binding `[input expected]` will let symbols which can be used in your test code.\n\n```clojure\n(ns my.cool.project-test\n  (:require [clojure.test :refer :all]\n            [data-test :refer :all]))\n\n(defdatatest should-test-multiple-specs [input expected]\n  (is (= input expected)))\n```\n\nYour test data are loaded as resource and therefore data has to be located in classpath. The path is determined by your tests namespace and your tests definition name. In given case it is `my/cool/project_test/should_test_multiple_spec.edn`:\n\n```clojure\n{:input 1\n :expected 1}\n```\n\nThe keys `:input` and `:expected` are fixed, the values can be anything you need. You can have up to 11 data specifications for each test. `my/cool/project_test/should_test_multiple_spec.[1-9].edn` is a valid resource-location also.\n\nTest can be executed by using `(clojure.test/run-tests)` and will produce the usual test-output like:\n\n```console\nRunning namespace tests…\nFAIL in: project_test.clj: 35: should-test-multiple-specs: project_test/should_test_multiple_specs.1.edn:\n  expected: 1\n\n  actual: (2)\n\n\n4 tests finished, problems found. 😭 errors: 0, failures: 1, ns: 1, vars: 3\n```\n\nThe test data resource used will determine the testing context.\n\nAs we are eating our own dog-food, we refactored our test and are using data-test. An example for refactoring you can find in our [dda-serverspec](https://github.com/DomainDrivenArchitecture/dda-serverspec-crate/commit/43abadbdb96afde6b1dc85834e465ee61eb464d2).\n\n## Reference\n\n### Loading Resources\n\ndata-test tries to locate data files on classpath as resource - should work similar in jar-files and in filesystem classpaths. The resource locations are determined by test namespace (e.g. `my/cool/project_test`) and defined test name (e.g. `should_test_multiple_spec.edn`). Resource-naming is following clojures usual filesystem mapping conventions.\n\n\n```console\nmy/cool/project_test/should_test_multiple_spec.edn\nmy/cool/project_test/should_test_multiple_spec.1.edn\n...\nmy/cool/project_test/should_test_multiple_spec.9.edn\n```\n\nA test is executed for every file defined.\n\n### Bindings\n\n`defdatatest name [binding-for-input binding-for-expected]` is translated in sth. like:\n\n```clojure\n(deftest should-test-with-data-explicit-version\n  (let [testdata (loader/read-test-data-spec (io/resource \"data_test_test/should_test_with_data_explicit_version.edn\"))\n        {:keys [input expected]} testdata]\n    (is (= expected\n           input))))\n```\n\nAs you can see, input and expected can be used in your test code. You have to declare the used symbols in the binding section.\n\n### Resources with AERO\n\nYou can use [aero](https://github.com/juxt/aero) in your test data declaration, e.g.\n\n```clojure\n{:references {:to-be-refernced \"ref-test\"}\n :input #ref [:references :to-be-refernced]\n :expected #ref [:references :to-be-refernced]}\n```\n\n### Adding Meta\nYou can add some metadata to your data files, e.g.\n\n```clojure\n{:input some-data\n :expected some-data\n :meta {:name \"name of data\"\n        :description \"describe what testcase is represented by this piec of data\"\n        :link \"https://add-some-link-here\"}}\n```\n\n### Generated Output\n\nEach data-test execution will report it's results to \"target/datatest/\". The key `:test-event` reflect [clojure.test reporting events](https://github.com/clojure/clojure/blob/8c402a8c9695a4eddc07cbbe0d95d44e1372f0bf/src/clj/clojure/test.clj#L214), the key `:test-data-spec` reflects the used data-test data specification.\n\n```clojure\n(def TestDataReport\n  {:test-event s/Any\n   :test-data-spec {:input s/Any\n                    :expected s/Any\n                    :data-spec-file s/Str}})\n```\n\n## Development \u0026 mirrors\nDevelopment happens at: https://repo.prod.meissa.de/meissa/data-test\n\nMirrors are:\n* https://gitlab.com/domaindrivenarchitecture/data-test (CI issues and PR)\n* https://github.com/DomainDrivenArchitecture/data-test\n\n## License\n\nCopyright © 2022 meissa GmbH\nLicensed under the [Apache License, Version 2.0](LICENSE) (the \"License\")\nPls. find licenses of our subcomponents [here](doc/SUBCOMPONENT_LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdomaindrivenarchitecture%2Fdata-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdomaindrivenarchitecture%2Fdata-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdomaindrivenarchitecture%2Fdata-test/lists"}