Ahmed Ibrahim
08/13/2020, 1:07 PMobject MyTestCase : Spek({})
vs
class MyTestCase : Spek({})
David Silva
08/13/2020, 2:30 PMobject
as I believe that’s what was/is used at the docs. Also, since these test classes (leaves, not the intermediate classes, if any) are not parametrised and the runtime engine does not seem to require it, there’s no need to be a class
.
Other than that, I have no idea if there’s an opinionated view on object
vs class
on the official docs.Ahmed Ibrahim
08/13/2020, 2:58 PMobject
as well, however since object
are singletons that gets lazily initialized when needed, I was wondering what happens when in a big project where we have thousands of test singletons in memory that might not be garbage collected, wouldn't we risk an OOM in CIs or our local development machine?David Silva
08/13/2020, 5:59 PMAhmed Ibrahim
08/13/2020, 6:04 PMpublic final class MyTest extends Spek {
public static final MyTest INSTANCE;
private MyTest() {
super((Function1)null.INSTANCE);
}
static {
MyTest var0 = new MyTest();
INSTANCE = var0;
}
}
It seems that INSTANCE won't be garbage collected, but again I have no idea how does JUnit's test runtime manages test instancesraniejade
08/13/2020, 11:27 PMclass
vs object
, I used it in the samples to show people that they can use object
😅. But TBH, the class and object thing is just an extra ceremony, ideally I would want to write their tests directly in kts files instead of wrapping them in a class. I might add some kind of support via the Kotlin Scripting API, but that API being jvm only makes me step back from it.raniejade
08/14/2020, 12:08 AMINSTANCE
for example will be in the heap). With 2000 tests, the spek classes will only occupy ~32KB of memory.Ahmed Ibrahim
08/14/2020, 8:29 AM