# Optional testing files in pacakge?

**URL:** <https://discourse.julialang.org/t/optional-testing-files-in-pacakge/94657>\
**Category:** New to Julia\
**Tags:** question, package, testing, artifacts\
**Created:** [February 15, 2023, 12:49am UTC](https://discourse.julialang.org/t/optional-testing-files-in-pacakge/94657 "2023-02-15T00:49:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lntricate](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lntricate/32/46878_2.png) [@lntricate](https://discourse.julialang.org/u/lntricate)\
**Post date:** [February 15, 2023, 12:49am UTC](https://discourse.julialang.org/t/optional-testing-files-in-pacakge/94657/1 "2023-02-15T00:49:52Z")

</div>

Hello, I have made a small package for reading and writing a particular file type, and I would like to provide some sample testing files to run unit tests on. However, it seems suboptimal to have them downloaded with the package since most users don’t need them. Is there a way to mark some files to only be downloaded for running tests?

Ideally I would like to avoid making a new repo just to host the files to be downloaded with Artifacts, but I will if there’s no better way.

Any help or ideas will be appreciated!

---

<div class="post-metadata">

**Author:** ![M-PERSIC](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/m-persic/32/51968_2.png) [@M-PERSIC](https://discourse.julialang.org/u/M-PERSIC)\
**Post date:** [February 15, 2023, 3:11am UTC](https://discourse.julialang.org/t/optional-testing-files-in-pacakge/94657/2 "2023-02-15T03:11:52Z")

</div>

Artifacts can be lazily downloaded (on-demand) by setting `lazy = true` in your Artifacts.toml file [like so](https://pkgdocs.julialang.org/v1/artifacts/#Artifacts.toml-files):

```julia
[socrates]
git-tree-sha1 = "43563e7631a7eafae1f9f8d9d332e3de44ad7239"
lazy = true

```

[It is recommended](https://pkgdocs.julialang.org/v1/creating-packages/#Adding-tests-to-the-package) to keep tests in a separate `test/` directory with its own environment (separate Project.toml). This will allow you to avoid adding test-specific dependencies into your actual package:

```julia
- Project.toml
- src/
   - main.jl
- test/
    - Project.toml
    - tests.jl

```

---

<div class="post-metadata">

**Author:** ![halleysfifthinc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/halleysfifthinc/32/206280_2.png) [@halleysfifthinc](https://discourse.julialang.org/u/halleysfifthinc)\
**Post date:** [February 15, 2023, 4:03pm UTC](https://discourse.julialang.org/t/optional-testing-files-in-pacakge/94657/3 "2023-02-15T16:03:48Z")

</div>

I have a similar file reading package that I recently switched to Artifacts for test files: [C3D.jl](https://github.com/halleysfifthinc/C3D.jl).

I used [ArtifactUtils.jl](https://github.com/simeonschaub/ArtifactUtils.jl) to create the artifacts as gists on GitHub, and then use LazyArtifacts (stdlib) in my tests to download the individual artifacts on demand.
