Can I register a package without doing unit tests? If it only has three functions and is meant to be simple

I am trying to register this package GitHub - sumant-28/AppleHealthParser.jl

I don’t have a software background so unit tests have always been foreign to me. Do I test this by adding a Monte Carlo function to my main source module and use that to randomly generate XML strings to see if one of the accessory functions processes that correctly? And I believe my project.toml file is set at the right version for a package to be registered but I am unsure

Maybe you can include an example file that you let the package parse and check that the result is what you expect?

2 Likes

Really cool that you want to register a package. I just had a quick look and I have some suggestions.

  • The scope is not so big, maybe it could be added to an exiting package or added as an example in an exiting package.
  • Remove “Revise” as a dependency. It is a nice tool for development but should not be package dependecy
  • Change the version to 0.1, I would recommend that you first get the package out, get some feedback and then only put is at 1.0 later when you are sure everything works.
  • The main function is not normal for a package. I would change it and pass the file name as an input . Maybe function parse_apple_health(file::AbsractString)
  • Adding tests is a good idea. You can simply add it under the @testset in AppleHealthParser.jl/test/runtests.jl at main · sumant-28/AppleHealthParser.jl · GitHub A simple unit test would look like @test 1+1 == 2
  • A more realistic test would be
@testset "AppleHealthParser.jl" begin
    small_test_file = #path to a small test file
    output_path = # path to where you expect the output
    rm(output_path) ## delete any left over test output
    parse_apple_health(small_test_file)
    @test isfile(output_path) # test the file is created

    # try to read the content of the output and check that it is correct

end

Look here to see more documentation of tests and how to run them in a pacakge. Unit Testing · The Julia Language and 5. Creating Packages · Pkg.jl

6 Likes

You have given me a lot to think about. I hope to make some amendments and use this experience to learn some lessons.

1 Like

You don’t need to generate random data for unit tests. It’s easier to test with hard-coded data and expected results. Once there are basic unit tests, you could add random tests if you believe such tests are important for finding corner cases, but it’s by no means mandatory.

2 Likes