# Run doctests?

**URL:** https://discourse.julialang.org/t/run-doctests/8035
**Category:** General Usage
**Created:** [December 28, 2017, 9:10am UTC](https://discourse.julialang.org/t/run-doctests/8035 "2017-12-28T09:10:13Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tbenst](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbenst/32/3029_2.png) [@tbenst](https://discourse.julialang.org/u/tbenst)
#### Post date: [December 28, 2017, 9:10am UTC](https://discourse.julialang.org/t/run-doctests/8035/1 "2017-12-28T09:10:13Z")

</div>

I’m guessing I’m missing something trivially obvious but haven’t found it–how can I run all doctests found in my code?

The Julia documentation references `make -C doc doctest`, but PkgDev.generate() does not create a makefile. The makefile for the Julia manual seems to run `julia --color=yes docs/make.jl -- doctest`, but as I understand [Documenter](https://juliadocs.github.io/Documenter.jl/latest/man/doctests/), this requires manually adding each function to `docs/src/index.md`.

Is there a Julia equivalent to `python setup.py test` that runs all tests + doctests?

Many thanks!

---

<div class="post-metadata">

### Author: ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)
#### Post date: [January 3, 2018, 8:30pm UTC](https://discourse.julialang.org/t/run-doctests/8035/2 "2018-01-03T20:30:56Z")

</div>

I don’t know if there is a way to run a doctest without adding it to the docs. However you certainly don’t need to add each function manually, you can add everything automatically, see [here](https://juliadocs.github.io/Documenter.jl/latest/man/syntax/#@autodocs-block-1).

---

<div class="post-metadata">

### Author: ![tbenst](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbenst/32/3029_2.png) [@tbenst](https://discourse.julialang.org/u/tbenst)
#### Post date: [January 5, 2018, 9:22am UTC](https://discourse.julialang.org/t/run-doctests/8035/3 "2018-01-05T09:22:52Z")

</div>

This is a great tip, thank you! I’ve also made a feature request on the Juno github to add such a feature, here’s the link for anyone that’s interested: [https://github.com/JunoLab/atom-julia-client/issues/401](https://github.com/JunoLab/atom-julia-client/issues/401)

---

<div class="post-metadata">

### Author: ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)
#### Post date: [February 24, 2022, 6:08pm UTC](https://discourse.julialang.org/t/run-doctests/8035/4 "2022-02-24T18:08:36Z")

</div>

> [@tbenst](#):
>
> how can I run all doctests found in my code?

Is there still no answer to that question, short of building the docs?

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [February 24, 2022, 6:33pm UTC](https://discourse.julialang.org/t/run-doctests/8035/5 "2022-02-24T18:33:23Z")

</div>

There is [`doctest(::Module)`](https://juliadocs.github.io/Documenter.jl/stable/lib/public/#Documenter.doctest).

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [January 23, 2024, 6:30pm UTC](https://discourse.julialang.org/t/run-doctests/8035/6 "2024-01-23T18:30:07Z")

</div>

Package doctests can be run as a standard test like this, correct?

```julia
@testitem "Doctest" begin
    doctest(MyPackage)
end

```

Such that the doc tests are run when the package is tested?

Also, would this make the `codecov` consider the doc tests in the computation of coverage? (it seems that it does not).
