# Writing files inside a dune test

**URL:** <https://discuss.ocaml.org/t/writing-files-inside-a-dune-test/6038>\
**Category:** Learning\
**Created:** [June 28, 2020, 6:25pm UTC](https://discuss.ocaml.org/t/writing-files-inside-a-dune-test/6038 "2020-06-28T18:25:59Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Levi\_Roth](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/levi_roth/32/2268_2.png) [@Levi\_Roth](https://discuss.ocaml.org/u/Levi_Roth)\
**Post date:** [June 28, 2020, 6:25pm UTC](https://discuss.ocaml.org/t/writing-files-inside-a-dune-test/6038/1 "2020-06-28T18:25:59Z")

</div>

If I want to depend on some files in a dune test, I can put `(inline_tests (deps (source_tree data)))` in my `dune` file and then anything in the `data/` subdirectory gets copied into the build directory, and I can access it within tests using an ordinary relative path.

What if I want to generate some files and add them to `data/` from within my test?

(Naturally I don’t want to do this every time! The goal is to have something like [VCR](https://github.com/vcr/vcr) where I can record an HTTP interaction the first time I run the test and then just read it out of the file subsequently.)

---

_[View the full topic](https://discuss.ocaml.org/t/writing-files-inside-a-dune-test/6038)._
