测试运行期间多次出现Spring消息

问题描述

我目前正在使用 spring-boot 和 org.testcontainers 库来通过 docker 中的测试。但是我注意到以下消息出现了好几次:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__,| / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v1.5.20.RELEASE)

最多出现 4 次,其中 2 次带有以下消息:

11:33:23.733 [main] INFO  org.springframework.web.context.support.GenericWebApplicationContext - Refreshing org.springframework.web.context.support.GenericWebApplicationContext@13ffeba4: startup date [Wed Jun 16 11:33:23 CEST 2021]; root of context hierarchy

一些引起我注意的消息,第一次出现(我认为唯一需要的)

11:31:48.515 [main] INFO  org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer - Tomcat initialized with port(s): 0 (http)
11:31:49.019 [localhost-startStop-1] INFO  org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 5416 ms

2:为什么不出现?

3:

11:35:06.738 [main] INFO  org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer - Tomcat initialized with port(s): 0 (http)
11:35:06.764 [localhost-startStop-1] INFO  org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 1569 ms

4:

11:36:19.343 [main] INFO  org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer - Tomcat initialized with port(s): 0 (http)
11:36:19.362 [localhost-startStop-1] INFO  org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 454 ms

该消息总是在特定测试后弹出,例如在此测试期间的第三次。

@Category(OneTest.class)
public class PasswordEncryptionTest
{

  @Test
  public void passwordEncryptiontest()
  {
    PasswordEncryption passwordEncryption = new PasswordEncryption();
    try
    {
      String password = "passwordExample";
      
      String encrypted = passwordEncryption.encryptPassword(password.tochararray());
      
      String decrypted = passwordEncryption.decryptPassword(encrypted.tochararray());
      assertEquals(password,decrypted);
    }
    catch (PasswordDecryptionException e)
    {
      e.printstacktrace();
      fail(e.getMessage());
    }
  }

}

这正常吗?因为是启动应用程序时出现的消息,出现了4次,这就是我注意到的。

它会影响测试的性能吗?

Pd:它们是消息,经过多次测试,在不同的环境中,它们不是偶然的结果。我没有看到不同外观之间的时代关系。 (它不遵循时间模式)

  • spring-boot 1.5.20
  • junit47
  • org.testcontainers 1.13.0
  • Docker 窗口 2.2.0.3

解决方法

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

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

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