-
First of all, thanks for creating testcontainers-keycloak. It's a great help in building tests. I'm wondering if you have any recommendations for "resetting" Keycloak in-between tests. If I were writing tests against some other database-backed service, I might just tear down the entire DB between tests. However, stopping and re-launching the entire container is a bit too heavyweight IMO. I could, of course, save references to any entities I've created during the test and delete them in a try/finally clause, but this seems a bit onerous. Do you have any other suggestions for how to "clean up" between tests? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Not really a bullet-proof suggestion, but you can try to setup the testcontainer as usual with |
Beta Was this translation helpful? Give feedback.
Not really a bullet-proof suggestion, but you can try to setup the testcontainer as usual with
private static void...
, doing all the basic configurations you need, but do not import a realm.Then, in a
@Before
annotated method, import/init the realm through admin API as desired, in an@After
annotated method, remove the realm again through admin API. This way, you'll have a new fresh realm for each test method. Give it a try.