I have a module that I'm writing unit tests for to run with travis.ci.
In my module I perform HTTP POST operations to a web service.
One of my internal only functions validate_http_response()
is integral to the functions I'm creating to wrap around web service calls, so I'd like to test it. However, because there is no such export validate_http_response
the function can't be "seen" by my test script and I get the error:
validate_http_response not defined
How should I structure my test so that I don't have to copy and paste the internal functions into the test itself (there are a few of them)? I'd like to prevent having to maintain a src
and test
script simultaneously.
EDIT Along with the accepted answer I also found I could do the following at the beginning of the test script: include("../src/myfunctions.jl")
, as I have a separate test script for each file in the src
.
Check out the documentation on modules to better understand how namespacing works. There is no forced visibility in Julia, so you can always access functions, exported or non-exported, in any module by fully qualifying the reference.
So in your case, if your module is named HTTP
, you could say HTTP.validate_http_response
to access your unexported function to test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With