oneat
oneat

Reputation: 10994

Replace Beans.xml configuration in Spring

How can I replace beans.xml file for testing purposes? I use

@SpringBootApplication
@ImportResource("classpath:Beans.xml")
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

to init class, but in my testing class

@RunWith(SpringRunner.class)
@SpringBootTest
public class ArrayCointainerTest {

I'd like to use another one. Any idea for this?

Upvotes: 2

Views: 274

Answers (1)

kuhajeyan
kuhajeyan

Reputation: 11017

Define a separate configuration class which has you beans xml imported and annotate that with @TestConfiguration. Spring boot automatically pick this up as your test configuration

Detecting test configuration

Upvotes: 3

Related Questions