# How to avoid name conflicts in MyPackage/runtests.jl

**URL:** <https://discourse.julialang.org/t/how-to-avoid-name-conflicts-in-mypackage-runtests-jl/57186>\
**Category:** New to Julia\
**Tags:** testing\
**Created:** [March 15, 2021, 10:12am UTC](https://discourse.julialang.org/t/how-to-avoid-name-conflicts-in-mypackage-runtests-jl/57186 "2021-03-15T10:12:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marty0801](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marty0801/32/12715_2.png) [@marty0801](https://discourse.julialang.org/u/marty0801)\
**Post date:** [March 15, 2021, 10:12am UTC](https://discourse.julialang.org/t/how-to-avoid-name-conflicts-in-mypackage-runtests-jl/57186/1 "2021-03-15T10:12:25Z")

</div>

When testing my package I get errors that are not present when I run the failing test script in a new REPL, suggesting that namespace corruption is the problem. My runtests.jl setup is probably to blame; it looks like

```julia
files= ["test1.jl", "test2.jl"] 

for file in files: 
   include(file) 
end 

```

How should I better structure runtests.jl to avoid this issue?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 15, 2021, 12:46pm UTC](https://discourse.julialang.org/t/how-to-avoid-name-conflicts-in-mypackage-runtests-jl/57186/2 "2021-03-15T12:46:37Z")

</div>

> [@marty0801](#):
>
> My runtests.jl setup is probably to blame

I am not sure about this, unless you use `file` and `files` in some scope that is interfering.

In any case, there is

> **[GitHub - YingboMa/SafeTestsets.jl](https://github.com/YingboMa/SafeTestsets.jl)**
>
> Contribute to YingboMa/SafeTestsets.jl development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [March 15, 2021, 1:12pm UTC](https://discourse.julialang.org/t/how-to-avoid-name-conflicts-in-mypackage-runtests-jl/57186/3 "2021-03-15T13:12:19Z")

</div>

I usually wrap everything inside individual files in a module. Usually it have a name of a file plus word Test. You can factor out common pieces and include them into individual files. So, it looks like that

```julia
#test1.jl
module TestTest1
include("testcommon.jl")

#actual tests

end #module

```

It’s more or less the same as `SafeTestsets.jl` just more explicit.

---

<div class="post-metadata">

**Author:** ![marty0801](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marty0801/32/12715_2.png) [@marty0801](https://discourse.julialang.org/u/marty0801)\
**Post date:** [March 16, 2021, 1:03am UTC](https://discourse.julialang.org/t/how-to-avoid-name-conflicts-in-mypackage-runtests-jl/57186/4 "2021-03-16T01:03:51Z")

</div>

That’ll do. Thanks!
