Hi !

I'm fighting with a piece of our test framework that worked well with Junit4, not so much with Junit5.

In Junit4, we were using Rule and ClassRule to declare some DirectoryService used in tests (typically, if we want to test some features, we start with a DS creation that will be visible by all the tests. This is what we do with ClassRule. If we want a specific test to declare a new DS, we use a Rule for that: this is for instance what we do to check replication, where we need 2 DS).

Anyway, in Junit5, Rule and ClassRule has been removed, and we have to implement Extensions, which are interface containing declaration for those methods :

BeforeEachCallback,
AfterEachCallback,
BeforeAllCallback,
AfterAllCallback

The logic is pretty simlple: those callbacks get called before the first test, before each test, after each test and after all tests.

Nothing fancy, and it's quite smart.

Now, the pb I have is that I have to declare the DS instance in the BeforeAll callback, and sometime declare a DS in a BeforeEach callback (but not necessarilly). The trouble is that those extensions are not visible by the tests, so I can't use the instance.

I can foresee a hack: creating a static class that will contain the instance, feed it in the BeforeEach and BeforeAll callbacks, and make the fields visible.

It's ugly...

I have trie to play with the ParameterResolver, which is a way to start Parameterized tests (and so pass a parameter to a test), but with not much success so far.

The second issue is that I don't want to create a DS instance everytime I call BeforeEach. I don't know how to do that.

If any of you have soime suggestion, that would be very appreciate !

Thanks !
--
*Emmanuel Lécharny - CTO* 205 Promenade des Anglais – 06200 NICE
T. +33 (0)4 89 97 36 50
P. +33 (0)6 08 33 32 61
emmanuel.lecha...@busit.com https://www.busit.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@directory.apache.org
For additional commands, e-mail: dev-h...@directory.apache.org

Reply via email to