How do I test my package while avoiding adding large alternative dependencies?

Two examples of lightweight packages as alternatives to a large package:

  • RecipesBase.jl instead of Plots.jl
  • OrdinaryDiffEq.jl instead of DifferentialEquations.jl

In both cases, the former is added to a personal package to avoid the sheer size of the latter as a dependency.

For example, in OrdinaryDiffEq.jl, you choose the algorithm. But what if I want to run the same code with solve from DifferentialEquations.jl to see what algorithm is chosen for me?

And another example, with RecipesBase.jl I’ll be implementing recipes, but to test them I need to install the Plots.jl package anyway.

Is it as simple as Pkg.adding both the smaller and larger packages to my package, but avoid import/using them in my source code?

For RecipesBase: How to test plot recipes? - #6 by giordano.

As a general answer to your question, you can add test-specific dependencies which will be installed only when running the test, not when using your package normally.

2 Likes

Thanks! This is what I’m looking for I believe.

For testing in a different sense, as the above scenario, I’ll need a whole new environment/project to activate, won’t I. It doesn’t make sense to add DifferentialEquations to the test environment.

In that case I’ll have to copy my code over, or re-implement just the needed components, and then test with DifferentialEquations.jl replacing OrdinaryDiffEq.jl