# How to put '"alcotest" {with-test}' in an opam file generated from a dune-project file?

**URL:** <https://discuss.ocaml.org/t/how-to-put-alcotest-with-test-in-an-opam-file-generated-from-a-dune-project-file/12982>\
**Category:** Ecosystem\
**Tags:** opam, dune\
**Created:** [September 7, 2023, 8:13pm UTC](https://discuss.ocaml.org/t/how-to-put-alcotest-with-test-in-an-opam-file-generated-from-a-dune-project-file/12982 "2023-09-07T20:13:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjambon](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mjambon/32/6180_2.png) [@mjambon](https://discuss.ocaml.org/u/mjambon)\
**Post date:** [September 7, 2023, 8:13pm UTC](https://discuss.ocaml.org/t/how-to-put-alcotest-with-test-in-an-opam-file-generated-from-a-dune-project-file/12982/1 "2023-09-07T20:13:37Z")

</div>

Handcrafted opam files may contain this:

```auto
depends: [
  "alcotest" {with-test}
  ...
]

```

It tells opam that the package in question (`alcotest`) is only a dependency if we want to run the tests (`opam install --with-test ...`). How can we specify the same when using a `dune-project` file as the source for the opam file?

```auto
$ cat dune-project
...
(generate_opam_files true)
...
(package
 ...
 (depends
   alcotest ; <-- how to specify '{with-test}'?
   ...
 )
)

```

---

<div class="post-metadata">

**Author:** ![mjambon](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mjambon/32/6180_2.png) [@mjambon](https://discuss.ocaml.org/u/mjambon)\
**Post date:** [September 7, 2023, 8:20pm UTC](https://discuss.ocaml.org/t/how-to-put-alcotest-with-test-in-an-opam-file-generated-from-a-dune-project-file/12982/2 "2023-09-07T20:20:24Z")

</div>

Solution:

```auto
$ cat dune-project
...
(generate_opam_files true)
...
(package
 ...
 (depends
   (alcotest :with-test)
   ...
 )
)

```
