Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including testsets from within testsets #35

Open
dpinol opened this issue Aug 14, 2021 · 5 comments
Open

Including testsets from within testsets #35

dpinol opened this issue Aug 14, 2021 · 5 comments

Comments

@dpinol
Copy link

dpinol commented Aug 14, 2021

Hi,
The limitation to not include files containing testsets from within testsets is a showstopper for our project, since we have our tests within a hierarchy of folders mimicking the hierarchy in the src folder.
Eg
test/runtests.jl:

@testset "utils" begin
 include("utils/1.jl")
end

test/utils/1.jl:

@testset "1" begin
 @test ....
end

Is there any workaround? Do you plan to offer one in the future?

thanks

@rfourquet
Copy link
Collaborator

There is some partial improvement on this front, available when ReTest.hijack is used, via the include=:static keyword. It would be great if you can try it out and report if it works as intended for your test code. This is available on the "master" branch, and I'm about to make a release with it, which should be available later today.

If you want to use ReTest directly in your code, you could try to write your @testset with the undocumented option static_include=true (e.g. @testset "description" static_include=true begin ... end, this might not be the final API). If you want to keep your tests compatible with both Test and ReTest as highlighted at https://juliatesting.github.io/ReTest.jl/stable/#Keeping-the-ability-to-use-Test, I could maybe add the include=:static option also to the retest function.

But for ReTest in general, this option with include looks like a hack (as include can have other side effects beside defining testsets, which are then executed only once with include=:static. A more fit solution still has to be designed. Maybe a simple @testset_include macro or something like that would do.

@Sacha0
Copy link

Sacha0 commented Jan 21, 2022

We are exploring migration from XUnit to ReTest, and the ability to include files containing testsets within a testset is important to us as well: Much of our test code is structured as @dpinol describes above, with multiple levels of includes within includes. Maintaining compatibility with Test is not important to us; we haven't been compatible for some time. Is the status above current Rafael, i.e. the undocumented/experimental static_include=true argument to @testset is the only option for this use case at the moment, and the API may change going forward? Thanks and best wishes Rafael! Hope you're doing well! :)

@Sacha0
Copy link

Sacha0 commented Feb 14, 2022

cc @caseykneale :)

@rfourquet
Copy link
Collaborator

Hi @Sacha0 , nice to see you here :) Yes the status above is current. I don't think static_include is going anywhere, but give me a chance to revisit this issue to try to come up with a better API, I will try to slowly resume my work on ReTest in the upcoming weeks. Hope you are doing well! Best wishes

@Sacha0
Copy link

Sacha0 commented Feb 26, 2022

Cheers, thanks Rafael! Please let us know if we can help out somehow :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants