Is there a way to only enable a project extension ...
# kotest
d
Is there a way to only enable a project extension if actually needed in one of the test classes being run? I need some testcontainers to come up but only for certain tests, and stay alive for other classes that might need them.
I guess one option could be to use an
object
as a listener and plug it into the test classes using it.
s
Yeah just add the listener to some specs. Where are you adding it atm
d
On the project, since I don't want those containers to get destroyed and created for every test class
But I don't want to run all the containers when some test classes don't really need them
s
Do you need them on every test run
d
Not all of them
s
I don't understand the requirement. If you start the test container at the project level it'll only be started once ?
d
Like I have some tests that only need postgres, others that only need mysql, etc...
s
And you run them in separate jobs
d
jobs?
s
Test runs
Do you do gradle test postegres and gradle test mysql
Do just one gradle test that does them all
d
No, I usually run single classes in the IDE before/after making changes to code. Before a release, I then run them all.
s
And it's in ide that you don't wanna start them all but just the ones applicable to that test
d
Yup
Saves development time
s
My phone is about to die but you could add tags to the spec classes and have an if statement in the listeners and only start them if the spec has the appropriate tag
👍🏼 1