Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

For my application I created my own type of ApplicationContext that allows me to interact in specific manners that are needed for may application.

(对于我的应用程序,我创建了自己的ApplicationContext类型,该类型允许我以可能需要应用程序的特定方式进行交互。)

As the application is a desktop application, I create the context like this:

(由于该应用程序是桌面应用程序,因此我将创建如下上下文:)

@SpringBootApplication
@Import(StandaloneConfiguration.class)
@PropertySource(value = {"application.properties", "server.properties"})
public class OpenPatricianApplication extends Application {
    private ApplicationContext context;
    @Override
    public void init() {
        SpringApplicationBuilder builder = new SpringApplicationBuilder(OpenPatricianApplication.class);
        context = builder.contextClass(DependentAnnotationConfigApplicationContext.class).run(getParameters().getRaw().toArray(new String[0]));
        // more initialisation

        }
    }
}

Now I want to create a Spring Boot integration test that actually relies on the functionality of my own ApplicationConext implementation.

(现在,我想创建一个实际上依赖于我自己的ApplicationConext实现的功能的Spring Boot集成测试。)

@SpringBootTest(classes = {ServerTestConfiguration.class})
public class ServerIntegrationTest {
    private DependentAnnotationConfigApplicationContext context;
}

How do I go about initializing my context in the test?

(如何在测试中初始化我的context ?)

The context must be created in order to start the spring application for this to work, but with the SpringBootTest annotation this already happened, when the constructor is entered.

(必须创建context才能启动spring应用程序才能SpringBootTest正常工作,但是使用SpringBootTest批注时,在输入构造函数时已经发生了这种情况。)

Are there any additional annotations or parameter for existing ones that can be applied?

(现有的注释或参数是否可以应用?)

Should tests of these nature not be annotated with SpringBootTest at all and the application created manually?

(应该不使用SpringBootTest完全注释这些性质的测试,而是手动创建应用程序吗?)

  ask by hotzst translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
377 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...