最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - How to control assignment of tests to processes with Junit5 and maven-failsafe in forked execution mode? - Stack Overflow

programmeradmin5浏览0评论

Context

Consider a Junit 5 test suite with a maven-failsafe configuration that is configured to run the tests concurrently in multiple processes using the forkCount parameter.

Question

Is it possible to programmatically control which forks pick up what test?

Motivation

The performance of the overall test suite can change dramatically based on how tests are distributed across forks. This is especially relevant for Spring-based tests: often one of the slowest parts of a spring-based test is spinning up the application context (AC). Therefore, the Spring TestContext framework caches the AC between tests, but clearly this isn't (can't be) shared between processes. If a parallel test suite uses multiple distinct ACs, then minimizing the distinct number of ACs per process can significantly reduce runtime.

Failed Attempt

One option I've explored is to use test suites. We can configure failsafe to fork based on test suite, and then manually group the tests in appropriate suites. This is however less than ideal, because it relies on manual (thus unreliable) assignment of tests to suites, and because it strictly pins a suite to a fork (which can leave other forks idle when suites aren't approximately the same size).

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论