How can I exclude test classes when running nativeTest?

101 views Asked by At

I have a Spring boot 3.1.4 application that has some tests that use things like @DataJpaTest/@WebMvcTest/etc that use mocking & whatnot which aren't supported when running in native test mode.

Is there a way I can exclude these tests from running when running the nativeTest maven profile?

I do want them to run in JVM mode though.

1

There are 1 answers

1
M. Rizzo On BEST ANSWER

You can mark test with via the @EnabledInNativeImage and @DisabledInNativeImage annotations.

Example to not run a test when running nativeTest profile:

@Test
@DisabledInNativeImage
void neverWithinNativeImage() {
    // ...
}