DENG-MIT / Arrhenius.jl

Differentiable Reacting Flow Modeling Software
https://deng-mit.github.io/Arrhenius.jl/dev/
MIT License
58 stars 21 forks source link

Add Unit Testing for development #56

Open jiweiqi opened 3 years ago

jiweiqi commented 3 years ago

As the package becomes more and more complex, it is important to adopt unit testing. We can following the example of RMS.jl at https://github.com/ReactionMechanismGenerator/ReactionMechanismSimulator.jl/blob/ac2a3bd88504b86d5bc60dedc09533839a9c9cbb/src/Calculators/TestThermo.jl#L1-L60.

Some thoughts:

TJP-Karpowski commented 3 years ago

That sound like a good ideal. I can add that for the thermo interface.

I think the naming "test_.jl" sounds great. I also agree, that we can test a lot against Cantera. But could you explain, why you would put the test files in the source folder? I would prefer those test files either in the toplevel test dir (e.g. test/test_Thermo.jl) or in a separate folder in the src directory (src/tests/test_Thermo.jl) as I fear, that the src dir becomes cluttered over time. I also find it conceptually odd to place things which are not actually src files in the src toplevel. But maybe I am just unaware of some advantages of the shared folder (especially if they are unique to Julia). In that case please let me know :).

jiweiqi commented 3 years ago

Hi @TJP-Karpowski , I agree with you that we should make the top level of src being clean. Indeed, putting them into either ./test/ or ./src/test is a good idea.

As for the current test files, which are put at the level of src, the reason is that I haven't figured out a good pipeline for debugging code during the development phase. As you probably know, if I import Arrhenius.jl via using Arrhenius, every time I change the source code, I will have to restart the Julia terminal. Instead, I currently import Arrhenius.jl by directly executing the module file as done in https://github.com/DENG-MIT/Arrhenius.jl/blob/3f7700709ad1092291c9d5e3d108f233f845a696/src/_transport_test.jl#L5-L43. I feel this is not a good way to do it. But at the current time being, I haven't tried other approaches.

Noting that, I have to call Arrhenius.R to access the member of the Arrhenius module. This is different from the standard test file, like https://github.com/DENG-MIT/Arrhenius.jl/blob/3f7700709ad1092291c9d5e3d108f233f845a696/test/runtests.jl#L1-L38.

TJP-Karpowski commented 3 years ago

I had the same problem with the Julia restart, luckily we are not the first to have that issue. You can use the revise package: https://timholy.github.io/Revise.jl/stable/ . Just call using Revise before using Arrhenius and then revise will check for changes to the source files and will apply those changes in the running session :).