-
Couldn't load subscription status.
- Fork 1.4k
Import-less test methods #4566
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
Import-less test methods #4566
Conversation
|
Question: should we do this for |
e4430b6 to
c611ae5
Compare
|
@hmemcpy I think it makes sense for |
|
Great, I'll add those as well.
This PR would make step 3 redundant, however for assertions I would still need to import each individual one. Perhaps it's worth thinking of somehow proxying all of them? |
c611ae5 to
7b1d3e1
Compare
|
Hmm, I was afraid of that. I'm met with a problem. Adding the delegate calls for Unless there's a way of solving this issue without having to rearrange the code, I have a proposal. Now that #4242 was merged, I suggest consolidating gathering the source location for the assert methods via the implicit |
|
Ok, let me know what you want to do there. I do think consolidation is useful. I am not sure if that alone will solve the problem after we simplify |
|
@hmemcpy You can't delegate to macro methods, but you may delegate to the implementation of the macro: final def assert[A](expr: => A)(assertion: Assertion[A]): TestResult = macro Macros.assert_impl
In Scala 2 you can traverse the tree surrounding the macro call / implicit summon, so you can preserve auto-labeling even with an implicit macro. But I think that's impossible in Scala 3, a macro can only inspect the tree that's passed to it, so in Scala 3 the assert will have to remain a macro. |
|
Thanks @neko-kai! I'm afraid that if I go down this road I'd have to split the Perhaps then we can keep this PR as-is, only introducing |
|
@hmemcpy You can put assert into a separate trait e.g. |
|
@hmemcpy If you can sign the CLA, it's good to merge! |
This is a follow-up of sorts to #4520/#4532. Introduces
suiteandtestMin addition toteston theDefaultRunnableSpec. This allows creating an entire suite just with importingzio.test.DefaultRunnableSpecand nothing else:Additional imports (
zio.ZIO, assertions) may be added as needed. But this suite compiles and runs without explicitly addingimport zio.test._.