# Incremental testing

**URL:** https://discourse.julialang.org/t/incremental-testing/127680
**Category:** General Usage
**Tags:** documentation
**Created:** [April 3, 2025, 2:40pm UTC](https://discourse.julialang.org/t/incremental-testing/127680 "2025-04-03T14:40:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![langestefan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/langestefan/32/207923_2.png) [@langestefan](https://discourse.julialang.org/u/langestefan)
#### Post date: [April 3, 2025, 2:40pm UTC](https://discourse.julialang.org/t/incremental-testing/127680/1 "2025-04-03T14:40:00Z")

</div>

Hi,

I was reading the page on [unit testing](https://docs.julialang.org/en/v1/stdlib/Test/#Basic-Unit-Tests) and I found that the suggested method `] test` was rather slow due to pre-compilation, making it unusable for me during development.

There is a much faster way to incrementally run tests, using Revise.jl.

For example I have a file `test/runtests.jl` (from BestieTemplate.jl) which collects my tests.

```julia
#=
Don't add your tests to runtests.jl. Instead, create files named

    test-title-for-my-test.jl

The file will be automatically included inside a `@testset` with title "Title For My Test".
=#
function runtests()
    for (root, dirs, files) in walkdir(@ __DIR__ )
        for file in files
            if isnothing(match(r"^test-.*\.jl$", file))
                continue
            end
            title = titlecase(replace(splitext(file[6:end])[1], "-" => " "))
            @testset "$title" begin
                @info "Running test: $file at dir $root"
                include(root * '/' * file)
            end
        end
    end
end

# Run the tests
runtests()

```

From Revise.jl I call [includet](https://timholy.github.io/Revise.jl/stable/user_reference/#Revise.includet) to track any changes to my tests:

```julia
julia> using Revise
includet("test/runtests.jl")
runtests()

```

Now I can run my tests, make changes, create new tests all without having to pre-compile.

Would it make sense to add this as a section to the unit testing docs?

---

<div class="post-metadata">

### Author: ![Satvik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/satvik/32/20486_2.png) [@Satvik](https://discourse.julialang.org/u/Satvik)
#### Post date: [April 3, 2025, 3:00pm UTC](https://discourse.julialang.org/t/incremental-testing/127680/2 "2025-04-03T15:00:05Z")

</div>

I think it would be great to add something similar, or post a library that makes unit tests with Revise easier.

I have something similar in my monorepo:

```julia
function run_tests(test_names::Union{Nothing,Vector{String}}=nothing)

    # When we pass in arguments on the command line, they're
    # read into the Base.ARGS variable. This mimics that effect
    empty!(Base.ARGS)
    if !isnothing(test_names)
        push!(Base.ARGS, "--include_tests")
        append!(Base.ARGS, test_names)
    end

    current_file_path = @ __DIR__
    project_path = dirname(dirname(current_file_path))
    runtests_path = joinpath(project_path, "test", "runtests.jl")
    include(runtests_path)

    empty!(Base.ARGS)
    return nothing
end

```

Which lets me run things like `run_tests(["db", "ml"])` and only run test sets that contain either of those strings, or `run_tests()` to run all tests, and works with Revise.

---

<div class="post-metadata">

### Author: ![langestefan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/langestefan/32/207923_2.png) [@langestefan](https://discourse.julialang.org/u/langestefan)
#### Post date: [April 3, 2025, 3:10pm UTC](https://discourse.julialang.org/t/incremental-testing/127680/3 "2025-04-03T15:10:27Z")

</div>

A Julia library with the same kind of functionality that pytest offers would be fantastic. I know there are a few attempts out there but I don’t know any that are still actively maintained.

---

<div class="post-metadata">

### Author: ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)
#### Post date: [April 3, 2025, 5:54pm UTC](https://discourse.julialang.org/t/incremental-testing/127680/4 "2025-04-03T17:54:40Z")

</div>

I think the Test Item framework is likely what your are looking for:

> **[Test Item Framework · Julia in VS Code](https://www.julia-vscode.org/docs/stable/userguide/testitems/)**
>
> Documentation for Julia in VS Code.

---

<div class="post-metadata">

### Author: ![langestefan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/langestefan/32/207923_2.png) [@langestefan](https://discourse.julialang.org/u/langestefan)
#### Post date: [April 3, 2025, 6:12pm UTC](https://discourse.julialang.org/t/incremental-testing/127680/5 "2025-04-03T18:12:15Z")

</div>

Definitely seems to support a lot of useful features. Hopefully they will keep developing it. But I will still need to use the `Revise.jl` flow given above.
