jeudi 22 août 2019

How can I use @SpringBootTest(webEnvironment) with @DataJpaTest?

I am trying to test a JAX-RS application but I'd rather not mock the data especially since there's a buildData method for an existing @DataJpaTest

Here's what I am trying so far:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(
    webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
    classes = MyApp.class
)
@DirtiesContext
@DataJpaTest
public class MyResourceTest {

I get the following error

java.lang.IllegalStateException: Configuration error: found multiple declarations of @BootstrapWith for test class [app.MyResourceTest]: [@org.springframework.test.context.BootstrapWith(value=class org.springframework.boot.test.context.SpringBootTestContextBootstrapper), @org.springframework.test.context.BootstrapWith(value=class org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper)]

The other ones I saw that are similar do not talk about the webEnvironment setting:

Aucun commentaire:

Enregistrer un commentaire