# Workflow for Testing Packages

**URL:** https://discourse.julialang.org/t/workflow-for-testing-packages/101305
**Category:** New to Julia
**Created:** [July 7, 2023, 9:58am UTC](https://discourse.julialang.org/t/workflow-for-testing-packages/101305 "2023-07-07T09:58:02Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jeffzwe](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@jeffzwe](https://discourse.julialang.org/u/jeffzwe)
#### Post date: [July 7, 2023, 9:58am UTC](https://discourse.julialang.org/t/workflow-for-testing-packages/101305/1 "2023-07-07T09:58:02Z")

</div>

Hi there,

I’m new to Julia and I’m currently developing a new package. In order to set up a testing suite, I followed the “tutorial” in the [Docs](https://docs.julialang.org/en/v1/stdlib/Test/#Workflow-for-Testing-Packages).

However even with this simple example I’m getting following error for every single test:

```julia
Test threw exception
  Expression: 2 == simple_add(1, 1)
  UndefVarError: simple_add not defined
  Stacktrace:
   [1] macro expansion
     @ /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/Test/src/Test.jl:464 [inlined]
   [2] macro expansion
     @ ~/Desktop/Example/test/math_tests.jl:2 [inlined]
   [3] macro expansion
     @ /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/Test/src/Test.jl:1363 [inlined]
   [4] top-level scope
     @ ~/Desktop/Example/test/math_tests.jl:2

```

From my understanding runtests.jl should be able to find Example.jl by itself and include it.  
But even after including Example.jl manually I get the same error.

Didn’t find anybody having the same problem online so I’m posting it here…

Thanks for the help!

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [July 7, 2023, 10:22am UTC](https://discourse.julialang.org/t/workflow-for-testing-packages/101305/2 "2023-07-07T10:22:06Z")

</div>

I think the example in the docs might be wrong because it doesn’t export the functions it defines. Basically, if you want to use the function `simple_add` outside of the `Example` module, there are three options:

- hope that `Example` contains the statement `export simple_add`
- prefix the function call with `Example.simple_add`
- replace `using Example` with `using Example: simple_add`

Can anyone confirm that the docs is indeed wrong?  
The Example.jl package on GitHub does include exports: [https://github.com/JuliaLang/Example.jl/blob/master/src/Example.jl](https://github.com/JuliaLang/Example.jl/blob/master/src/Example.jl)

---

<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: [July 7, 2023, 12:08pm UTC](https://discourse.julialang.org/t/workflow-for-testing-packages/101305/3 "2023-07-07T12:08:33Z")

</div>

> [@gdalle](#):
>
> Can anyone confirm that the docs is indeed wrong?

There is no `simple_add` function in that package. The functions it exports and test are `hello` and `domath`.

(the example seems ok, I mean)

---

<div class="post-metadata">

### Author: ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)
#### Post date: [July 7, 2023, 12:26pm UTC](https://discourse.julialang.org/t/workflow-for-testing-packages/101305/4 "2023-07-07T12:26:03Z")

</div>

The documentation I see - [Unit Testing · The Julia Language](https://docs.julialang.org/en/v1/stdlib/Test/#Workflow-for-Testing-Packages) - doesn’t include any export statements, therefore the error **jeffzwe** observes.

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [July 7, 2023, 1:13pm UTC](https://discourse.julialang.org/t/workflow-for-testing-packages/101305/5 "2023-07-07T13:13:28Z")

</div>

Indeed, what I meant is that the Examples.jl package on the JuliaLang GitHub repo has an export, but the `Example` module on the test docs page doesn’t, and that second part seems wrong to me (regardless of the fact that they have different contents). I’ll open a PR

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [July 7, 2023, 1:17pm UTC](https://discourse.julialang.org/t/workflow-for-testing-packages/101305/6 "2023-07-07T13:17:55Z")

</div>

In case core devs see this, it’s a 1-line PR: [Add exports to `Example` module for the test workflow in the docs by gdalle · Pull Request #50459 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/50459)

---

<div class="post-metadata">

### Author: ![jeffzwe](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@jeffzwe](https://discourse.julialang.org/u/jeffzwe)
#### Post date: [July 9, 2023, 3:52pm UTC](https://discourse.julialang.org/t/workflow-for-testing-packages/101305/7 "2023-07-09T15:52:24Z")

</div>

Thanks! This did the trick
