How to count the number of times the spring boot loads on spring tests?

Viewed 623

I've a app with spring boot tests, can I enforce the number of times that spring boot is loaded? so if someone will load another spring boot I'll will warn about it.

1 Answers

The question is a bit general and my answer may be not exactly what is wanted.

With logging.level.org.springframework.test.context.cache: debug you can monitor how many contexts are loaded, for example this project use 7 contexts:

Spring test ApplicationContext cache statistics: [DefaultContextCache@3655a68c size = 7, maxSize = 32, parentContextCount = 0, hitCount = 1780, missCount = 7]

Related