In my project, I have both API and UI tests, which are in different packages. I am using JUnit 5 as the test runner with some extensions for UI tests.
I have property junit.jupiter.extensions.autodetection.enabled=true
which means, that all extensions listed in META-INF/services/org.junit.jupiter.api.extension.Extension file will be applied to my @Test
(both API and UI).
The problem is I want this extensions to be applied ONLY to UI tests (which are in separate package).
First solution that comes to mind is to create BaseUiTest
class, @ExtendWith
all extensions which I want to apply to UI tests only and then inherit my UI tests from that class.
OR
Create annotation @UiTest
, apply extensions and use it instead of default @Test
I don't like both options, so maybe there is different approach to apply extensions for UI package only ?