# Automated Unit and integration test frameworks

**URL:** <https://discuss.ocaml.org/t/automated-unit-and-integration-test-frameworks/4891>\
**Category:** Learning\
**Created:** [December 19, 2019, 11:44am UTC](https://discuss.ocaml.org/t/automated-unit-and-integration-test-frameworks/4891 "2019-12-19T11:44:18Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![shonfeder](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/shonfeder/32/424_2.png) [@shonfeder](https://discuss.ocaml.org/u/shonfeder)\
**Post date:** [December 26, 2019, 1:15am UTC](https://discuss.ocaml.org/t/automated-unit-and-integration-test-frameworks/4891/3 "2019-12-26T01:15:33Z")

</div>

`dune` does the builds (so takes care of build dependencies) but `opam` does the packaging. `opam` in conjunction with `tuareg` does indeed ensure that the editor knows about new deps, but it’s true you need to go through opam to install them. I usually have a terminal open with `dune build -w` running, so it will rebuild on any changes, and ensure dependencies are kept up to date (e.g., if I add a new module or component somewhere in the project).

For testing, I am fond of [qcheck](https://github.com/c-cube/qcheck) for property based testing and [alcotest](https://github.com/mirage/alcotest) for the test runner and unit tests. But OUnit is widely used, so I’m sure this is a good choice 🙂

re: test automation, I have used circleCI for automating CI without much fuss. You can see my approach [here](https://github.com/shonfeder/alg_structs/blob/master/.circleci/config.yml). You may also be interested in the new GitHub actions announced in [GitHub Actions for OCaml / opam now available](https://discuss.ocaml.org/t/github-actions-for-ocaml-opam-now-available/4745)

I think better opam/dune integration (or a wrapper tool to manage their interaction) will be coming before long, and it will make it much easier to manage dependencies. In the meantime, I have taken to including a `Makefile` with a rule like this:

```auto
.PHONY: deps
deps: $(opam_file)

# Update the package dependencies when new deps are added to dune-project
$(opam_file): dune-project
	-dune build @install # Update the $(opam_file)
	-git add $(opam_file) # opam uses the state of master for it updates
	-git commit $(opam_file) -m "Updating package dependencies"
	opam install . --deps-only # Install the new dependencies

```

Then `make deps` will update the opam package file and install new deps as needed. This depends on [dune generation of opam files](https://dune.readthedocs.io/en/stable/opam.html#generating-opam-files).

---

_[View the full topic](https://discuss.ocaml.org/t/automated-unit-and-integration-test-frameworks/4891)._
