I’m having some trouble structuring my project so that i can easily run tests.
Right now I have the following structure:
Project/ src/ MyStruct.jl test/ MyStruct-test.jl runtests.jl Project.toml Manifest.Toml
MyStruct.jl I define a
struct MyStruct and some methods for it. Then, on
MyStruct-test.jl I have some functions related to testing the correct funcionality of the struct and finally on
runtests.jl I have different
@test macros using this functions.
The top of my
runtests.jl file looks like this:
include("../src/MyStruct.jl") using Test, MyStruct include("MyStruct-Test.jl") ...
However when I try to run
>pkg activate . ; >pkg test I get an error like this:
ERROR: LoadError: LoadError: UndefVarError: MyStruct not defined
I think this is because inside of both
MyStruct-test.jl I use the struct defined in
src/MyStruct.jl but it is not importing it correctly.
The only thing that seems to work is hardcoding the path via
push!(LOAD_PATH, "/path/to/MyStruct.jl but this feels very hacky and if I work on this on a different computer I would have to modify it.
What is the proper way to structure the project so that
using works and I can just use Pkg and have it run the tests?