测试中应用程序引导的最佳实践

问题描述

我们正在研究运行测试时应用程序引导与EmbeddedServer的关系。 到目前为止,我们的理解是引导Micronaut应用程序可能是这样的:

public class Application {

    public static void main(String[] args) {
        Micronaut.build(args)
            .eagerInitSingletons(true) 
            .mainClass(Application.class)

            // plus some other stuff you might want to configure here

            .start();
    }
}

但是,在测试中运行嵌入式服务器时,据我们所知,将隐式地完成许多工作:

EmbeddedServer server = ApplicationContext.run(EmbeddedServer.class);

main的{​​{1}}方法中的代码不再相关,并且测试可能会在稍微不同的应用上下文配置(以及现成的设置)下运行。 / p>

我们可能会找到一些解决方案,以确保在两种情况下都以完全相同的方式加载应用上下文。但我首先想检查一下我们是否有窍门,并查看Micronaut在这种情况下是否有建议的做法。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...