Skip to content

Can't export items from @testmodule modules #98

@kenahoo

Description

@kenahoo

It would be very useful to export items from a @testmodule, but that appears not to be possible right now, correct?

I have the following in a file called test/test_test.jl:

@testmodule TestHelpers begin
    f(x, y) = x + y
    export f
end

@testitem "Test the tests" setup = [TestHelpers] begin
    # Try the exported function
    try
        f(1, 2) == 3
    catch e
        println("Error f(1, 2): ", e)
    end

    # Manually export it
    f = TestHelpers.f
    @test f(1, 2) == 3
end

When I run that from the VS Code testing pane, I get this output:

Error f(1, 2): UndefVarError(:f)
Test Summary:                        | Pass  Total  Time
.../test/test_test.jl:Test the tests |    1      1  0.0s

Is there some other technique besides this hacky workaround that I might have missed?

I'm using TestItemRunner v1.0.5 and VS Code 1.95.1. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions