Wesley Hartford
11/14/2023, 5:09 PMListener
or Extension
(or something else) such that the added test is always executed as the last test case? I have a handful of test classes which all need to perform the same test after other test cases have completed, to ensure that the tests clean up after themselves.Emil Kantis
11/14/2023, 5:12 PMWesley Hartford
11/14/2023, 5:13 PMafterSpec
, but I'd rather it show up as a test.LeoColman
11/14/2023, 6:50 PMEmil Kantis
11/14/2023, 6:57 PMWesley Hartford
11/14/2023, 6:59 PMLeoColman
11/14/2023, 7:00 PMWesley Hartford
11/14/2023, 7:01 PMLeoColman
11/14/2023, 7:07 PMafterProject
, with less granularityEmil Kantis
11/14/2023, 7:10 PMTestCaseExtension
that modifies the outcome of the test if it doesn't clean up properly. You would immediately see which test case left lingering data (rather than just which Spec) and you could register it globally for your integration testsabstract class DbSpec(function: FunSpec.() -> Unit) : FunSpec(
{
function()
test("db should be empty"){}
},
)
Wesley Hartford
11/14/2023, 7:13 PMinit
block rather than a lambda, but that wouldn't work if a child class defined their tests in their own init
block, since the child init
would run after the parent's init
block, causing the child's test cases to follow the one defined by the parent. But I think using a lambda as in your example would work.Emil Kantis
11/14/2023, 7:30 PMWesley Hartford
11/14/2023, 7:30 PMEmil Kantis
11/14/2023, 7:30 PMWesley Hartford
11/14/2023, 7:32 PMinit
block, so if the child uses an init block rather than a lambda constructor parameter, its tests get executed after the one added by the base class.Emil Kantis
11/14/2023, 8:02 PMWesley Hartford
11/14/2023, 9:03 PMTestCaseExtension
. I only run the check on root tests, that way anything within a test container can share database entries as long as they get cleaned up by the end of the container.