Skip to content

Adding methods to existing functions in test setups is not isolated to the users of the setup #184

@Drvi

Description

@Drvi

This led to at least one confusing situation where removing a test setup from a test item didn't cause a failure because the required methods leaked the test setup and were available to the test item regardless, MRE:

@testsetup module B
    import ReTestItems
    ReTestItems.runtests(::Int) = 1
end

@testitem "t1" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t2" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t3" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t4" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t5" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t50" setup=[B] begin @test B.ReTestItems.runtests(1) == 1 end
@testitem "t96" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t97" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t98" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t99" begin @test ReTestItems.runtests(1) == 1 end
@testitem "t100" begin @test ReTestItems.runtests(1) == 1 end
Test Summary:    | Pass  Error  Total  Time
ReTestItems      |    6      5     11  3.4s
  .              |    6      5     11      
    the-tests.jl |    6      5     11      
      t1         |           1      1  0.9s
      t2         |           1      1  0.0s
      t3         |           1      1  0.0s
      t4         |           1      1  0.0s
      t5         |           1      1  0.0s
      t50        |    1             1  0.1s
      t96        |    1             1  0.0s
      t97        |    1             1  0.0s
      t98        |    1             1  0.0s
      t99        |    1             1  0.0s
      t100       |    1             1  0.0s

There isn't probably much to do about this, but maybe we should investigate whether Base.Experimental.@MethodTable could be used to make test setups more isolated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    speculativea feature idea that we are undecided about

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions