https://kotlinlang.org logo
#kotest
Title
# kotest
d

dave08

02/02/2023, 4:55 PM
Is there a way to have a
beforeTest
in an init block in a base class? I need to drop and create the database contents before each test in the spec's base class so I don't have to do that in each spec... but I'm getting the warning:
Calling non-final function beforeTest in constructor
...? Should I just ignore that?
e

Emil Kantis

02/02/2023, 5:10 PM
I would create an extension instead, and register it wherever you mean to use the base class
d

dave08

02/02/2023, 6:28 PM
The base class has other things there...
An extension doesn't give me all the utility functions and objects I need for db tests
l

LeoColman

02/02/2023, 7:01 PM
Overriding the function is not a nice option for you?
Maybe using test factories and separate them from your hierarchy is an idea
d

dave08

02/02/2023, 7:42 PM
I tried overriding the function, i dont think it worked from the base class... and test factories dont work well with the intellij plugin (at least last time i tried them...)
13 Views