TestItemRunner.jl icon indicating copy to clipboard operation
TestItemRunner.jl copied to clipboard

Provide some kind of "coverage" warning/error if a test file includes code outside a testitem

Open NHDaly opened this issue 2 years ago • 2 comments

If you have a test file that has a typo in it, and accidentally looks like this:

# src/foo_test.jl
@testitem "test 1" begin
    ...
end

@testiteem "test 2" begin
    ...
end

You'll notice that there is a typo in the definition of test 2: @testiteem.

But since this file isn't included anywhere, it's never actually executed by anything, and so no one will ever warn you that this test item macro is malformed! 😱

So it seems like we'll need some kind of ability to report on lines in a "test file" that weren't covered. Maybe this is just integrating with the standard coverage report, and generating code coverage on the test files? Maybe that'll "just work" if you put your testitems in the src/ directory?

NHDaly avatar Jan 20 '23 18:01 NHDaly

CC: @nickrobinson251

NHDaly avatar Jan 20 '23 18:01 NHDaly

Another option would be to have a "strict test file" option. If that is enabled, if there is a Julia file that has anything other than @testitem or @testsetup in it, then we report an error. Could even be a separate file extension, I guess?

davidanthoff avatar Jan 26 '23 21:01 davidanthoff