{"id":303317,"date":"2020-05-10T15:00:22","date_gmt":"2020-05-10T15:00:22","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=303317"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=303317","title":{"rendered":"\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 Kotlin \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Spock"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/489562\/\">\u0426\u0435\u043b\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Spock \u0441 Kotlin, \u043a\u0430\u043a\u0438\u0435 \u0435\u0441\u0442\u044c \u043f\u0443\u0442\u0438 \u0438\u0445 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441, \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Spock, \u0435\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0435 \u043d\u0430 Kotlin. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u042f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%AD%D0%BA%D1%81%D1%82%D1%80%D0%B5%D0%BC%D0%B0%D0%BB%D1%8C%D0%BD%D0%BE%D0%B5_%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5\" rel=\"nofollow\">\u044d\u043a\u0441\u0442\u0440\u0435\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/a>. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0440\u0438\u0451\u043c\u043e\u0432 \u044d\u043a\u0441\u0442\u0440\u0435\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A0%D0%B0%D0%B7%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%BA%D0%B0_%D1%87%D0%B5%D1%80%D0%B5%D0%B7_%D1%82%D0%B5%D1%81%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5\" rel=\"nofollow\">TDD<\/a> (test-driven development). \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u043e\u0434, \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u044b \u0438 \u0438\u043c\u0435\u0435\u043c \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u043a\u043e\u0434\u0430 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0431\u043b\u0438\u0437\u043a\u043e\u0435 \u043a 100%. \u042d\u0442\u043e \u043f\u0440\u0435\u0434\u044a\u044f\u0432\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0432\u044b\u0431\u043e\u0440\u0443 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0430: \u043e\u0434\u043d\u043e \u0434\u0435\u043b\u043e \u2014 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u0440\u0430\u0437 \u0432 \u043d\u0435\u0434\u0435\u043b\u044e, \u0441\u043e\u0432\u0441\u0435\u043c \u0434\u0440\u0443\u0433\u043e\u0435 \u2014 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c.<\/p>\n<p>  \u041c\u044b \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043d\u0430 Kotlin \u0438 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 Spock. \u0421 \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u043e\u0448\u043b\u043e \u043e\u043a\u043e\u043b\u043e 6 \u043c\u0435\u0441\u044f\u0446\u0435\u0432, \u0447\u0443\u0432\u0441\u0442\u0432\u043e \u044d\u0439\u0444\u043e\u0440\u0438\u0438 \u0438 \u043d\u043e\u0432\u0438\u0437\u043d\u044b \u043f\u0440\u043e\u0448\u043b\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u0440\u0435\u0442\u0440\u043e\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043e\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0441 \u043a\u0430\u043a\u0438\u043c\u0438 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0437\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0438 \u043a\u0430\u043a \u043c\u044b \u0438\u0445 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u043b\u0438.<\/p>\n<h2>\u041f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e Spock?<\/h2>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ud\/fs\/pl\/udfsplifoxjgfj0dchghvg3phfw.png\"><\/p>\n<p>  \u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a\u0438\u0435 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c Kotlin \u0438 \u043a\u0430\u043a\u0438\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0434\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e Spock \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043d\u0438\u043c\u0438. <\/p>\n<p>  \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432 Kotlin \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0441 Java, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u044e\u0431\u044b\u0435 Java \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <a href=\"https:\/\/junit.org\/junit5\/\" rel=\"nofollow\">Junit<\/a>, <a href=\"https:\/\/testng.org\/doc\/\" rel=\"nofollow\">TestNG<\/a>, <a href=\"http:\/\/spockframework.org\/\" rel=\"nofollow\">Spock<\/a> \u0438 \u0442.\u0434. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0435\u0441\u0442\u044c \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f Kotlin \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <a href=\"https:\/\/www.spekframework.org\/\" rel=\"nofollow\">Spek<\/a> \u0438 <a href=\"https:\/\/github.com\/kotest\/kotest\" rel=\"nofollow\">Kotest<\/a>. \u041f\u043e\u0447\u0435\u043c\u0443 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0438\u043c\u0435\u0435\u043d\u043e Spock?<\/p>\n<p>  \u042f \u0431\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430:<\/p>\n<ul>\n<li>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, Spock \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 Groovy. \u0425\u043e\u0440\u043e\u0448\u043e \u044d\u0442\u043e \u0438\u043b\u0438 \u043f\u043b\u043e\u0445\u043e \u2014 \u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0430\u043c\u0438. \u041f\u0440\u043e Groovy \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0435\u0439\u043a\u0443 \u0432\u043e\u0442 <a href=\"https:\/\/habr.com\/ru\/post\/122127\/\">\u0442\u0443\u0442<\/a>. \u041b\u0438\u0447\u043d\u043e \u043c\u0435\u043d\u044f \u0432 Groovy \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438, \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0438 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0441\u0443\u043c\u0430\u0441\u0448\u0435\u0434\u0448\u0438\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432. <\/li>\n<li>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, Spock \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 mock-\u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a (MockingApi) \u0438 assertion-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443;   <\/li>\n<li>\u0415\u0449\u0435 Spock \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"kotlin\">def &quot;maximum of two numbers&quot;() {     expect:     Math.max(a, b) == c      where:     a | b | c     1 | 3 | 3     7 | 4 | 7     0 | 0 | 0   } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 (\u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c), \u043d\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u044b, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 Spock. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043d\u0435\u0434\u0435\u043b\u0438 \u0438 \u043c\u0435\u0441\u044f\u0446\u044b \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044f\u043c\u0438.<\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 Kotlin \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Spock \u0438 \u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h2>\n<p>  \u0422\u0443\u0442 \u044f \u0441\u0440\u0430\u0437\u0443 \u043e\u0433\u043e\u0432\u043e\u0440\u044e\u0441\u044c, \u0447\u0442\u043e <b>\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0438\u0436\u0435, \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u043b\u044f Spock, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e Java-\u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u043e\u043d\u0438, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u0441 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0441 Kotlin<\/b>.<\/p>\n<h3>1. final \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/h3>\n<p>   <i>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/i><\/p>\n<p>  \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 Java, \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b Kotlin \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u043c\u0435\u044e\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <code>final<\/code>, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0442\u0443\u0442 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 mock-\u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e mock-\u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c proxy-\u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u044f\u0435\u0442 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u044b. <\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441:  <\/p>\n<pre><code class=\"kotlin\">class CustomerService {     fun getCustomer(id: String): Customer {         \/\/ Some logic     } } <\/code><\/pre>\n<p>  \u0438 \u0432\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c mock \u044d\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0432 Groovy:  <\/p>\n<pre><code class=\"plaintext\">def customerServiceMock = Mock(CustomerService) <\/code><\/pre>\n<p>  , \u0442\u043e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043e\u0448\u0438\u0431\u043a\u0443:  <\/p>\n<pre><code class=\"plaintext\">org.spockframework.mock.CannotCreateMockException: Cannot create mock for class CustomerService because Java mocks cannot mock final classes <\/code><\/pre>\n<p>  <i>\u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/i>   <\/p>\n<ul>\n<li> \u041f\u0435\u0440\u0432\u044b\u043c, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0443\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <code>open<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0434\u0440\u0443\u0433\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u0430\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0434\u0430\u043d\u043d\u043e\u0433\u043e. \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u043c\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 \u00ab\u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0435\u043d\u0438\u0435\u00bb \u043a\u043e\u0434\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f; <\/li>\n<li> \u0412\u0442\u043e\u0440\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <a href=\"https:\/\/kotlinlang.ru\/docs\/reference\/compiler-plugins.html\" rel=\"nofollow\">all-open \u043f\u043b\u0430\u0433\u0438\u043d\u0430<\/a> \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430. \u042d\u0442\u043e\u0442 \u043f\u043b\u0430\u0433\u0438\u043d \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u0438\u0445 \u0447\u043b\u0435\u043d\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u042d\u0442\u043e\u0442 \u043f\u043b\u0430\u0433\u0438\u043d \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Spring Framework \u0438 Hibernate, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <a href=\"https:\/\/github.com\/cglib\/cglib\" rel=\"nofollow\">cglib<\/a>(Code Generation Library);<\/li>\n<li>\u0422\u0430\u043a\u0436\u0435, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0438\u0437 mock-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f Kotlin (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/mockk.io\/\" rel=\"nofollow\">mockk<\/a>). \u041e\u0434\u043d\u0430\u043a\u043e, \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u0442\u0430\u043a \u043a\u0430\u043a Spock \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 Spock MockingApi.<\/li>\n<\/ul>\n<h3>2. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/h3>\n<p>   <i>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/i><\/p>\n<p>  \u0412 Kotlin \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d \u043f\u0440\u0438 \u0435\u0451 \u0432\u044b\u0437\u043e\u0432\u0435. \u0422\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0431\u0430\u0439\u0442-\u043a\u043e\u0434 Java \u0442\u0435\u0440\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438 \u0438\u043c\u0435\u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 Kotlin \u0438\u0437 Spock \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <code>Customer<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0441 2-\u043c\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438 <code>email<\/code> \u0438 <code>name<\/code> \u0438 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438, \u0438\u043c\u0435\u044e\u0449\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<pre><code class=\"kotlin\">data class Customer(     val email: String,     val name: String,     val surname: String = &quot;&quot;,     val age: Int = 18,     val identifiers: List&lt;NationalIdentifier&gt; = emptyList(),     val addresses: List&lt;Address&gt; = emptyList(),     val paymentInfo: PaymentInfo? = null ) <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 Groovy Spock \u0442\u0435\u0441\u0442\u0435, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<pre><code class=\"plaintext\">new Customer(&quot;john.doe@gmail.com&quot;, &quot;John&quot;, &quot;&quot;, 18, [], [], null) <\/code><\/pre>\n<p>  <i>\u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/i>   <\/p>\n<ul>\n<li>\u041f\u0435\u0440\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <a href=\"https:\/\/kotlinlang.org\/api\/latest\/jvm\/stdlib\/kotlin.jvm\/-jvm-overloads\/index.html\" rel=\"nofollow\"><code>@JvmOverloads<\/code><\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/li>\n<li>\u0422\u0430\u043a\u0436\u0435, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 groovy \u043a\u043b\u0430\u0441\u0441 \u2014 \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"kotlin\">class ModelFactory {     static def getCustomer() {          new Customer(             &quot;john.doe@gmail.com&quot;,              &quot;John&quot;,              &quot;Doe&quot;,              18,              [nationalIdentifier],              [address],              paymentInfo         )      }      static def getAddress() { new Address(\/* arguments *\/) }      static def getNationalIdentifier() { new NationalIdentifier(\/* arguments *\/) }      static def getPaymentInfo() { new PaymentInfo(\/* arguments *\/) } } <\/code><\/pre>\n<h3>3. Java Reflection vs Kotlin Reflection<\/h3>\n<p>   \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0443\u0437\u043a\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u044c\u044e, \u043d\u043e <b>\u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e \u0432 \u0441\u0432\u043e\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445, \u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Groovy.<\/b> \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u043d\u043e\u0433\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0438, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0438\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438, \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438. \u0422\u0443\u0442-\u0442\u043e \u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  <i>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/i><\/p>\n<p>  \u041a\u043b\u0430\u0441\u0441\u044b \u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0430 Kotlin, \u043b\u043e\u0433\u0438\u043a\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0438 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0435\u0439 \u043d\u0430 Groovy. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0448\u0430\u043d\u0438\u043d\u0430 \u0438\u0437 Java Reflection API \u0438 Kotlin Reflection:<\/p>\n<p>  \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f Java \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 Kotlin:  <\/p>\n<pre><code class=\"plaintext\">def kotlinClass = new KClassImpl(clazz) <\/code><\/pre>\n<p>  \u0412\u044b\u0437\u043e\u0432 Kotlin extension-\u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043a\u0430\u043a \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432:  <\/p>\n<pre><code class=\"plaintext\">ReflectJvmMapping.getJavaType(property.returnType) <\/code><\/pre>\n<p>  \u0422\u0440\u0443\u0434\u043d\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u043a\u043e\u0434, \u0433\u0434\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0438\u043f\u044b Kotlin:  <\/p>\n<pre><code class=\"plaintext\">private static boolean isOfCollectionType(KProperty1&lt;Object, ?&gt; property) {     \/\/ Some logic } <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u043c-\u0442\u043e \u043d\u0435\u043f\u043e\u0441\u0438\u043b\u044c\u043d\u044b\u043c \u0438\u043b\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c. \u0412\u043e\u043f\u0440\u043e\u0441 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0449\u0435 \u043b\u0438 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Kotlin \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c extension-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0447\u0438\u0441\u0442\u044b\u0439 Kotlin Reflection??<\/p>\n<h3>4. Coroutines<\/h3>\n<p>  <b>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b, \u0442\u043e \u044d\u0442\u043e \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u043e\u0432\u043e\u0434 \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f \u043e \u0442\u043e\u043c, \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u043b\u0438 \u0432\u044b \u0432\u044b\u0431\u0440\u0430\u0442\u044c Kotlin \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/b><\/p>\n<p>  <i>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/i><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c <code>suspend<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u044e  <\/p>\n<pre><code class=\"kotlin\">suspend fun someSuspendFun() {     \/\/ Some logic } <\/code><\/pre>\n<p>  , \u0442\u043e \u043e\u043d\u0430 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"java\">public void someSuspendFun(Continuation&lt;? super Unit&gt; $completion) {     \/\/ Some logic } <\/code><\/pre>\n<p>  , \u0433\u0434\u0435 Continuation \u2014 \u044d\u0442\u043e Java-\u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b. \u0412\u043e\u0442 \u0442\u0443\u0442 \u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430? \u0422\u0430\u043a\u0436\u0435, \u0432 Groovy \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d <i>runBlocking<\/i>. \u0418 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u044f\u0441\u043d\u043e, \u043a\u0430\u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0441 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0430\u043c\u0438 \u0432 Spock.<\/p>\n<h2>\u0418\u0442\u043e\u0433\u0438<\/h2>\n<p>  \u0417\u0430 \u043f\u043e\u043b\u0433\u043e\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Spock \u043e\u043d \u043f\u0440\u0438\u043d\u0435\u0441 \u043d\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e, \u0447\u0435\u043c \u043f\u043b\u043e\u0445\u043e\u0433\u043e \u0438 \u043e \u0432\u044b\u0431\u043e\u0440\u0435 \u043c\u044b \u043d\u0435 \u0436\u0430\u043b\u0435\u0435\u043c: \u0442\u0435\u0441\u0442\u044b \u043b\u0435\u0433\u043a\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c, \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u2014 \u043e\u0434\u043d\u043e \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435. \u041b\u043e\u0436\u043a\u043e\u0439 \u0434\u0435\u0433\u0442\u044f \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044f, \u043d\u043e \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u043e \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445, \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0441 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0430\u043c\u0438. <\/p>\n<p>  \u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 Kotlin \u0441\u0442\u043e\u0438\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0437\u044b\u043a\u0430 \u0432\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 CRUD-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, Spock \u0431\u0443\u0434\u0435\u0442 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0438 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e? \u0422\u043e\u0433\u0434\u0430 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 <a href=\"https:\/\/www.spekframework.org\/\" rel=\"nofollow\">Spek<\/a> \u0438\u043b\u0438 <a href=\"https:\/\/github.com\/kotest\/kotest\" rel=\"nofollow\">Kotest<\/a>.<\/p>\n<p>  \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u0435\u0442 \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0442\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0432\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Spock \u0438 Kotlin \u2014 \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<h2>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>  <\/p>\n<ul>\n<li> <a href=\"http:\/\/spockframework.org\/\" rel=\"nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Spock <\/a><\/li>\n<li> <a href=\"https:\/\/groovy-lang.org\/\" rel=\"nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Groovy <\/a><\/li>\n<\/ul>\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\/post\/489562\/\"> https:\/\/habr.com\/ru\/post\/489562\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/489562\/\">\u0426\u0435\u043b\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Spock \u0441 Kotlin, \u043a\u0430\u043a\u0438\u0435 \u0435\u0441\u0442\u044c \u043f\u0443\u0442\u0438 \u0438\u0445 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441, \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Spock, \u0435\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0435 \u043d\u0430 Kotlin. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-303317","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/303317","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=303317"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/303317\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=303317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=303317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=303317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}