{"id":476700,"date":"2026-04-20T16:08:10","date_gmt":"2026-04-20T16:08:10","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=476700"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=476700","title":{"rendered":"\u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u044b \u0441 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435\u043c Java-\u0430\u0432\u0442\u043e\u0442\u0435\u0441\u0442\u043e\u0432"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u044b \u0432\u044b\u043a\u0430\u0442\u0438\u043b\u0438 \u0444\u0438\u043a\u0441 \u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0433\u043d\u0430\u0442\u044c \u0440\u0435\u0433\u0440\u0435\u0441\u0441 \u043d\u0430 \u0441\u0442\u0435\u043d\u0434\u0435. \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0448\u044c CI, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0448\u044c \u0442\u0435\u0441\u0442\u044b \u0438 \u0441\u043f\u0443\u0441\u0442\u044f \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043f\u0430\u0440\u0443 \u0447\u0430\u0441\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u0442\u0438\u043c \u043c\u044b \u0440\u0435\u043b\u0438\u0437 \u0438\u043b\u0438 \u043d\u0435\u0442. \u0414\u0435\u043f\u043b\u043e\u0439 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d, \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u0436\u0434\u0443\u0442 \u043c\u0435\u0440\u0434\u0436, \u0430 \u0442\u044b &#8212; \u0442\u0435\u0441\u0442\u044b. \u0410 \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0442\u044c \u0440\u0435\u0433\u0440\u0435\u0441\u0441 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432 \u0434\u0435\u043d\u044c?<\/p>\n<p>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0441\u043e\u0432\u0435\u0442 \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 &#8212; \u201c\u0437\u0430\u043f\u0443\u0441\u0442\u0438 \u0442\u0435\u0441\u0442\u044b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u201d. <br \/>\u041e\u043a\u0435\u0439, \u0430 \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c?<\/p>\n<p>\u0412 JUnit5 \u0441\u0432\u043e\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f. \u0412 Gradle &#8212; \u0441\u0432\u043e\u0439. \u0410 \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0418 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0441\u0435 \u0441\u043b\u043e\u043c\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0442\u0435\u0441\u0442\u044b \u043d\u0430\u0447\u043d\u0443\u0442 \u0433\u043e\u043d\u043a\u0443 \u0437\u0430 \u043e\u0431\u0449\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b.<\/p>\n<p>\u042f \u043f\u0440\u043e\u0432\u0451\u043b \u0441\u0435\u0440\u0438\u044e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432: 5 \u0432\u0438\u0434\u043e\u0432 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432, 4 \u0440\u0435\u0436\u0438\u043c\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430, 3 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u0435\u0440\u043d\u043e\u0441\u0442\u0438. \u0418\u0437\u043c\u0435\u0440\u044f\u043b \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c, \u043d\u043e \u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u201c\u043f\u0435\u0447\u0430\u0442\u0430\u044e \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e, \u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0435\u0440\u0443\u043d\u0434\u0430\u201d.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u043a\u0430\u0436\u0443:<\/p>\n<ul>\n<li>\n<p>\u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u0435\u043b\u043b\u0438\u0437\u043c \u0432 JUnit5 \u0438 Gradle (\u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432);<\/p>\n<\/li>\n<li>\n<p>\u0447\u0442\u043e \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u0431\u0435\u0437 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u043a \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0411\u0414 \u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u043a\u043e\u0439 \u0440\u0435\u0436\u0438\u043c \u0434\u0430\u0435\u0442 \u043b\u0443\u0447\u0448\u0438\u0439 \u0431\u0430\u043b\u0430\u043d\u0441 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u043e\u043b\u044c\u043a\u043e JUnit5 + Gradle. \u0411\u0435\u0437 Maven, \u0431\u0435\u0437 TestNG, \u0431\u0435\u0437 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0438 CI-\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c.<\/p>\n<h3>TL;DR<\/h3>\n<p>\u0414\u043b\u044f \u0441\u0430\u043c\u044b\u0445 \u043d\u0435\u0442\u0435\u0440\u0435\u043f\u0435\u043b\u0438\u0432\u044b\u0445 &#8212; \u0441\u0432\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u041f\u0440\u043e\u0433\u043e\u043d 50 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u043e 6 \u0441\u0435\u043a\u0443\u043d\u0434 \u043a\u0430\u0436\u0434\u044b\u0439.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0421\u0446\u0435\u043d\u0430\u0440\u0438\u0439<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e<\/p>\n<\/th>\n<th>\n<p align=\"left\">JUnit (1&#215;4)<\/p>\n<\/th>\n<th>\n<p align=\"left\">Gradle (4&#215;1)<\/p>\n<\/th>\n<th>\n<p align=\"left\">Hybrid (2&#215;2)<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0427\u0438\u0441\u0442\u044b\u0435 \u0442\u0435\u0441\u0442\u044b<\/p>\n<\/td>\n<td>\n<p align=\"left\">302 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441 (3.80x)<\/p>\n<\/td>\n<td>\n<p align=\"left\">91 \u0441 (3.29x)<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441 (3.78x)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0411\u0414 (\u0431\u0435\u0437 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439)<\/p>\n<\/td>\n<td>\n<p align=\"left\">302 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">7 \u0441 (FAIL)<\/p>\n<\/td>\n<td>\n<p align=\"left\">69 \u0441 (FAIL)<\/p>\n<\/td>\n<td>\n<p align=\"left\">7 \u0441 (FAIL)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0411\u0414 (\u0441 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u043c\u0438)<\/p>\n<\/td>\n<td>\n<p align=\"left\">302 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441 (3.80x)<\/p>\n<\/td>\n<td>\n<p align=\"left\">92 \u0441 (3.29x)<\/p>\n<\/td>\n<td>\n<p align=\"left\">80 \u0441 (3.78x)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0424\u0430\u0439\u043b\u044b (\u0431\u0435\u0437 \u0441\u0438\u043d\u0445\u0440.)<\/p>\n<\/td>\n<td>\n<p align=\"left\">302 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441 (flaky)<\/p>\n<\/td>\n<td>\n<p align=\"left\">92 \u0441 (FAIL)<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441 (FAIL)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0424\u0430\u0439\u043b\u044b (\u0441 \u0441\u0438\u043d\u0445\u0440.)<\/p>\n<\/td>\n<td>\n<p align=\"left\">301 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441 (3.80x)<\/p>\n<\/td>\n<td>\n<p align=\"left\">92 \u0441 (3.28x)<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441 (3.79x)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/189\/49c\/659\/18949c6597061a6225f9b5ba46a05a5c.png\" width=\"1210\" height=\"624\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/189\/49c\/659\/18949c6597061a6225f9b5ba46a05a5c.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/189\/49c\/659\/18949c6597061a6225f9b5ba46a05a5c.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e:<\/p>\n<ul>\n<li>\n<p>Hybrid 2&#215;2 (2 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 x 2 \u043f\u043e\u0442\u043e\u043a\u0430) &#8212; \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440. \u0421\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e ~3.8x \u043d\u0430 \u0432\u0441\u0435\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u0431\u0435\u0437 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 = \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0438\u043b\u0438, \u0447\u0442\u043e \u0445\u0443\u0436\u0435, \u0441\u043a\u0440\u044b\u0442\u0430\u044f \u043f\u043e\u0442\u0435\u0440\u044f \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p>Gradle \u201c\u0447\u0435\u0441\u0442\u043d\u0435\u0435\u201d JUnit \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u0438 \u0447\u0430\u0449\u0435 \u043f\u0430\u0434\u0430\u0435\u0442, \u0442\u0430\u043c \u0433\u0434\u0435 JUnit \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u044f\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438, \u0442\u043e \u043f\u043e\u0435\u0445\u0430\u043b\u0438.<\/p>\n<h3>\u041f\u043e\u0442\u043e\u043a\u0438 \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b: \u0434\u0432\u0430 \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430<\/h3>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043a\u0440\u0443\u0442\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043a\u0430\u043a \u044d\u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0432 Java-\u043c\u0438\u0440\u0435. \u041f\u0430\u0440\u0430\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0442\u0435\u0441\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u0434\u0432\u0443\u0445 \u0443\u0440\u043e\u0432\u043d\u044f\u0445, \u0438 \u043e\u043d\u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f.<\/p>\n<p><strong>JUnit 5 Parallel Execution<\/strong> &#8212; \u043f\u043e\u0442\u043e\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0439 JVM. \u0422\u0435\u0441\u0442\u044b \u0436\u0438\u0432\u0443\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0434\u0435\u043b\u044f\u0442 \u043e\u0431\u0449\u0443\u044e \u043a\u0443\u0447\u0443 (heap) \u0438 \u0432\u0438\u0434\u044f\u0442 \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u0417\u0430\u0442\u0440\u0430\u0442\u044b \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435. \u041f\u043e\u0442\u043e\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0451\u0448\u0435\u0432\u043e, \u043d\u043e \u0438 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u0442\u043e\u0436\u0435 \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0435.<\/p>\n<p><strong>Gradle maxParallelForks<\/strong> &#8212; \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 JVM-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b. Gradle \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 n-\u043a\u043e\u043f\u0438\u0439 Java-\u043c\u0430\u0448\u0438\u043d\u044b \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u043f\u043e\u0440\u0446\u0438\u044e \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041f\u043e\u043b\u043d\u0430\u044f \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a \u043a\u0430\u0436\u0434\u043e\u0439 JVM \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b.<\/p>\n<p><strong>\u0413\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c<\/strong> &#8212; \u0441\u043e\u0432\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043a\u0438. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">[Gradle]\u251c\u2500\u2500 JVM-\u043f\u0440\u043e\u0446\u0435\u0441\u0441 #1 (maxParallelForks)\u2502   \u251c\u2500\u2500 JUnit-\u043f\u043e\u0442\u043e\u043a A \u2500\u2500\u2500 Test1.test1()\u2502   \u2514\u2500\u2500 JUnit-\u043f\u043e\u0442\u043e\u043a B \u2500\u2500\u2500 Test1.test2()\u2502\u2514\u2500\u2500 JVM-\u043f\u0440\u043e\u0446\u0435\u0441\u0441 #2    \u251c\u2500\u2500 JUnit-\u043f\u043e\u0442\u043e\u043a C \u2500\u2500\u2500 Test2.test1()    \u2514\u2500\u2500 JUnit-\u043f\u043e\u0442\u043e\u043a D \u2500\u2500\u2500 Test2.test2()<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0438 \u043f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b. \u041d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\n<\/th>\n<th>\n<p align=\"left\">JUnit (\u043f\u043e\u0442\u043e\u043a\u0438)<\/p>\n<\/th>\n<th>\n<p align=\"left\">Gradle (\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b)<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0418\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u043e\u043b\u043d\u0430\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Static-\u043f\u043e\u043b\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0431\u0449\u0438\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 JVM<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0424\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0431\u0449\u0430\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0431\u0449\u0430\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0411\u0414<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0431\u0449\u0430\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u0431\u0449\u0430\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0417\u0430\u0442\u0440\u0430\u0442\u044b<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0420\u0435\u0441\u0443\u0440\u0441\u044b \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a JVM<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041b\u0443\u0447\u0448\u0435 \u0434\u043b\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0427\u0438\u0441\u0442\u044b\u0445 unit-\u0442\u0435\u0441\u0442\u043e\u0432<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c<\/h3>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0442\u0435\u043e\u0440\u0438\u0438 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 JVM. \u0411\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0433\u0440\u0430\u0431\u0435\u043b\u044c.<\/p>\n<h4>\u041f\u043e\u0442\u043e\u043a\u0438 \u0432 JVM &#8212; \u044d\u0442\u043e \u043f\u043e\u0442\u043e\u043a\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/h4>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 <code>Thread<\/code> \u0432 Java &#8212; \u044d\u0442\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u0432 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 (\u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f <a href=\"https:\/\/docs.oracle.com\/en\/java\/javase\/21\/core\/virtual-threads.html#GUID-15BDB995-028A-45E0-AA85-3B1D2E1A0E14\">\u043c\u043e\u0434\u0435\u043b\u044c 1:1<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 HotSpot). \u041a\u043e\u0433\u0434\u0430 JUnit \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 4 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430, \u0442\u043e \u041e\u0421 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 4 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430 \u0438 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Completely_Fair_Scheduler\">\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u041e\u0421<\/a> \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0438\u0445 \u043f\u043e \u044f\u0434\u0440\u0430\u043c CPU.<\/p>\n<p>\u041c\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c. \u0415\u0441\u043b\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0443 \u043d\u0430\u0441 \u044f\u0434\u0435\u0440 \u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432\u0441\u0435 \u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u044f\u0434\u0435\u0440, \u0442\u043e \u041e\u0421 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u041a\u0430\u0436\u0434\u043e\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9F%D0%B5%D1%80%D0%B5%D0%BA%D0%BB%D1%8E%D1%87%D0%B5%D0%BD%D0%B8%D0%B5_%D0%BA%D0%BE%D0%BD%D1%82%D0%B5%D0%BA%D1%81%D1%82%D0%B0\">\u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/a> \u044d\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u042d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043d\u0430\u0448\u0438 \u0437\u0430\u0442\u0440\u0430\u0442\u044b.<\/p>\n<h4>\u041e\u0431\u0449\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c<\/h4>\n<p>\u041f\u043e\u0442\u043e\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0439 JVM \u0434\u0435\u043b\u044f\u0442 \u043e\u0434\u043d\u0443 \u043a\u0443\u0447\u0443 (heap) \u0438 \u043e\u0434\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432 (Metaspace). \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0442\u0435\u043a\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0445 \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0439.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e92\/108\/b18\/e92108b18193c9abbd2a2bf28e45c7a1.png\" width=\"1325\" height=\"655\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/e92\/108\/b18\/e92108b18193c9abbd2a2bf28e45c7a1.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e92\/108\/b18\/e92108b18193c9abbd2a2bf28e45c7a1.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>Static-\u043f\u043e\u043b\u044f \u043e\u0431\u0449\u0438\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0415\u0441\u043b\u0438 \u043e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u043f\u0438\u0448\u0435\u0442 \u0432 <code>static int counter<\/code>, \u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u0432\u0438\u0434\u0438\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u041f\u0440\u0430\u0432\u0434\u0430 \u0431\u0435\u0437 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0439. <a href=\"https:\/\/docs.oracle.com\/javase\/specs\/jls\/se21\/html\/jls-17.html#jls-17.4\">Java Memory Model (JMM)<\/a> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 <a href=\"https:\/\/docs.oracle.com\/javase\/specs\/jls\/se21\/html\/jls-17.html#jls-17.4.5\">happens-before<\/a>: \u0431\u0435\u0437 <code>volatile<\/code>, <code>synchronized<\/code> \u0438\u043b\u0438 <code>Lock<\/code> \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u043c. \u041d\u0430 x86 \u044d\u0442\u043e \u0441\u0442\u0440\u0435\u043b\u044f\u0435\u0442 \u0440\u0435\u0436\u0435 \u0442\u0430\u043a \u043a\u0430\u043a \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0438\u043c\u0435\u0435\u0442 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Memory_ordering#Runtime_memory_ordering\">\u0441\u0438\u043b\u044c\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0430\u043c\u044f\u0442\u0438<\/a>, \u043d\u043e \u043d\u0430 ARM &#8212; \u0448\u0430\u043d\u0441\u044b \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u044e\u0442.<\/p>\n<p>\u0418 \u0435\u0449\u0435 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0447\u0430\u0441\u0442\u043e \u043f\u0443\u0442\u0430\u044e\u0442: Thread-safe != test-safe. <code>AtomicInteger<\/code> \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u0435\u043d, \u043d\u043e \u0435\u0441\u043b\u0438 \u0434\u0432\u0430 \u0442\u0435\u0441\u0442\u0430 \u043f\u0438\u0448\u0443\u0442 \u0432 \u043e\u0434\u0438\u043d \u0441\u0447\u0435\u0442\u0447\u0438\u043a, \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c. \u041f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0435\u0441\u0442\u044b \u0441 \u043d\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e.<\/p>\n<h4>\u041f\u0440\u043e\u0446\u0435\u0441\u0441\u044b<\/h4>\n<p>\u041a\u043e\u0433\u0434\u0430 Gradle \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 4 \u0444\u043e\u0440\u043a\u0430, \u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 java-\u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u043a\u0443\u0447\u0435\u0439, GC, JIT-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c, static-\u043f\u043e\u043b\u044f\u043c\u0438 \u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e\u043c \u0438\u043c\u0451\u043d \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<p>\u041e\u0431\u0449\u0438\u043c\u0438 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0438 \u0441\u0435\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 Gradle-\u0444\u043e\u0440\u043a\u0438 \u043d\u0435 \u0441\u0442\u0440\u0430\u0434\u0430\u044e\u0442 \u043e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 static-\u043f\u043e\u043b\u044f\u043c\u0438, \u043d\u043e \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u044f \u0437\u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0430\u0439\u043b\u0430\u043c \u0438\u043b\u0438 \u0411\u0414 \u043d\u0438\u043a\u0443\u0434\u0430 \u043d\u0435 \u0434\u0435\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<h4>\u0417\u0430\u043a\u043e\u043d \u0410\u043c\u0434\u0430\u043b\u0430<\/h4>\n<p>\u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%97%D0%B0%D0%BA%D0%BE%D0%BD_%D0%90%D0%BC%D0%B4%D0%B0%D0%BB%D0%B0\">\u0437\u0430\u043a\u043e\u043d\u043e\u043c \u0410\u043c\u0434\u0430\u043b\u0430<\/a>:<\/p>\n<pre><code class=\"1c\">\u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 = 1 \/ (a + (1 - a) \/ p)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0413\u0434\u0435 <strong>a<\/strong> &#8212; \u0434\u043e\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, <strong>p<\/strong> &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<p>\u0412 \u043c\u043e\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 <code>Thread.sleep<\/code> &#8212; \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u0443\u0435\u043c\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f (a = 0), \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c 4x \u043d\u0430 4 \u043f\u043e\u0442\u043e\u043a\u0430\u0445. \u0420\u0435\u0430\u043b\u044c\u043d\u043e \u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f 3.8x. \u041e\u0441\u0442\u0430\u0432\u0448\u0430\u044f\u0441\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u0430\u043a \u0440\u0430\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438: \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f JUnit, \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f Gradle, \u0440\u0430\u0431\u043e\u0442\u0430 GC.<\/p>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435: spring-\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0411\u0414, \u043f\u0440\u043e\u0433\u0440\u0435\u0432 \u043a\u044d\u0448\u0435\u0439 \u0438 \u0442.\u0434. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u0436\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0432 2-3x \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u044d\u0442\u043e \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u043f\u043e\u0431\u0435\u0434\u0430.<\/p>\n<h4>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e Thread.sleep<\/h4>\n<p>\u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u044f \u0432\u044b\u0431\u0440\u0430\u043b \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u0443\u0434\u0430\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u0441\u0432\u043e\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445. \u041d\u043e \u043d\u0430 \u0434\u0435\u043b\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432 \u0432 \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0436\u0434\u0443\u0442 \u043e\u0442\u0432\u0435\u0442\u0430 \u043e\u0442 \u0411\u0414, \u043e\u0442 HTTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043e\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. <code>Thread.sleep<\/code> \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435: \u043f\u043e\u0442\u043e\u043a \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d, \u044f\u0434\u0440\u043e CPU \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0431\u0435\u0437 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u0438.<\/p>\n<hr\/>\n<h3>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u0432 JUnit 5<\/h3>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 JUnit 5 \u043d\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a.<\/p>\n<p>\u0424\u0430\u0439\u043b <code>src\/test\/resources\/junit-platform.properties<\/code>:<\/p>\n<pre><code class=\"json\">junit.jupiter.execution.parallel.enabled=truejunit.jupiter.execution.parallel.mode.default=concurrentjunit.jupiter.execution.parallel.config.strategy=fixedjunit.jupiter.execution.parallel.config.fixed.parallelism=4<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0427\u0435\u0442\u044b\u0440\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0438 \u0442\u0435\u0441\u0442\u044b \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432 4 \u043f\u043e\u0442\u043e\u043a\u0430. <code>mode.default=concurrent<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0415\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u0430\u0441\u0441\u044b, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"json\">junit.jupiter.execution.parallel.mode.default=same_threadjunit.jupiter.execution.parallel.mode.classes.default=concurrent<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>@Execution(CONCURRENT)<\/code> \u0438\u043b\u0438 <code>@Execution(SAME_THREAD)<\/code>.<\/p>\n<p>\u0412 \u0441\u0432\u043e\u0435\u043c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 JUnit \u043f\u0435\u0440\u0435\u0434\u0430\u044e \u0447\u0435\u0440\u0435\u0437 <code>systemProperties<\/code> \u0432 <code>build.gradle<\/code>. \u0422\u0430\u043a \u0431\u044b\u043b\u043e \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 Gradle-\u0437\u0430\u0434\u0430\u0447 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438, \u0447\u0435\u043c \u0445\u0430\u0440\u0434\u043a\u043e\u0434\u0438\u0442\u044c properties-\u0444\u0430\u0439\u043b\u044b \u0438 \u043f\u043e\u0434\u043a\u0438\u0434\u044b\u0432\u0430\u0442\u044c \u0438\u0445.<\/p>\n<h3>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u0432 Gradle<\/h3>\n<p>Gradle \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c <code>maxParallelForks<\/code>. \u041e\u043d \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 JVM-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445.<\/p>\n<pre><code class=\"java\">tasks.register('testGradleParallel', Test) {    useJUnitPlatform()    maxParallelForks = 4  \/\/ 4 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 JVM-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430    systemProperties = [        'junit.jupiter.execution.parallel.enabled': 'false'  \/\/ JUnit \u041d\u0415 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0442    ]}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u043d\u0435 \u043f\u0443\u0442\u0430\u0442\u044c <code>maxParallelForks<\/code> \u0441 \u0444\u043b\u0430\u0433\u043e\u043c <code>--parallel<\/code>. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0442 \u0441\u0431\u043e\u0440\u043a\u0443, \u0430 \u043d\u0435 \u0442\u0435\u0441\u0442\u044b. \u0414\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0444\u043b\u0430\u0433 <code>--parallel<\/code> \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0430\u0441\u0442.<\/p>\n<h3>\u041a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c<\/h3>\n<p>\u0422\u0443\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0431\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u043c\u0435\u0441\u0442\u0435<\/p>\n<pre><code class=\"java\">tasks.register('testHybrid2x2', Test) {    useJUnitPlatform()    maxParallelForks = 2  \/\/ 2 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430    systemProperties = [        'junit.jupiter.execution.parallel.enabled'                  : 'true',        'junit.jupiter.execution.parallel.mode.default'             : 'concurrent',        'junit.jupiter.execution.parallel.mode.classes.default'     : 'concurrent',        'junit.jupiter.execution.parallel.config.strategy'          : 'fixed',        'junit.jupiter.execution.parallel.config.fixed.parallelism' : '2'  \/\/ 2 \u043f\u043e\u0442\u043e\u043a\u0430 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c    ]    \/\/ \u0418\u0442\u043e\u0433\u043e: 2 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 x 2 \u043f\u043e\u0442\u043e\u043a\u0430 = 4 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<hr\/>\n<h3>\u041c\u0435\u0442\u043e\u0434\u0438\u043a\u0430 \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0439<\/h3>\n<h4>\u0427\u0442\u043e \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u043c<\/h4>\n<ul>\n<li>\n<p>50 \u0442\u0435\u0441\u0442\u043e\u0432 (10 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 x 5 \u043c\u0435\u0442\u043e\u0434\u043e\u0432), \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 <code>Thread.sleep(6000)<\/code> \u2014 \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044f 6 \u0441\u0435\u043a\u0443\u043d\u0434 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f: 50 x 6 = 300 \u0441\u0435\u043a\u0443\u043d\u0434 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>3 \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430, \u0431\u0435\u0440\u0451\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435. \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0430\u0437\u0431\u0440\u043e\u0441 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0433\u043e\u043d\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041d\u0430 \u0447\u0435\u043c \u0433\u043e\u043d\u044f\u0435\u043c<\/h4>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043c\u043e\u044f \u043c\u0430\u0448\u0438\u043d\u043a\u0430 \u044d\u0442\u043e HP ProBook 430 G8.<\/p>\n<pre><code class=\"java\">OS:     ALT Workstation K 11.2 (Nemorosa) x86_64Kernel: Linux 6.12.74-6.12-alt1CPU:    11th Gen Intel(R) Core(TM) i7-1165G7 (8) @ 4.70 GHzMemory: 15.31 GiBJava:   21.0.10 (OpenJDK)Gradle: 8.10<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>5 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432<\/h4>\n<ol>\n<li>\n<p>base &#8212; \u0447\u0438\u0441\u0442\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0431\u0435\u0437 \u043e\u0431\u0449\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>database_broken &#8212; \u0442\u0435\u0441\u0442\u044b \u0441 \u043e\u0431\u0449\u0438\u043c \u0411\u0414 (Commit + DELETE)<\/p>\n<\/li>\n<li>\n<p>database_fixed &#8212; \u0442\u0435\u0441\u0442\u044b \u0441 \u043e\u0431\u0449\u0438\u043c \u0411\u0414, \u043d\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 (ThreadLocal + rollback)<\/p>\n<\/li>\n<li>\n<p>filesystem_broken &#8212; \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043e\u0431\u0449\u0438\u0439 \u0444\u0430\u0439\u043b<\/p>\n<\/li>\n<li>\n<p>filesystem_fixed &#8212; \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c (ReentrantLock + FileLock)<\/p>\n<\/li>\n<\/ol>\n<h4>4 \u0440\u0435\u0436\u0438\u043c\u0430<\/h4>\n<ol>\n<li>\n<p>Sequential &#8212; 1 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, 1 \u043f\u043e\u0442\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>JUnit Parallel &#8212; 1 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, 4 \u043f\u043e\u0442\u043e\u043a\u0430<\/p>\n<\/li>\n<li>\n<p>Gradle Parallel &#8212; 4 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, 1 \u043f\u043e\u0442\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>Hybrid 2&#215;2 &#8212; 2 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, 2 \u043f\u043e\u0442\u043e\u043a\u0430 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2ab\/8ec\/a40\/2ab8eca407d7c905dc31309327cb613b.png\" width=\"1300\" height=\"950\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/2ab\/8ec\/a40\/2ab8eca407d7c905dc31309327cb613b.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2ab\/8ec\/a40\/2ab8eca407d7c905dc31309327cb613b.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h3>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u0442\u0435\u0441\u0442\u044b<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f. \u0423 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0435\u0442 \u043e\u0431\u0449\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u0411\u0414, \u0444\u0430\u0439\u043b\u043e\u0432, \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u043a\u044d\u0448\u0435\u0439 \u0438 \u0442.\u043f.<\/p>\n<pre><code class=\"java\">public abstract class CleanTestTemplate {    protected static final long TEST_DURATION_MS = 6000;    @Test    void test01() throws InterruptedException {        Thread.sleep(TEST_DURATION_MS);    }    \/\/ ... test02-05}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u0435\u0441\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u044d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d. 50 \u0442\u0435\u0441\u0442\u043e\u0432. 300 \u0441\u0435\u043a\u0443\u043d\u0434 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<h4>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/h4>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0420\u0435\u0436\u0438\u043c<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0412\u0440\u0435\u043c\u044f<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Sequential<\/p>\n<\/td>\n<td>\n<p align=\"left\">302 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.00x<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">JUnit (1&#215;4)<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.80x<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Gradle (4&#215;1)<\/p>\n<\/td>\n<td>\n<p align=\"left\">91 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.29x<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Hybrid (2&#215;2)<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.78x<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 3.8x \u0438\u0437 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 4x. \u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c 95%. Gradle \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 JUnit \u0438 \u0413\u0438\u0431\u0440\u0438\u0434\u043d\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430 \u043d\u0430 ~12 \u0441\u0435\u043a\u0443\u043d\u0434. \u041f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a 4 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 JVM-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432.<\/p>\n<p>\u0412\u044b\u0432\u043e\u0434 \u0437\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0442\u0435\u0441\u0442\u044b \u043d\u0435 \u0434\u0435\u043b\u044f\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0439 JUnit Parallel.<\/p>\n<hr\/>\n<h3>\u0422\u0435\u0441\u0442\u044b \u0441 \u0411\u0414<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u0432\u0435\u0449\u0430\u043c.<\/p>\n<h4>\u0427\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0439\u0442\u0438 \u043d\u0435 \u0442\u0430\u043a?<\/h4>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430. \u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442:<\/p>\n<ol>\n<li>\n<p>\u0412\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0411\u0414 (INSERT)<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0435\u0441\u0442\u044c \u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0435 (SELECT count(*))<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043b\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 (\u0432 \u043c\u043e\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e Thread.sleep)<\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0435 (DELETE \u0432 <a class=\"mention\" href=\"\/users\/AfterEach\">@AfterEach<\/a>)<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e. \u041f\u043e\u0442\u043e\u043c \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u0438 \u043f\u0440\u0438\u0432\u0435\u0442:<\/p>\n<pre><code class=\"java\">@ExtendWith(NaiveDbSetup.class)public abstract class NaiveTestTemplate {    private void testUserOperation(int methodId) throws SQLException, InterruptedException {        int userId = getClassOffset() + methodId;        Connection conn = NaiveDbSetup.getConnection();        \/\/ \u0412\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (autoCommit=true -&gt; \u0441\u0440\u0430\u0437\u0443 \u0432\u0438\u0434\u0435\u043d \u0412\u0421\u0415\u041c)        insertUser(conn, userId, userName, balance);        \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c: \"\u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u044f \u0437\u0430\u043f\u0438\u0441\u044c\"        int totalUsers = NaiveDbSetup.countAllUsers(conn);        assertThat(totalUsers)                .as(\"\u041e\u0436\u0438\u0434\u0430\u0435\u043c &lt;= 1 \u0437\u0430\u043f\u0438\u0441\u044c, \u043d\u043e \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0435\u0441\u0442\u044b \u0443\u0436\u0435 \u0432\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0441\u0432\u043e\u0438\")                .isLessThanOrEqualTo(1);  \/\/ &lt;-- \u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0435        Thread.sleep(TEST_DURATION_MS);        \/\/ afterEach: DELETE... \u043d\u043e \u0443\u0436\u0435 \u043f\u043e\u0437\u0434\u043d\u043e    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 <code>autoCommit=true<\/code>. \u042d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 JDBC \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u041a\u0430\u0436\u0434\u044b\u0439 INSERT \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u0432\u0438\u0434\u0435\u043d \u0432\u0441\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u0430\u043c \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c. \u0422\u0435\u0441\u0442 \u0410 \u0432\u0441\u0442\u0430\u0432\u0438\u043b \u0437\u0430\u043f\u0438\u0441\u044c, \u0442\u0435\u0441\u0442 \u0411 \u0434\u0435\u043b\u0430\u0435\u0442 <code>SELECT count(*)<\/code> \u0438 \u0432\u0438\u0434\u0438\u0442 \u043d\u0435 \u043e\u0434\u043d\u0443 \u0437\u0430\u043f\u0438\u0441\u044c, \u0430 \u0434\u0432\u0435. Assert \u043f\u0430\u0434\u0430\u0435\u0442.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e32\/fdd\/734\/e32fdd7348a153d98c3d5c302045548e.png\" width=\"1060\" height=\"810\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/e32\/fdd\/734\/e32fdd7348a153d98c3d5c302045548e.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e32\/fdd\/734\/e32fdd7348a153d98c3d5c302045548e.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h4>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b broken-\u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f<\/h4>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0420\u0435\u0436\u0438\u043c<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0412\u0440\u0435\u043c\u044f<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Sequential<\/p>\n<\/td>\n<td>\n<p align=\"left\">302 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">50\/50 passed<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">JUnit (1&#215;4)<\/p>\n<\/td>\n<td>\n<p align=\"left\">7 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">49\/50 FAILED<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Gradle (4&#215;1)<\/p>\n<\/td>\n<td>\n<p align=\"left\">69 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">35-41\/50 FAILED<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Hybrid (2&#215;2)<\/p>\n<\/td>\n<td>\n<p align=\"left\">7 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">49\/50 FAILED<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412 Gradle \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u043f\u0430\u0432\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e. \u0427\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0443\u043f\u0430\u043b\u043e, \u0442\u0435\u043c \u0434\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0433\u043e\u043d. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e Gradle-\u0444\u043e\u0440\u043a\u0438 \u0438\u043c\u0435\u044e\u0442 \u043f\u043e\u043b\u043d\u0443\u044e \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0447\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0438.<\/p>\n<h4>\u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044f<\/h4>\n<p>\u0414\u0430, \u0411\u0414 \u0443 \u043d\u0430\u0441 \u043e\u0434\u043d\u0430, \u043d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0435\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0442\u0435\u0441\u0442\u0430. \u041d\u0438\u043a\u0442\u043e \u043d\u0435 \u0432\u0438\u0434\u0438\u0442 \u0447\u0443\u0436\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u043d\u0435 \u0437\u0430\u043a\u043e\u043c\u043c\u0438\u0447\u0435\u043d\u044b.<\/p>\n<pre><code class=\"java\">public class TransactionalDbSetup        implements BeforeAllCallback, BeforeEachCallback, AfterEachCallback {    private static final ThreadLocal&lt;Connection&gt; threadLocalConnection = new ThreadLocal&lt;&gt;();    @Override    public void beforeEach(ExtensionContext context) throws Exception {        Connection conn = DriverManager.getConnection(DB_URL);        conn.setAutoCommit(false);  \/\/ \u041d\u0430\u0447\u0430\u043b\u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438        threadLocalConnection.set(conn);    }    @Override    public void afterEach(ExtensionContext context) throws Exception {        Connection conn = threadLocalConnection.get();        if (conn != null &amp;&amp; !conn.isClosed()) {            conn.rollback();  \/\/ \u041e\u0442\u043a\u0430\u0442 \u0432\u0441\u0435\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439            conn.close();            threadLocalConnection.remove();        }    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u0432\u044f\u0437\u043a\u0430 \u0438\u0437 <code>ThreadLocal&lt;Connection&gt;<\/code> \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0432\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, <code>setAutoCommit(false)<\/code> \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u0432\u0438\u0434\u043d\u044b \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f\u043c \u0434\u043e \u043a\u043e\u043c\u043c\u0438\u0442\u0430, \u0430 \u043a\u043e\u043c\u043c\u0438\u0442\u0430 \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, <code>rollback()<\/code> \u043f\u043e\u0441\u043b\u0435 \u0442\u0435\u0441\u0442\u0430 \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u0442\u043a\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u0411\u0414 \u0441\u043d\u043e\u0432\u0430 \u0447\u0438\u0441\u0442\u0430\u044f.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/67c\/a35\/0c5\/67ca350c5b1aafe697813f16730b5d7a.png\" width=\"1090\" height=\"890\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/67c\/a35\/0c5\/67ca350c5b1aafe697813f16730b5d7a.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/67c\/a35\/0c5\/67ca350c5b1aafe697813f16730b5d7a.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h4>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b transactional-\u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f<\/h4>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0420\u0435\u0436\u0438\u043c<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0412\u0440\u0435\u043c\u044f<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Sequential<\/p>\n<\/td>\n<td>\n<p align=\"left\">302 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.00x<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">JUnit (1&#215;4)<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.80x<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Gradle (4&#215;1)<\/p>\n<\/td>\n<td>\n<p align=\"left\">92 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.29x<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Hybrid (2&#215;2)<\/p>\n<\/td>\n<td>\n<p align=\"left\">80 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.78x<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412\u0441\u0435 50 \u0442\u0435\u0441\u0442\u043e\u0432, \u0432\u0441\u0435 3 \u043f\u0440\u043e\u0433\u043e\u043d\u0430, \u0432\u0441\u0435 4 \u0440\u0435\u0436\u0438\u043c\u0430 &#8212; \u043f\u0440\u043e\u0448\u043b\u0438. \u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0430\u043a\u043e\u0435 \u0436\u0435, \u043a\u0430\u043a \u043d\u0430 \u0447\u0438\u0441\u0442\u044b\u0445 \u0442\u0435\u0441\u0442\u0430\u0445.<\/p>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0432\u043c\u0435\u0441\u0442\u043e \u0440\u0443\u0447\u043d\u043e\u0433\u043e <code>ThreadLocal<\/code> + <code>rollback<\/code> \u0447\u0430\u0449\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <code>@Transactional<\/code> \u043e\u0442 Spring Boot (\u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0442\u043e\u0442 \u0436\u0435 <code>setAutoCommit(false)<\/code> + <code>rollback()<\/code>, \u043d\u043e \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u043e) \u0438\u043b\u0438 Testcontainers \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0411\u0414 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441.<\/p>\n<hr\/>\n<h3>\u0422\u0435\u0441\u0442\u044b \u0441 \u0444\u0430\u0439\u043b\u043e\u043c<\/h3>\n<p>\u0421 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0432\u0441\u0451 \u0445\u0443\u0436\u0435, \u0447\u0435\u043c \u0441 \u0411\u0414. \u0422\u0443\u0442 \u043d\u0435\u0442 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439, \u043d\u0435\u0442 <code>rollback<\/code>, \u043d\u0435\u0442 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 &#8212; \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0442\u044f\u0442 \u0432 \u043d\u0435\u0433\u043e \u0447\u0442\u043e-\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c.<\/p>\n<h4>\u041f\u0438\u0448\u0435\u043c \u0432 \u0444\u0430\u0439\u043b \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e<\/h4>\n<pre><code class=\"java\">public class UnsafeFileWriter {    private static final Path BROKEN_FILE =            Paths.get(\"build\/test-results\/broken_output.json\");    public static void write(String content) throws IOException {        writesAttempted.incrementAndGet();        try (BufferedWriter writer = Files.newBufferedWriter(                BROKEN_FILE, StandardOpenOption.APPEND)) {            writer.write(content + System.lineSeparator());  \/\/ Race condition        }    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0442 \u0444\u0430\u0439\u043b \u043d\u0430 \u0434\u043e\u0437\u0430\u043f\u0438\u0441\u044c. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0442\u0435\u0440\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438 \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h4>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e flaky \u043d\u0430 \u0440\u043e\u0432\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435<\/h4>\n<p>\u0415\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 filesystem_broken + JUnit \u0437\u0430 9 \u043f\u0440\u043e\u0433\u043e\u043d\u043e\u0432.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041f\u0440\u043e\u0433\u043e\u043d<\/p>\n<\/th>\n<th>\n<p align=\"left\">JUnit<\/p>\n<\/th>\n<th>\n<p align=\"left\">Gradle<\/p>\n<\/th>\n<th>\n<p align=\"left\">Hybrid<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">#1<\/p>\n<\/td>\n<td>\n<p align=\"left\">2\/3<\/p>\n<\/td>\n<td>\n<p align=\"left\">0\/3<\/p>\n<\/td>\n<td>\n<p align=\"left\">0\/3<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">#2<\/p>\n<\/td>\n<td>\n<p align=\"left\">3\/3<\/p>\n<\/td>\n<td>\n<p align=\"left\">0\/3<\/p>\n<\/td>\n<td>\n<p align=\"left\">0\/3<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">#3<\/p>\n<\/td>\n<td>\n<p align=\"left\">3\/3<\/p>\n<\/td>\n<td>\n<p align=\"left\">0\/3<\/p>\n<\/td>\n<td>\n<p align=\"left\">0\/3<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>Gradle \u0438 Hybrid \u043f\u0430\u0434\u0430\u044e\u0442 \u0432\u0441\u0435\u0433\u0434\u0430. JUnit \u043f\u0430\u0434\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0438\u0437 \u0434\u0435\u0432\u044f\u0442\u0438. \u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043b\u043e\u0436\u043d\u043e\u0435 \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0440\u0435\u0448\u0438\u0442, \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0435\u0441\u0442 \u0441\u0431\u043e\u0439\u043d\u0443\u043b, \u0432\u0435\u0434\u044c \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0435 8 \u0440\u0430\u0437 \u043e\u043d \u0431\u044b\u043b \u0437\u0435\u043b\u0435\u043d\u044b\u0439.<\/p>\n<p>\u0412\u044b\u0445\u043e\u0434\u0438\u0442 \u0447\u0442\u043e Gradle \u201c\u0447\u0435\u0441\u0442\u043d\u0435\u0435\u201d JUnit \u0438 \u0432\u044b\u044f\u0432\u043b\u044f\u0435\u0442 race condition \u0442\u0430\u043c, \u0433\u0434\u0435 JUnit \u0435\u0433\u043e \u043c\u0430\u0441\u043a\u0438\u0440\u0443\u0435\u0442.<\/p>\n<h4>\u041f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0435\u0448\u0438\u0442\u044c<\/h4>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0438 \u043f\u043e\u0442\u043e\u043a\u0438 \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438 \u0432\u0441\u0435 \u0432\u043f\u0435\u0440\u0435\u043c\u0435\u0448\u043a\u0443, \u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0434\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0439 JVM \u044d\u0442\u043e <code>ReentrantLock<\/code>, \u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 <code>FileLock<\/code>.<\/p>\n<pre><code class=\"java\">public class SafeFileWriter {    private static final ReentrantLock jvmLock = new ReentrantLock();    public static void write(String content) throws IOException {        jvmLock.lock();  \/\/ \u0423\u0440\u043e\u0432\u0435\u043d\u044c 1: \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438        try {            try (FileChannel channel = FileChannel.open(SAFE_FILE,                    StandardOpenOption.CREATE,                    StandardOpenOption.WRITE,                    StandardOpenOption.APPEND)) {                try (FileLock ignored = channel.lock()) {  \/\/ \u0423\u0440\u043e\u0432\u0435\u043d\u044c 2: \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438                    byte[] bytes = (content + System.lineSeparator())                            .getBytes(StandardCharsets.UTF_8);                    channel.write(ByteBuffer.wrap(bytes));                }            }            writesAttempted++;        } finally {            jvmLock.unlock();        }    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/708\/213\/7fe\/7082137fe667e5240c2f40a815f9e2ec.png\" width=\"1190\" height=\"870\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/708\/213\/7fe\/7082137fe667e5240c2f40a815f9e2ec.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/708\/213\/7fe\/7082137fe667e5240c2f40a815f9e2ec.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h4>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b fixed-\u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f<\/h4>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0420\u0435\u0436\u0438\u043c<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0412\u0440\u0435\u043c\u044f<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0426\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Sequential<\/p>\n<\/td>\n<td>\n<p align=\"left\">301 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.00x<\/p>\n<\/td>\n<td>\n<p align=\"left\">100%<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">JUnit (1&#215;4)<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.80x<\/p>\n<\/td>\n<td>\n<p align=\"left\">100%<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Gradle (4&#215;1)<\/p>\n<\/td>\n<td>\n<p align=\"left\">92 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.28x<\/p>\n<\/td>\n<td>\n<p align=\"left\">100%<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Hybrid (2&#215;2)<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.79x<\/p>\n<\/td>\n<td>\n<p align=\"left\">100%<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0422\u0443\u0442 \u0432\u0441\u0435 \u0447\u0451\u0442\u0435\u043d\u044c\u043a\u043e.<\/p>\n<hr\/>\n<h3>\u0418\u0442\u043e\u0433\u0438 \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0439<\/h3>\n<h4>\u0421\u0432\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 (\u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u043e\u043d, 60 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432)<\/h4>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0421\u0446\u0435\u043d\u0430\u0440\u0438\u0439<\/p>\n<\/th>\n<th>\n<p align=\"left\">Sequential<\/p>\n<\/th>\n<th>\n<p align=\"left\">JUnit (1&#215;4)<\/p>\n<\/th>\n<th>\n<p align=\"left\">Gradle (4&#215;1)<\/p>\n<\/th>\n<th>\n<p align=\"left\">Hybrid (2&#215;2)<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">base<\/p>\n<\/td>\n<td>\n<p align=\"left\">302 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441 \/ 3.80x<\/p>\n<\/td>\n<td>\n<p align=\"left\">91 \u0441 \/ 3.29x<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441 \/ 3.78x<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">database_broken<\/p>\n<\/td>\n<td>\n<p align=\"left\">302 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">FAIL (49\/50)<\/p>\n<\/td>\n<td>\n<p align=\"left\">FAIL (35-41\/50)<\/p>\n<\/td>\n<td>\n<p align=\"left\">FAIL (49\/50)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">database_transactional<\/p>\n<\/td>\n<td>\n<p align=\"left\">302 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441 \/ 3.80x<\/p>\n<\/td>\n<td>\n<p align=\"left\">92 \u0441 \/ 3.29x<\/p>\n<\/td>\n<td>\n<p align=\"left\">80 \u0441 \/ 3.78x<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">filesystem_broken<\/p>\n<\/td>\n<td>\n<p align=\"left\">302 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441 \/ flaky<\/p>\n<\/td>\n<td>\n<p align=\"left\">92 \u0441 \/ FAIL<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441 \/ FAIL<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">filesystem_fixed<\/p>\n<\/td>\n<td>\n<p align=\"left\">301 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441 \/ 3.80x<\/p>\n<\/td>\n<td>\n<p align=\"left\">92 \u0441 \/ 3.28x<\/p>\n<\/td>\n<td>\n<p align=\"left\">79 \u0441 \/ 3.79x<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d9b\/3ea\/b3c\/d9b3eab3c6c4a2a9036261d32ae57ce1.png\" width=\"1310\" height=\"674\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/d9b\/3ea\/b3c\/d9b3eab3c6c4a2a9036261d32ae57ce1.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d9b\/3ea\/b3c\/d9b3eab3c6c4a2a9036261d32ae57ce1.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h4>\u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h4>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0420\u0435\u0436\u0438\u043c<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u0440\u043e\u0433\u043e\u043d #1<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u0440\u043e\u0433\u043e\u043d #2<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u0440\u043e\u0433\u043e\u043d #3<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0420\u0430\u0437\u0431\u0440\u043e\u0441<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">JUnit<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.58-3.75x<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.70-3.80x<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.80x<\/p>\n<\/td>\n<td>\n<p align=\"left\">&lt;=0.05x<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Gradle<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.25-3.26x<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.27-3.29x<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.28-3.29x<\/p>\n<\/td>\n<td>\n<p align=\"left\">&lt;=0.04x<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Hybrid<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.73-3.75x<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.78-3.79x<\/p>\n<\/td>\n<td>\n<p align=\"left\">3.78-3.80x<\/p>\n<\/td>\n<td>\n<p align=\"left\">&lt;=0.05x<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 \u0446\u0435\u043b\u043e\u043c \u0441\u0445\u043e\u0434\u044f\u0442\u0441\u044f. \u0420\u0430\u0437\u0431\u0440\u043e\u0441 \u043c\u0435\u0436\u0434\u0443 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0433\u043e\u043d\u0430\u043c\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439.<\/p>\n<h4>\u041a\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043b\u0443\u0448\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c?<\/h4>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0421\u0446\u0435\u043d\u0430\u0440\u0438\u0439<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u043e\u0447\u0435\u043c\u0443<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0427\u0438\u0441\u0442\u044b\u0435 unit-\u0442\u0435\u0441\u0442\u044b<\/p>\n<\/td>\n<td>\n<p align=\"left\">JUnit 5 (1&#215;4)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041c\u0438\u043d\u0438\u043c\u0443\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b<\/p>\n<\/td>\n<td>\n<p align=\"left\">Gradle (4&#215;1)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0418\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u043c\u0435\u0448\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">Hybrid 2&#215;2<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u0430\u043b\u0430\u043d\u0441 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0438 \u0437\u0430\u0442\u0440\u0430\u0442<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043c\u0430\u043b\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432<\/p>\n<\/td>\n<td>\n<p align=\"left\">Gradle (4&#215;1)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041c\u0430\u043b\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432<\/p>\n<\/td>\n<td>\n<p align=\"left\">JUnit (1&#215;4)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0415\u0441\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u0435\u0437 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0445\u0443\u0436\u0435<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<hr\/>\n<h3>\u0412\u044b\u0432\u043e\u0434\u044b<\/h3>\n<h4>\u0413\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430<\/h4>\n<p>\u0414\u0432\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u043e \u0434\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u044f\u043c \u043d\u0430 \u0432\u0441\u0435\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445. \u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u043a\u0430\u043a JUnit, \u043d\u043e \u043d\u0435 \u043c\u0430\u0441\u043a\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b. \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u0441\u0430\u043c\u044b\u0439 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440. \u0415\u0441\u043b\u0438 \u0447\u0442\u043e \u043c\u0435\u043d\u044f \u043f\u043e\u043f\u0440\u0430\u0432\u044f\u0442 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0445.<\/p>\n<p>\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c <code>parallel.enabled=true<\/code> \u044d\u0442\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u0441\u0435\u043a\u0443\u043d\u0434 10, \u0430 \u0432\u043e\u0442 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043a \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0443 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043d\u044f\u0442\u044c \u0442\u043e\u043d\u043d\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u043c.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0434\u043e \u043a\u043e\u043d\u0446\u0430. \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0442\u043e \u043c\u043e\u0433\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u044b \u043d\u0430\u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0438 \u0433\u0440\u0430\u0431\u0435\u043b\u044c \u043f\u0440\u0438 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0438 playwright \u0442\u0435\u0441\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u044b \u043f\u043e\u043b\u043d\u044b\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438, \u0442\u043e \u0442\u043e\u0436\u0435 \u043c\u0430\u044f\u043a\u043d\u0438\u0442\u0435 &#8212; \u0437\u0430\u043b\u044c\u044e \u0432 \u0440\u0435\u043f\u043a\u0443.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1025746\/\">https:\/\/habr.com\/ru\/articles\/1025746\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0420\u0430\u0437\u0440\u0430\u0431\u044b \u0432\u044b\u043a\u0430\u0442\u0438\u043b\u0438 \u0444\u0438\u043a\u0441 \u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0433\u043d\u0430\u0442\u044c \u0440\u0435\u0433\u0440\u0435\u0441\u0441 \u043d\u0430 \u0441\u0442\u0435\u043d\u0434\u0435. \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0448\u044c CI, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0448\u044c \u0442\u0435\u0441\u0442\u044b \u0438 \u0441\u043f\u0443\u0441\u0442\u044f \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043f\u0430\u0440\u0443 \u0447\u0430\u0441\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u0442\u0438\u043c \u043c\u044b \u0440\u0435\u043b\u0438\u0437 \u0438\u043b\u0438 \u043d\u0435\u0442. \u0414\u0435\u043f\u043b\u043e\u0439 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d, \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u0436\u0434\u0443\u0442 \u043c\u0435\u0440\u0434\u0436, \u0430 \u0442\u044b &#8212; \u0442\u0435\u0441\u0442\u044b. \u0410 \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0442\u044c \u0440\u0435\u0433\u0440\u0435\u0441\u0441 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432 \u0434\u0435\u043d\u044c?\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0441\u043e\u0432\u0435\u0442 \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 &#8212; \u201c\u0437\u0430\u043f\u0443\u0441\u0442\u0438 \u0442\u0435\u0441\u0442\u044b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u201d. \u041e\u043a\u0435\u0439, \u0430 \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c?\u0412 JUnit5 \u0441\u0432\u043e\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f. \u0412 Gradle &#8212; \u0441\u0432\u043e\u0439. \u0410 \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0418 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0441\u0435 \u0441\u043b\u043e\u043c\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0442\u0435\u0441\u0442\u044b \u043d\u0430\u0447\u043d\u0443\u0442 \u0433\u043e\u043d\u043a\u0443 \u0437\u0430 \u043e\u0431\u0449\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b.\u042f \u043f\u0440\u043e\u0432\u0451\u043b \u0441\u0435\u0440\u0438\u044e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432: 5 \u0432\u0438\u0434\u043e\u0432 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432, 4 \u0440\u0435\u0436\u0438\u043c\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430, 3 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u0435\u0440\u043d\u043e\u0441\u0442\u0438. \u0418\u0437\u043c\u0435\u0440\u044f\u043b \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c, \u043d\u043e \u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u201c\u043f\u0435\u0447\u0430\u0442\u0430\u044e \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e, \u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0435\u0440\u0443\u043d\u0434\u0430\u201d.\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u043a\u0430\u0436\u0443:\u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u0435\u043b\u043b\u0438\u0437\u043c \u0432 JUnit5 \u0438 Gradle (\u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432);\u0447\u0442\u043e \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u0431\u0435\u0437 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438;\u043a\u0430\u043a \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0411\u0414 \u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432;\u043a\u0430\u043a\u043e\u0439 \u0440\u0435\u0436\u0438\u043c \u0434\u0430\u0435\u0442 \u043b\u0443\u0447\u0448\u0438\u0439 \u0431\u0430\u043b\u0430\u043d\u0441 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u0438.\u0422\u043e\u043b\u044c\u043a\u043e JUnit5 + Gradle. \u0411\u0435\u0437 Maven, \u0431\u0435\u0437 TestNG, \u0431\u0435\u0437 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0438 CI-\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c.TL;DR\u0414\u043b\u044f \u0441\u0430\u043c\u044b\u0445 \u043d\u0435\u0442\u0435\u0440\u0435\u043f\u0435\u043b\u0438\u0432\u044b\u0445 &#8212; \u0441\u0432\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u041f\u0440\u043e\u0433\u043e\u043d 50 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u043e 6 \u0441\u0435\u043a\u0443\u043d\u0434 \u043a\u0430\u0436\u0434\u044b\u0439.\u0421\u0446\u0435\u043d\u0430\u0440\u0438\u0439\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043eJUnit (1&#215;4)Gradle (4&#215;1)Hybrid (2&#215;2)\u0427\u0438\u0441\u0442\u044b\u0435 \u0442\u0435\u0441\u0442\u044b302 \u044179 \u0441 (3.80x)91 \u0441 (3.29x)79 \u0441 (3.78x)\u0411\u0414 (\u0431\u0435\u0437 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439)302 \u04417 \u0441 (FAIL)69 \u0441 (FAIL)7 \u0441 (FAIL)\u0411\u0414 (\u0441 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u043c\u0438)302 \u044179 \u0441 (3.80x)92 \u0441 (3.29x)80 \u0441 (3.78x)\u0424\u0430\u0439\u043b\u044b (\u0431\u0435\u0437 \u0441\u0438\u043d\u0445\u0440.)302 \u044179 \u0441 (flaky)92 \u0441 (FAIL)79 \u0441 (FAIL)\u0424\u0430\u0439\u043b\u044b (\u0441 \u0441\u0438\u043d\u0445\u0440.)301 \u044179 \u0441 (3.80x)92 \u0441 (3.28x)79 \u0441 (3.79x)\u0415\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e:Hybrid 2&#215;2 (2 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 x 2 \u043f\u043e\u0442\u043e\u043a\u0430) &#8212; \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440. \u0421\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e ~3.8x \u043d\u0430 \u0432\u0441\u0435\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445.\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u0431\u0435\u0437 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 = \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0438\u043b\u0438, \u0447\u0442\u043e \u0445\u0443\u0436\u0435, \u0441\u043a\u0440\u044b\u0442\u0430\u044f \u043f\u043e\u0442\u0435\u0440\u044f \u0434\u0430\u043d\u043d\u044b\u0445.Gradle \u201c\u0447\u0435\u0441\u0442\u043d\u0435\u0435\u201d JUnit \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u0438 \u0447\u0430\u0449\u0435 \u043f\u0430\u0434\u0430\u0435\u0442, \u0442\u0430\u043c \u0433\u0434\u0435 JUnit \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u044f\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.\u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438, \u0442\u043e \u043f\u043e\u0435\u0445\u0430\u043b\u0438.\u041f\u043e\u0442\u043e\u043a\u0438 \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b: \u0434\u0432\u0430 \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043a\u0440\u0443\u0442\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043a\u0430\u043a \u044d\u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0432 Java-\u043c\u0438\u0440\u0435. \u041f\u0430\u0440\u0430\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0442\u0435\u0441\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u0434\u0432\u0443\u0445 \u0443\u0440\u043e\u0432\u043d\u044f\u0445, \u0438 \u043e\u043d\u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f.JUnit 5 Parallel Execution &#8212; \u043f\u043e\u0442\u043e\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0439 JVM. \u0422\u0435\u0441\u0442\u044b \u0436\u0438\u0432\u0443\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0434\u0435\u043b\u044f\u0442 \u043e\u0431\u0449\u0443\u044e \u043a\u0443\u0447\u0443 (heap) \u0438 \u0432\u0438\u0434\u044f\u0442 \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u0417\u0430\u0442\u0440\u0430\u0442\u044b \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435. \u041f\u043e\u0442\u043e\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0451\u0448\u0435\u0432\u043e, \u043d\u043e \u0438 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u0442\u043e\u0436\u0435 \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0435.Gradle maxParallelForks &#8212; \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 JVM-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b. Gradle \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 n-\u043a\u043e\u043f\u0438\u0439 Java-\u043c\u0430\u0448\u0438\u043d\u044b \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u043f\u043e\u0440\u0446\u0438\u044e \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041f\u043e\u043b\u043d\u0430\u044f \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a \u043a\u0430\u0436\u0434\u043e\u0439 JVM \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b.\u0413\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c &#8212; \u0441\u043e\u0432\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043a\u0438. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:[Gradle]\u251c\u2500\u2500 JVM-\u043f\u0440\u043e\u0446\u0435\u0441\u0441 #1 (maxParallelForks)\u2502   \u251c\u2500\u2500 JUnit-\u043f\u043e\u0442\u043e\u043a A \u2500\u2500\u2500 Test1.test1()\u2502   \u2514\u2500\u2500 JUnit-\u043f\u043e\u0442\u043e\u043a B \u2500\u2500\u2500 Test1.test2()\u2502\u2514\u2500\u2500 JVM-\u043f\u0440\u043e\u0446\u0435\u0441\u0441 #2    \u251c\u2500\u2500 JUnit-\u043f\u043e\u0442\u043e\u043a C \u2500\u2500\u2500 Test2.test1()    \u2514\u2500\u2500 JUnit-\u043f\u043e\u0442\u043e\u043a D \u2500\u2500\u2500 Test2.test2()\u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0438 \u043f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b. \u041d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044fJUnit (\u043f\u043e\u0442\u043e\u043a\u0438)Gradle (\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b)\u0418\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438\u041d\u0435\u0442\u041f\u043e\u043b\u043d\u0430\u044fStatic-\u043f\u043e\u043b\u044f\u041e\u0431\u0449\u0438\u0435\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 JVM\u0424\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u041e\u0431\u0449\u0430\u044f\u041e\u0431\u0449\u0430\u044f\u0411\u0414\u041e\u0431\u0449\u0430\u044f\u041e\u0431\u0449\u0430\u044f\u0417\u0430\u0442\u0440\u0430\u0442\u044b\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435\u0420\u0435\u0441\u0443\u0440\u0441\u044b \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a JVM\u041b\u0443\u0447\u0448\u0435 \u0434\u043b\u044f\u0427\u0438\u0441\u0442\u044b\u0445 unit-\u0442\u0435\u0441\u0442\u043e\u0432\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0442\u0435\u043e\u0440\u0438\u0438 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 JVM. \u0411\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0433\u0440\u0430\u0431\u0435\u043b\u044c.\u041f\u043e\u0442\u043e\u043a\u0438 \u0432 JVM &#8212; \u044d\u0442\u043e \u043f\u043e\u0442\u043e\u043a\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b\u041a\u0430\u0436\u0434\u044b\u0439 Thread \u0432 Java &#8212; \u044d\u0442\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u0432 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 (\u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c 1:1, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 HotSpot). \u041a\u043e\u0433\u0434\u0430 JUnit \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 4 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430, \u0442\u043e \u041e\u0421 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 4 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430 \u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u041e\u0421 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0438\u0445 \u043f\u043e \u044f\u0434\u0440\u0430\u043c CPU.\u041c\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c. \u0415\u0441\u043b\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0443 \u043d\u0430\u0441 \u044f\u0434\u0435\u0440 \u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432\u0441\u0435 \u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u044f\u0434\u0435\u0440, \u0442\u043e \u041e\u0421 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u041a\u0430\u0436\u0434\u043e\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u042d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043d\u0430\u0448\u0438 \u0437\u0430\u0442\u0440\u0430\u0442\u044b.\u041e\u0431\u0449\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c\u041f\u043e\u0442\u043e\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0439 JVM \u0434\u0435\u043b\u044f\u0442 \u043e\u0434\u043d\u0443 \u043a\u0443\u0447\u0443 (heap) \u0438 \u043e\u0434\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432 (Metaspace). \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0442\u0435\u043a\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0445 \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0439.Static-\u043f\u043e\u043b\u044f \u043e\u0431\u0449\u0438\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0415\u0441\u043b\u0438 \u043e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u043f\u0438\u0448\u0435\u0442 \u0432 static int counter, \u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u0432\u0438\u0434\u0438\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u041f\u0440\u0430\u0432\u0434\u0430 \u0431\u0435\u0437 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0439. Java Memory Model (JMM) \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 happens-before: \u0431\u0435\u0437 volatile, synchronized \u0438\u043b\u0438 Lock \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u043c. \u041d\u0430 x86 \u044d\u0442\u043e \u0441\u0442\u0440\u0435\u043b\u044f\u0435\u0442 \u0440\u0435\u0436\u0435 \u0442\u0430\u043a \u043a\u0430\u043a \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0438\u043c\u0435\u0435\u0442 \u0441\u0438\u043b\u044c\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u043e \u043d\u0430 ARM &#8212; \u0448\u0430\u043d\u0441\u044b \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u044e\u0442.\u0418 \u0435\u0449\u0435 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0447\u0430\u0441\u0442\u043e \u043f\u0443\u0442\u0430\u044e\u0442: Thread-safe != test-safe. AtomicInteger \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u0435\u043d, \u043d\u043e \u0435\u0441\u043b\u0438 \u0434\u0432\u0430 \u0442\u0435\u0441\u0442\u0430 \u043f\u0438\u0448\u0443\u0442 \u0432 \u043e\u0434\u0438\u043d \u0441\u0447\u0435\u0442\u0447\u0438\u043a, \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c. \u041f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0435\u0441\u0442\u044b \u0441 \u043d\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e.\u041f\u0440\u043e\u0446\u0435\u0441\u0441\u044b\u041a\u043e\u0433\u0434\u0430 Gradle \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 4 \u0444\u043e\u0440\u043a\u0430, \u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 java-\u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u043a\u0443\u0447\u0435\u0439, GC, JIT-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c, static-\u043f\u043e\u043b\u044f\u043c\u0438 \u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e\u043c \u0438\u043c\u0451\u043d \u043f\u043e\u0442\u043e\u043a\u043e\u0432.\u041e\u0431\u0449\u0438\u043c\u0438 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0438 \u0441\u0435\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 Gradle-\u0444\u043e\u0440\u043a\u0438 \u043d\u0435 \u0441\u0442\u0440\u0430\u0434\u0430\u044e\u0442 \u043e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 static-\u043f\u043e\u043b\u044f\u043c\u0438, \u043d\u043e \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u044f \u0437\u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0430\u0439\u043b\u0430\u043c \u0438\u043b\u0438 \u0411\u0414 \u043d\u0438\u043a\u0443\u0434\u0430 \u043d\u0435 \u0434\u0435\u0432\u0430\u0435\u0442\u0441\u044f.\u0417\u0430\u043a\u043e\u043d \u0410\u043c\u0434\u0430\u043b\u0430\u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043a\u043e\u043d\u043e\u043c \u0410\u043c\u0434\u0430\u043b\u0430:\u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 = 1 \/ (a + (1 &#8212; a) \/ p)\u0413\u0434\u0435 a &#8212; \u0434\u043e\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, p &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.\u0412 \u043c\u043e\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 Thread.sleep &#8212; \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u0443\u0435\u043c\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f (a = 0), \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c 4x \u043d\u0430 4 \u043f\u043e\u0442\u043e\u043a\u0430\u0445. \u0420\u0435\u0430\u043b\u044c\u043d\u043e \u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f 3.8x. \u041e\u0441\u0442\u0430\u0432\u0448\u0430\u044f\u0441\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u0430\u043a \u0440\u0430\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438: \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f JUnit, \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f Gradle, \u0440\u0430\u0431\u043e\u0442\u0430 GC.\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435: spring-\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0411\u0414, \u043f\u0440\u043e\u0433\u0440\u0435\u0432 \u043a\u044d\u0448\u0435\u0439 \u0438 \u0442.\u0434. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u0436\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0432 2-3x \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u044d\u0442\u043e \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u043f\u043e\u0431\u0435\u0434\u0430.\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e Thread.sleep\u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u044f \u0432\u044b\u0431\u0440\u0430\u043b \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u0443\u0434\u0430\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u0441\u0432\u043e\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445. \u041d\u043e \u043d\u0430 \u0434\u0435\u043b\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432 \u0432 \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0436\u0434\u0443\u0442 \u043e\u0442\u0432\u0435\u0442\u0430 \u043e\u0442 \u0411\u0414, \u043e\u0442 HTTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043e\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. Thread.sleep \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435: \u043f\u043e\u0442\u043e\u043a \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d, \u044f\u0434\u0440\u043e CPU \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0431\u0435\u0437 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u0438.\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u0432 JUnit 5\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 JUnit 5 \u043d\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a.\u0424\u0430\u0439\u043b src\/test\/resources\/junit-platform.properties:junit.jupiter.execution.parallel.enabled=truejunit.jupiter.execution.parallel.mode.default=concurrentjunit.jupiter.execution.parallel.config.strategy=fixedjunit.jupiter.execution.parallel.config.fixed.parallelism=4\u0427\u0435\u0442\u044b\u0440\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0438 \u0442\u0435\u0441\u0442\u044b \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432 4 \u043f\u043e\u0442\u043e\u043a\u0430. mode.default=concurrent \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0415\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u0430\u0441\u0441\u044b, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:junit.jupiter.execution.parallel.mode.default=same_threadjunit.jupiter.execution.parallel.mode.classes.default=concurrent\u0414\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e @Execution(CONCURRENT) \u0438\u043b\u0438 @Execution(SAME_THREAD).\u0412 \u0441\u0432\u043e\u0435\u043c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 JUnit \u043f\u0435\u0440\u0435\u0434\u0430\u044e \u0447\u0435\u0440\u0435\u0437 systemProperties \u0432 build.gradle. \u0422\u0430\u043a \u0431\u044b\u043b\u043e \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 Gradle-\u0437\u0430\u0434\u0430\u0447 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438, \u0447\u0435\u043c \u0445\u0430\u0440\u0434\u043a\u043e\u0434\u0438\u0442\u044c properties-\u0444\u0430\u0439\u043b\u044b \u0438 \u043f\u043e\u0434\u043a\u0438\u0434\u044b\u0432\u0430\u0442\u044c \u0438\u0445.\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u0432 GradleGradle \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c maxParallelForks. \u041e\u043d \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 JVM-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445.tasks.register(&#8216;testGradleParallel&#8217;, Test) {    useJUnitPlatform()    maxParallelForks = 4  \/\/ 4 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 JVM-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430    systemProperties = [        &#8216;junit.jupiter.execution.parallel.enabled&#8217;: &#8216;false&#8217;  \/\/ JUnit \u041d\u0415 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0442    ]}\u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u043d\u0435 \u043f\u0443\u0442\u0430\u0442\u044c maxParallelForks \u0441 \u0444\u043b\u0430\u0433\u043e\u043c &#8212;parallel. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0442 \u0441\u0431\u043e\u0440\u043a\u0443, \u0430 \u043d\u0435 \u0442\u0435\u0441\u0442\u044b. \u0414\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0444\u043b\u0430\u0433 &#8212;parallel \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0430\u0441\u0442.\u041a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c\u0422\u0443\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0431\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u043c\u0435\u0441\u0442\u0435tasks.register(&#8216;testHybrid2x2&#8217;, Test) {    useJUnitPlatform()    maxParallelForks = 2  \/\/ 2 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430    systemProperties = [        &#8216;junit.jupiter.execution.parallel.enabled&#8217;                  : &#8216;true&#8217;,        &#8216;junit.jupiter.execution.parallel.mode.default&#8217;             : &#8216;concurrent&#8217;,        &#8216;junit.jupiter.execution.parallel.mode.classes.default&#8217;     : &#8216;concurrent&#8217;,        &#8216;junit.jupiter.execution.parallel.config.strategy&#8217;          : &#8216;fixed&#8217;,        &#8216;junit.jupiter.execution.parallel.config.fixed.parallelism&#8217; : &#8216;2&#8217;  \/\/ 2 \u043f\u043e\u0442\u043e\u043a\u0430 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c    ]    \/\/ \u0418\u0442\u043e\u0433\u043e: 2 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 x 2 \u043f\u043e\u0442\u043e\u043a\u0430 = 4 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430}\u041c\u0435\u0442\u043e\u0434\u0438\u043a\u0430 \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0439\u0427\u0442\u043e \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u043c50 \u0442\u0435\u0441\u0442\u043e\u0432 (10 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 x 5 \u043c\u0435\u0442\u043e\u0434\u043e\u0432), \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 Thread.sleep(6000) \u2014 \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044f 6 \u0441\u0435\u043a\u0443\u043d\u0434 \u0440\u0430\u0431\u043e\u0442\u044b.\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f: 50 x 6 = 300 \u0441\u0435\u043a\u0443\u043d\u0434 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e.3 \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430, \u0431\u0435\u0440\u0451\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435. \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0430\u0437\u0431\u0440\u043e\u0441 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0433\u043e\u043d\u0430\u043c\u0438.\u041d\u0430 \u0447\u0435\u043c \u0433\u043e\u043d\u044f\u0435\u043c\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043c\u043e\u044f \u043c\u0430\u0448\u0438\u043d\u043a\u0430 \u044d\u0442\u043e HP ProBook 430 G8.OS:     ALT Workstation K 11.2 (Nemorosa) x86_64Kernel: Linux 6.12.74-6.12-alt1CPU:    11th Gen Intel(R) Core(TM) i7-1165G7 (8) @ 4.70 GHzMemory: 15.31 GiBJava:   21.0.10 (OpenJDK)Gradle: 8.105 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432base &#8212; \u0447\u0438\u0441\u0442\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0431\u0435\u0437 \u043e\u0431\u0449\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432database_broken &#8212; \u0442\u0435\u0441\u0442\u044b \u0441 \u043e\u0431\u0449\u0438\u043c \u0411\u0414 (Commit + DELETE)database_fixed &#8212; \u0442\u0435\u0441\u0442\u044b \u0441 \u043e\u0431\u0449\u0438\u043c \u0411\u0414, \u043d\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 (ThreadLocal + rollback)filesystem_broken &#8212; \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043e\u0431\u0449\u0438\u0439 \u0444\u0430\u0439\u043bfilesystem_fixed &#8212; \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c (ReentrantLock + FileLock)4 \u0440\u0435\u0436\u0438\u043c\u0430Sequential &#8212; 1 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, 1 \u043f\u043e\u0442\u043e\u043aJUnit Parallel &#8212; 1 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, 4 \u043f\u043e\u0442\u043e\u043a\u0430Gradle Parallel &#8212; 4 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, 1 \u043f\u043e\u0442\u043e\u043aHybrid 2&#215;2 &#8212; 2 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, 2 \u043f\u043e\u0442\u043e\u043a\u0430 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u0442\u0435\u0441\u0442\u044b\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f. \u0423 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0435\u0442 \u043e\u0431\u0449\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u0411\u0414, \u0444\u0430\u0439\u043b\u043e\u0432, \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u043a\u044d\u0448\u0435\u0439 \u0438 \u0442.\u043f.public abstract class CleanTestTemplate {    protected static final long TEST_DURATION_MS = 6000;    @Test    void test01() throws InterruptedException {        Thread.sleep(TEST_DURATION_MS);    }    \/\/ &#8230; test02-05}\u0414\u0435\u0441\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u044d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d. 50 \u0442\u0435\u0441\u0442\u043e\u0432. 300 \u0441\u0435\u043a\u0443\u043d\u0434 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e.\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b\u0420\u0435\u0436\u0438\u043c\u0412\u0440\u0435\u043c\u044f\u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435Sequential302 \u04411.00xJUnit (1&#215;4)79 \u04413.80xGradle (4&#215;1)91 \u04413.29xHybrid (2&#215;2)79 \u04413.78x\u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 3.8x \u0438\u0437 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 4x. \u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c 95%. Gradle \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 JUnit \u0438 \u0413\u0438\u0431\u0440\u0438\u0434\u043d\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430 \u043d\u0430 ~12 \u0441\u0435\u043a\u0443\u043d\u0434. \u041f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a 4 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 JVM-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432.\u0412\u044b\u0432\u043e\u0434 \u0437\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0442\u0435\u0441\u0442\u044b \u043d\u0435 \u0434\u0435\u043b\u044f\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0442\u043e &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-476700","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/476700","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=476700"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/476700\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=476700"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=476700"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=476700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}