{"repo":"seregamorph/spring-test-smart-context","free":true,"listed":false,"github":"https://github.com/seregamorph/spring-test-smart-context","clone":"git clone https://github.com/seregamorph/spring-test-smart-context.git","description":"Improving Spring Boot test efficiency","language":"Java","stars":168,"topics":["context-caching","integration-testing","spring-boot"],"license":"Apache-2.0","category":"api-integrations-sdks","readme_excerpt":"Improving Spring Boot Test efficiency Problem statement Spring test framework creates an application context according to test class configuration. The context is cached and reused for all subsequent tests. If there is an existing context with the same configuration, it will be reused. Otherwise, the new context will be created. This is a very efficient and flexible approach, but it has a drawback: eventually this may lead to out of memory errors if the number of unique configurations is too high and context has a lot of heavyweight beans like TestContainers. In many cases simple static bean definition can help, but this project suggests another approach: reordering test classes and eager context cleanup. Consider a sample test suite of 8 classes that use 4 different configurations, classes that have the same configuration are marked with the same colour: In a large test suites as well as in shared CI/CD environments with lots of test pipelines working simultaneously this may eventually lead to out of memory errors in Java process or Docker host. Proposed solution It's recommended to use statically-defined TestContainers beans, optimize reusing same configuration between tests e.g. via common test super-classes. But additionally this library makes two optimizations: test class execution is reordered to group tests with the same context configuration so they can be executed sequentially the order of tests is known, so if current test class is last per current configuration, th","default_branch":null,"files":null,"tree":[],"storefront":"/r/seregamorph","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/seregamorph/spring-test-smart-context/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}