{"id":341510,"date":"2022-11-21T09:00:08","date_gmt":"2022-11-21T09:00:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=341510"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=341510","title":{"rendered":"<span>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u0431\u044b \u0434\u043b\u044f MockWebServer \u0432 Android-\u0442\u0435\u0441\u0442\u0430\u0445<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e52\/ec0\/611\/e52ec06112aad366794470ea39c4a097.png\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e52\/ec0\/611\/e52ec06112aad366794470ea39c4a097.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u043c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041d\u0438\u043a\u043e\u043b\u0430\u0439. \u041c\u043e\u044f \u0434\u043e\u043b\u0436\u043d\u043e\u0441\u0442\u044c \u0432 Delivery Club \u2014 QA Automation Engineer \u0432 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u044b \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0438 \u0445\u0440\u0430\u043d\u0438\u043c \u043e\u0442\u0432\u0435\u0442\u044b \u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u043f\u0440\u0438 UI-\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0443\u0440\u044c\u0435\u0440\u0441\u043a\u043e\u0433\u043e Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0442\u0440\u0443\u0434\u043d\u043e\u0434\u043e\u0441\u0442\u0438\u0436\u0438\u043c\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u0442\u0435\u0441\u0442\u0435, \u0438\u043b\u0438 \u0432\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u044e\u0442 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b, \u0438\u043b\u0438 \u0432\u044b \u0437\u0430\u0432\u0438\u0441\u0438\u0442\u0435 \u043e\u0442 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b? \u0418 \u0435\u0441\u043b\u0438 \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u044d\u0442\u043e, \u0442\u043e \u0443 \u0432\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u0441 \u043f\u043e\u0434\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u043c \u0431\u044d\u043a\u0435\u043d\u0434\u043e\u043c. \u041f\u0440\u043e\u0435\u043a\u0442\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f, \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 JSON-\u0444\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u0432\u0435\u0442\u043e\u0432, \u043d\u043e \u0443 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438, \u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0445. \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0431\u044d\u043a\u0435\u043d\u0434\u0430, \u043e\u043f\u0438\u0448\u0443 \u0438\u0445 \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438. \u041e\u0431\u0449\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c UI-\u0442\u0435\u0441\u0442\u043e\u0432, \u043c\u044b \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c.<\/p>\n<ol>\n<li>\n<p><a href=\"#theory\"><u>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#swap\"><u>\u0418\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u0432 Android-\u0442\u0435\u0441\u0442\u0430\u0445<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#dependencies\"><u>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#assets\"><u>\u0421\u0442\u0430\u0431\u044b \u0438\u0437 JSON-\u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#rawstrings\"><u>\u0421\u0442\u0430\u0431\u044b \u0438\u0437 Raw Strings<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#dto\"><u>\u0421\u0442\u0430\u0431\u044b \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#keyvalue\"><u>\u0421\u0442\u0430\u0431\u044b \u0438\u0437 Key Value<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#freestyle\"><u>\u0421\u0442\u0430\u0431\u044b \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#compare\"><u>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0431\u043e\u0432<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#summary\"><u>\u0412\u044b\u0432\u043e\u0434\u044b<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438<\/h2>\n<p><a class=\"anchor\" name=\"theory\" id=\"theory\"><\/a><\/p>\n<p>\u0420\u0430\u0437\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0443\u0431\u043b\u0435\u0440\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u0441\u0442\u0430\u0431\u044b \u0438 \u043c\u043e\u043a\u0438.\u00a0<\/p>\n<p><strong>Test doubles<\/strong> (\u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0443\u0431\u043b\u0435\u0440\u044b) \u2014 \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0434\u0443\u0431\u043b\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0440\u043e\u043b\u044f\u0445.<\/p>\n<p><strong>Stub<\/strong> (\u0441\u0442\u0430\u0431) \u2014 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0430\u044f \u0438 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u043d\u0430 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p><strong>Mock<\/strong> (\u043c\u043e\u043a) \u2014 \u0437\u0430\u043c\u0435\u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0430\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a \u043d\u0435\u0439, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432\u044b\u0437\u043e\u0432\u0430 \u0438 \u043f\u0440\u043e\u0447\u0435\u0435.<\/p>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u044f \u0440\u0435\u0448\u0438\u043b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0435 <strong>Mock<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u044b\u0445 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 <strong>Mock<\/strong>WebServer (\u043e\u0431 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0434\u0430\u043b\u0435\u0435). \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0438\u043c\u0435\u0442\u044c \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c <strong>Stub<\/strong> \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0430\u0432\u0442\u043e\u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u2014 \u0430\u0432\u0442\u043e\u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0435 \u0438\u043b\u0438 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435. \u0421\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0443\u0431\u043b\u0435\u0440\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0435\u0442\u0435\u0432\u0443\u044e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c \u0431\u0435\u0437 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0445\u0443\u0434\u0448\u0435\u043d\u0438\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u0442\u0435\u0441\u0442\u044b c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0443\u0431\u043b\u0435\u0440\u043e\u0432 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u043c\u0435\u043d\u043e\u0439 e2e-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e.<\/p>\n<h2>\u0418\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u0432 Android-\u0442\u0435\u0441\u0442\u0430\u0445<\/h2>\n<p><a class=\"anchor\" name=\"swap\" id=\"swap\"><\/a><\/p>\n<p>\u041c\u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0437\u0430\u0433\u043b\u0443\u0448\u0435\u043a \u0432 Android-\u0442\u0435\u0441\u0442\u0430\u0445:<\/p>\n<ul>\n<li>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0434\u043b\u044f MockWebServer, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043b\u0435\u0435 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 JSON \u0432 Assets.<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 JSON \u0432 Kotlin-\u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u043a\u0430\u043a Raw strings.<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0442\u0435\u043b\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 Map \u0438\u0437 Key Value, \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u043e\u0439 \u0432 JSON.<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0442\u0435\u043b\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 DTO \u043c\u043e\u0434\u0435\u043b\u0438, \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u043e\u0439 \u0432 JSON.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u0430\u0431-\u0441\u0435\u0440\u0432\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 Record and Playback (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, WireMock).<\/p>\n<\/li>\n<li>\n<p>\u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u0441\u0442\u0430\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438. \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0438\u0437 Swagger (Open API). \u0421\u0442\u0430\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a\u0430\u043a \u043f\u0440\u043e\u043a\u0441\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0447\u0430\u0441\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0430 \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0431\u044d\u043a\u0435\u043d\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u043a\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 HTTP-\u043a\u043b\u0438\u0435\u043d\u0442\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Retrofit). \u042d\u0442\u043e \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0447\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0441\u0445\u043e\u0436\u0435 \u0441 MockWebServer \u0438 WireMock.<\/p>\n<\/li>\n<\/ul>\n<h2>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h2>\n<p><a class=\"anchor\" name=\"dependencies\" id=\"dependencies\"><\/a><\/p>\n<h3>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/h3>\n<p>\u0421\u0435\u0442\u0435\u0432\u044b\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 Retrofit, \u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 JSON \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c kotlinx-serialization. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u043c\u0435\u043d\u044b \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d MockWebServer \u043e\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u0439 OkHttp\/Retrofit. \u042d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438\u043c\u0435\u0435\u0442 \u0440\u044f\u0434 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u0441\u0440\u0435\u0434\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u043c\u0435\u043d\u0430 \u043e\u0442\u0432\u0435\u0442\u043e\u0432. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Kaspresso.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432 build.gradle \u0438 \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c AndroidManifest, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u043d\u0435\u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u043e\u043c\u0443 HTTP.<\/p>\n<p>build.gradle <\/p>\n<pre><code class=\"java\">dependencies {    androidTestImplementation 'com.squareup.okhttp3:mockwebserver:x.x.x' }<\/code><\/pre>\n<p>network_security_config.xml \u0434\u043b\u044f <strong>debug<\/strong> \u0441\u0431\u043e\u0440\u043a\u0438<\/p>\n<pre><code class=\"xml\">&lt;network-security-config xmlns:tools=\"http:\/\/schemas.android.com\/tools\">    &lt;base-config        cleartextTrafficPermitted=\"true\"        tools:ignore=\"InsecureBaseConfiguration\"        >    &lt;\/base-config> &lt;\/network-security-config><\/code><\/pre>\n<p>AndroidManifest.xml\u00a0<\/p>\n<pre><code class=\"xml\">&lt;application    android:networkSecurityConfig=\"@xml\/network_security_config\" &lt;\/application><\/code><\/pre>\n<h3>DI-\u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f\u00a0<\/h3>\n<p>DI-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0434\u043b\u044f \u043d\u0443\u0436\u0434 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e\u043c\u0438\u043c\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e Application \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 Test Application. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u043f\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0438. \u041f\u043e\u043b\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/primechord\/stubwebserver\/pull\/1\/commits\/de68d451b8d45b0df0cacbe5984cc57b79257d85#diff-0b70724976d8bb03a57f492debdb70a028c796f50af4d7d35a55ecf0ba309e95\"><u>\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/u><\/a>.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 baseUrlProvider: <\/p>\n<pre><code class=\"kotlin\">Retrofit.Builder().baseUrl(baseUrlProvider.getUrl())<\/code><\/pre>\n<p>\u0433\u0434\u0435 \u0434\u043b\u044f Application \u0430\u0434\u0440\u0435\u0441 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c:<\/p>\n<pre><code class=\"kotlin\">override fun getUrl() = \"https:\/\/api.github.com\"<\/code><\/pre>\n<p>\u0430 \u0434\u043b\u044f Test Application \u0430\u0434\u0440\u0435\u0441 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438:<\/p>\n<pre><code class=\"kotlin\">override fun getUrl() = \"http:\/localhost:8080\"<\/code><\/pre>\n<p>\u041f\u043e\u0440\u0442 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u044f\u0432\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0435\u0441\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0441 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u044c\u044e.\u00a0<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430 AndroidJUnitRunner \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0432 \u043d\u0435\u043c \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 Test Application. \u0410 \u043d\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430 AndroidJUnitRunner \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u0441\u044b\u043b\u0430\u0435\u043c\u0441\u044f \u0432 build.gradle:<\/p>\n<pre><code class=\"kotlin\">@Suppress(\"unused\") class CustomTestRunner : AndroidJUnitRunner() {    override fun newApplication(cl: ClassLoader?, className: String?, context: Context?    ): Application {        return super.newApplication(cl, TestApplication::class.java.name, context)    } }<\/code><\/pre>\n<p>build.gradle <\/p>\n<pre><code class=\"java\">android { \u00a0\u00a0\u00a0defaultConfig { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0testInstrumentationRunner \"com.primechord.stubwebserver.application.CustomTestRunner\" \u00a0\u00a0\u00a0} }<\/code><\/pre>\n<h2>\u0421\u0442\u0430\u0431\u044b \u0438\u0437 JSON-\u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/h2>\n<p><a class=\"anchor\" name=\"assets\" id=\"assets\"><\/a><\/p>\n<p>\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u0432\u0435\u0442\u0430 endpoint\u2019\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0439, \u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0441 endpoint&#8217;\u0430\u043c\u0438 \u0438\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 production-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c: <a href=\"https:\/\/api.github.com\/users\/primechord\/repos\"><u>https:\/\/api.github.com\/users\/primechord\/repos<\/u><\/a>. \u041c\u043d\u043e\u0433\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0435\u0439 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432.<\/p>\n<h3>\u0423\u0442\u0438\u043b\u0438\u0442\u043d\u044b\u0439 \u043a\u043e\u0434<\/h3>\n<p>Dispatcher \u2014 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c MockWebServer, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.\u00a0<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0439 Dispatcher. \u0415\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043a\u043b\u044e\u0447\u0443 \u0438\u0437 Map, \u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442. \u0412 MockWebServer \u043e\u0442\u0432\u0435\u0442 \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u043b\u0430\u0441\u0441 MockResponse. \u0415\u0441\u043b\u0438 MockWebServer \u0443\u0432\u0438\u0434\u0438\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f Path, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u0442 \u0441\u0440\u0435\u0434\u0438 \u043a\u043b\u044e\u0447\u0435\u0439, \u0442\u043e \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u0434 404. \u0412 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044e endpoint&#8217;\u0430 (endsWith).<\/p>\n<pre><code class=\"kotlin\">fun createDispatcher(    mockResponsesMap: Map&lt;String, MockResponse?> ) = object : Dispatcher() {    override fun dispatch(request: RecordedRequest): MockResponse {        mockResponsesMap.forEach {            if (request.path?.endsWith(it.key) == true) {                return mockResponsesMap[it.key] ?: failNotFoundResponseMock()            }        }        return failNotFoundResponseMock()    } }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0432\u043e\u0436\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u0442\u0430\u0431\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c \u0442\u0435\u0441\u0442 \u0441 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 endpoint&#8217;\u0430\u0445.<\/p>\n<pre><code class=\"kotlin\">class MockUtils {    companion object {        const val SOME_REQUEST_PATH = \"\/api\/v1\/hello\/world\"        const val SOME_RESPONSE_FILE = \"hello\/world_pretty.json\"    }    val baseRequestResponseMap: HashMap&lt;String, MockResponse?> = hashMapOf(        SOME_REQUEST_PATH to successResponse(SOME_RESPONSE_FILE),    ) }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0442\u0435\u043b\u0430 \u043e\u0442\u0432\u0435\u0442\u0430:<\/p>\n<pre><code class=\"kotlin\">fun failNotFoundResponseMock(): MockResponse = \u00a0\u00a0\u00a0MockResponse() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.setResponseCode(HttpURLConnection.HTTP_NOT_FOUND)  fun successResponse(fileName: String): MockResponse = \u00a0\u00a0\u00a0MockResponse() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.setResponseCode(HttpURLConnection.HTTP_OK) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.setBody(jsonUtil.readJSONFromAsset(fileName))  fun successResponse(body: () -> String): MockResponse = \u00a0\u00a0\u00a0MockResponse() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.setResponseCode(HttpURLConnection.HTTP_OK) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.setBody(body.invoke())<\/code><\/pre>\n<p>\u041d\u0443 \u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0442\u0435\u0441\u0442\u043e\u0432:<\/p>\n<pre><code class=\"kotlin\">abstract class BaseTest(    protected val server: MockWebServer = MockWebServer(),    builder: Kaspresso.Builder = Kaspresso.Builder.simple {        beforeEachTest {            server.start(8080)        }        afterEachTest {            server.shutdown()        }    }, ) : TestCase(builder)<\/code><\/pre>\n<h3>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0435\u0441\u0442\u044b \u0438 \u0438\u0445 \u0441\u0442\u0430\u0431\u044b<\/h3>\n<h4>Assets \u0431\u0435\u0437 \u043e\u0431\u0435\u0440\u0442\u043a\u0438<\/h4>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u043f\u0440\u043e\u0441\u0442, \u0445\u043e\u0442\u044f \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u043e\u043b\u044c \u0443\u0433\u043e\u0434\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432 \u0431\u043b\u043e\u043a\u0435 when:<\/p>\n<pre><code class=\"kotlin\">@Test fun pureDispatcher() {    server.dispatcher = object : Dispatcher() {        val mockUtils = MockUtils()        override fun dispatch(request: RecordedRequest): MockResponse {            return when {                request.path?.contains(\"\/repos\") == true -> {                    mockUtils.successResponse {                        mockUtils.jsonUtil.readJSONFromAsset(\"repos.json\")                    }                }                else -> mockUtils.failNotFoundResponseMock()            }        }    }     \/\/ kaspresso code }<\/code><\/pre>\n<p>\u0410 \u0432\u043e\u0442 \u0431\u043e\u043b\u0435\u0435 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0443\u0442\u0438\u043b\u0438\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<pre><code class=\"kotlin\">private fun MockWebServer.mockRepos(reposResponseAsset: String) {    val mockUtils = MockUtils()    val requestResponseMap = mockUtils.baseRequestResponseMap    requestResponseMap[\"\/repos\"] = mockUtils.successResponse(reposResponseAsset)    dispatcher = mockUtils.createDispatcher(requestResponseMap) }  @Test fun withExtension() {    server.mockRepos(\"repos.json\")     \/\/ kaspresso code }<\/code><\/pre>\n<h4>\u041e\u0431\u0435\u0440\u0442\u043a\u0430 \u0434\u043b\u044f \u0443\u0440\u043e\u0432\u043d\u044f \u0442\u0435\u0441\u0442\u043e\u0432<\/h4>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f MockWebServer, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0434\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0442\u0435\u0441\u0442\u0430:<\/p>\n<pre><code class=\"kotlin\">fun MockWebServer.mockResponses(vararg pairs: Pair&lt;String, MockContainer>) {    val mockUtils = MockUtils()    val requestResponseMap = mockUtils.baseRequestResponseMap    for (pair in pairs) {        requestResponseMap[pair.first] = pair.second.getResponse()    }    dispatcher = mockUtils.createDispatcher(requestResponseMap) }  sealed interface MockContainer {    fun getResponse(): MockResponse }  class AnyContainer(private val mockResponse: MockResponse) : MockContainer {    override fun getResponse() = mockResponse }  class AssetContainer(private val fileName: String) : MockContainer {    override fun getResponse() = mockUtils.successResponse(fileName) }  class RawStringContainer(private val body: String) : MockContainer {    override fun getResponse() = mockUtils.successResponse { body } }  class ModelContainerClass&lt;T>(private val model: T, private val serializer: KSerializer&lt;T>) : MockContainer {    override fun getResponse() = mockUtils.successResponse { json.encodeToString(serializer, model) } }  class KeyValueContainer(private val params: Any) : MockContainer {    override fun getResponse() = mockUtils.successResponse { params.toJsonElement().toString() } }  @Suppress(\"TestFunctionName\") inline fun &lt;reified T> ModelContainer(model: T): ModelContainerClass&lt;T> =    ModelContainerClass(model, Json.serializersModule.serializer()) <\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 mockResponses \u0441\u043d\u043e\u0432\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 Dispatcher, \u0430 \u044d\u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0432 \u0442\u0435\u0441\u0442\u0435. \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u0448\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0439 \u0441\u0442\u0430\u0431 \u043f\u0440\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435.<\/p>\n<h4>\u0412\u0438\u0434\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043e\u0431\u0435\u0440\u0442\u043a\u0435<\/h4>\n<ul>\n<li>\n<p><strong>ModelContainer<\/strong> \u2014 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438, \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u043e\u0439 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u0442\u0435\u043b\u0430 \u043e\u0442\u0432\u0435\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>KeyValueContainer<\/strong> \u2014 \u0434\u043b\u044f Key-Value-\u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u0442\u0435\u043b\u0430 \u043e\u0442\u0432\u0435\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>RawStringContainer<\/strong> \u2014 \u0434\u043b\u044f \u0442\u0435\u043b\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 \u0432\u0438\u0434\u0435 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>AssetContainer<\/strong> \u2014 \u0434\u043b\u044f \u0442\u0435\u043b\u0430 \u043e\u0442\u0432\u0435\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 Assets.<\/p>\n<\/li>\n<li>\n<p><strong>AnyContainer<\/strong> \u2014 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 MockResponse. \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043f\u0440\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432.<\/p>\n<\/li>\n<\/ul>\n<h4>Assets \u0443\u0436\u0435 \u0441 \u043e\u0431\u0435\u0440\u0442\u043a\u043e\u0439<\/h4>\n<p>\u0415\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c\u0438:<\/p>\n<pre><code class=\"kotlin\">@Test fun withAsset() {    server.mockResponses(        \"\/repos\" to AssetContainer(\"repos.json\"),    )     \/\/ kaspresso code }<\/code><\/pre>\n<h3>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:\u00a0<\/h3>\n<ul>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 Code Review JSON-\u0444\u0430\u0439\u043b\u044b \u043d\u0435\u0440\u0435\u0434\u043a\u043e \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0421\u0442\u0430\u0431\u044b \u0438\u0437 Raw Strings<\/h2>\n<p><a class=\"anchor\" name=\"rawstrings\" id=\"rawstrings\"><\/a><\/p>\n<p>\u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c JSON \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u043c\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0440\u043e\u0439\u043d\u044b\u043c\u0438 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a: &#171;&#187;&#187;{ }&#187;&#187;&#187;. \u0414\u0430\u043b\u0435\u0435 \u0442\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0432 JSON.\u00a0<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0432\u0430\u043c \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u044f\u0437\u044b\u043a\u0430 <a href=\"https:\/\/kotlinlang.org\/docs\/strings.html#string-templates\"><u>String templates<\/u><\/a> \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0440\u0435\u0434\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 <a href=\"https:\/\/www.jetbrains.com\/help\/idea\/using-language-injections.html\"><u>Language injections<\/u><\/a>.\u00a0<\/p>\n<p>\u0412 \u0442\u0435\u0441\u0442\u0430\u0445 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u0443\u0440\u044c\u0435\u0440\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0435 \u0431\u044b\u043b \u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043d, \u043d\u043e \u0435\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0438, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0435\u0433\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0442\u044b \u043a\u0430\u0440\u0442\u0438\u043d\u044b.<\/p>\n<h3>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0435\u0441\u0442\u044b \u0438 \u0438\u0445 \u0441\u0442\u0430\u0431\u044b<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/aa3\/d4c\/ad1\/aa3d4cad16a287846ee630db0be9f227.png\" width=\"1392\" height=\"862\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aa3\/d4c\/ad1\/aa3d4cad16a287846ee630db0be9f227.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0414\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430:\u00a0<\/h3>\n<ul>\n<li>\n<p>\u0415\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 Raw strings \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c IDE Language injections.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0444\u0438\u0447\u0430 String templates, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0434\u0430\u0442\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u00ab\u0441\u0442\u0430\u0440\u0430\u044f \u0434\u043e\u0431\u0440\u0430\u044f\u00bb String concatenation.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:\u00a0<\/h3>\n<ul>\n<li>\n<p>IDE \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u043b\u0435\u0436\u0430\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0438\u0437 \u0442\u044b\u0441\u044f\u0447 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0421\u0442\u0430\u0431\u044b \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0435\u0439\u00a0<\/h2>\n<p><a class=\"anchor\" name=\"dto\" id=\"dto\"><\/a><\/p>\n<h3>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0435\u0441\u0442\u044b \u0438 \u0438\u0445 \u0441\u0442\u0430\u0431\u044b<\/h3>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u0435\u0441\u0442\u0430\u0445:<\/p>\n<pre><code class=\"kotlin\">@Serializable data class RepoItem(    val owner: Owner,    @SerialName(\"private\")    val privateField: Boolean,    \/\/ \u2026 )<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043a\u0430\u043a \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0442\u0430\u043a \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u041f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u2014 <a href=\"https:\/\/plugins.jetbrains.com\/plugin\/9960-json-to-kotlin-class-jsontokotlinclass-\"><u>json-to-kotlin-class<\/u><\/a>. \u0414\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0444\u0430\u0439\u043b\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438 \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 Gradle.\u00a0<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0442\u043e \u043d\u0435 \u0434\u0443\u0431\u043b\u0438\u0440\u0443\u0435\u0442\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445. \u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438, \u0442\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0437\u0430\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0435\u0441\u044c \u043d\u0430 production-\u043a\u043e\u0434 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445. \u041e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043d\u0438\u0436\u0435 \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438, \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0434\u043b\u044f \u0432\u0430\u0441 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438.<\/p>\n<h4>\u0421 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h4>\n<pre><code class=\"kotlin\">@Test fun withProdModels() {    server.mockResponses(        \"\/repos\" to ModelContainer(            createReposItemsFromProductionModels(\"defaultLogin\")        ),    )     \/\/ kaspresso code }  private fun createReposItemsFromProductionModels(    ownerLogin: String ): List&lt;ProdRepoItem> {    return listOf(        ProdRepoItem(            owner = ProdOwner(                login = ownerLogin,                avatar_url = \"\",                \/\/ \u2026                ),            \/\/ \u2026        )    ) }<\/code><\/pre>\n<h4>\u0421\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438<\/h4>\n<pre><code class=\"kotlin\">@Test fun withGenModels() {    server.mockResponses( \/\/ \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0430\u0431\u043e\u0432        \"\/repos\" to ModelContainer( \/\/ \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430 \u0438\u0437 Path \u0438 \u0442\u0435\u043b\u0430 \u043e\u0442\u0432\u0435\u0442\u0430            listOf( \/\/ \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0442\u0435\u043b\u0435 \u043e\u0442\u0432\u0435\u0442\u0430                GenRepoItem( \/\/ \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u0442\u0435\u043b\u0435 \u043e\u0442\u0432\u0435\u0442\u0430                    owner = GenOwner( \/\/ \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0432 \u043d\u0435\u0433\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442                        \/\/ \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0435\u0435\u0441\u044f \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e                        \/\/ \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0435\u0433\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c                        login = \"expected text\"                    )                )            )        )    )     \/\/ kaspresso code }<\/code><\/pre>\n<h3>\u0414\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430:\u00a0<\/h3>\n<ul>\n<li>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c. \u0412\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c JSON \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>Data class \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0420\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430 \u0432 \u043c\u0435\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430. \u0422\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0443\u0436\u0435 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438 Code Review.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u043e\u043b\u044f\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0430\u0442\u044b. \u0413\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0432 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043f\u043e\u043b\u0435\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0430\u0431\u044b \u0438\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0438 \u043e\u043d\u0438 \u0441\u0430\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 (\u043d\u043e \u043d\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445):<\/h3>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u0434\u043b\u044f \u0441\u0442\u0430\u0431\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0435 \u0432 common-\u043c\u043e\u0434\u0443\u043b\u0435 \u0438 \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0435 \u043e\u0431\u0449\u0435\u0439, \u0442\u043e \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u0432 \u043c\u043e\u0434\u0443\u043b\u044c \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438. \u0410\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u043e\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0442\u044f\u0433\u043e\u0449\u0435\u043d\u0430 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u044f\u043c\u0438, \u0442\u043e \u0432\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0435\u0433\u043a\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c Data class \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 IDE-\u043f\u043b\u0430\u0433\u0438\u043d\u0430. \u041e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043e\u0432\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438 \u0432\u043d\u0435\u0441\u0442\u0438 \u043c\u0435\u043b\u043a\u0438\u0435 \u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043b\u0430\u0433\u0438\u043d \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0434\u0430\u0447\u043d\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442, \u0447\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0443 \u043f\u0440\u043e\u0449\u0435 \u0432\u0437\u044f\u0442\u044c JSON \u0432 Charles\/Fiddler, \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 Assets \u0438 \u043d\u0435 \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0445 \u0434\u043e\u043b\u0433\u043e\u0441\u0440\u043e\u0447\u043d\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u0432\u0435\u0442\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043a\u0440\u0443\u0433\u043b\u044b\u0445 \u0441\u043a\u043e\u0431\u043e\u043a \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u043c \u0432\u043f\u0440\u0430\u0432\u043e, \u0447\u0442\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0421\u0442\u0430\u0431\u044b \u0438\u0437 Key Value<\/h2>\n<p><a class=\"anchor\" name=\"keyvalue\" id=\"keyvalue\"><\/a><\/p>\n<p>\u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c JSON \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 Collection, Map \u0438 JsonPrimitive, \u0438 \u0434\u0430\u043b\u0435\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u0432 JSON. <\/p>\n<p>\u0412 \u0442\u0435\u0441\u0442\u0430\u0445 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u0443\u0440\u044c\u0435\u0440\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0435 \u0431\u044b\u043b \u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043d, \u043d\u043e \u0435\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0438, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u044f \u0442\u0430\u043a\u0436\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443 \u0435\u0433\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0442\u044b \u043a\u0430\u0440\u0442\u0438\u043d\u044b.<\/p>\n<p>\u0421 JsonElement \u0438\u0437 kotlinx.serialization \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443. \u042f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c <a href=\"https:\/\/github.com\/primechord\/stubwebserver\/blob\/main\/app\/src\/androidTest\/java\/com\/primechord\/stubwebserver\/stub\/JsonElementUtils.kt\"><u>\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435<\/u><\/a>.<\/p>\n<h3>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0435\u0441\u0442\u044b \u0438 \u0438\u0445 \u0441\u0442\u0430\u0431\u044b<\/h3>\n<pre><code class=\"kotlin\">@Test fun withKeyValue() {    server.mockResponses(        \"\/repos\" to KeyValueContainer(            createResponseBodyForRepos(login = \"expected text\")        )    )     \/\/ kaspresso code }  private fun createResponseBodyForRepos(login: String): List&lt;Map&lt;String, Any>> {    return listOf(        mapOf(            \"allow_forking\" to false,            \"archive_url\" to \"\",             \/\/ \u2026        )    ) }<\/code><\/pre>\n<h3>\u0414\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430:<\/h3>\n<ul>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0434\u0430\u0442\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u0431\u043e\u0432 \u0432 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 DSL.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/h3>\n<ul>\n<li>\n<p>\u0412\u0440\u0435\u043c\u044f\u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0421\u0442\u0430\u0431\u044b \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435<\/h2>\n<p><a class=\"anchor\" name=\"freestyle\" id=\"freestyle\"><\/a><\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0431\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 MockResponse. \u042d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438. \u0421\u043f\u043e\u0441\u043e\u0431 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0432\u043d\u0435 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f.\u00a0<\/p>\n<pre><code class=\"kotlin\">@Test fun withError() {    server.mockResponses(        \"\/repos\" to AnyContainer(            MockResponse()                .setResponseCode(500)        )    )     \/\/ kaspresso code }<\/code><\/pre>\n<h2>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0431\u043e\u0432<\/h2>\n<p><a class=\"anchor\" name=\"compare\" id=\"compare\"><\/a><\/p>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u044b\u0448\u0435 \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430\u043c\u0438 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u043c\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/96a\/bd7\/d73\/96abd7d73c36ce4f7a01e4dfc66239fb.png\" width=\"1468\" height=\"1022\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/96a\/bd7\/d73\/96abd7d73c36ce4f7a01e4dfc66239fb.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0438\u0436\u0435 \u044f \u0441\u0440\u0430\u0432\u043d\u0438\u043b \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438, \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430. \u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0438\u0441\u044c, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u043e \u043c\u043d\u0435\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u0440\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bc5\/85f\/faa\/bc585ffaaf2ad26e8a820f622990a7fc.png\" width=\"1556\" height=\"666\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bc5\/85f\/faa\/bc585ffaaf2ad26e8a820f622990a7fc.png\"\/><figcaption><\/figcaption><\/figure>\n<p><a class=\"anchor\" name=\"summary\" id=\"summary\"><\/a><\/p>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u0430\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u0431\u044b\u043b\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0430 \u0434\u043b\u044f \u043a\u0443\u0440\u044c\u0435\u0440\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Delivery Club. \u041e\u043d\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0431\u044b \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0444\u0430\u0439\u043b\u044b \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, raw strings \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 MockResponse. \u041f\u043e \u043c\u043e\u0435\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u043b\u044f \u0441\u0442\u0430\u0431\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c, \u043d\u043e, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b.<\/p>\n<p>\u0416\u0435\u043b\u0430\u044e\u0449\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 <a href=\"https:\/\/github.com\/primechord\/stubwebserver\/pull\/1\/commits\"><u>\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u043c<\/u><\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043e\u0434\u043d\u043e\u044d\u043a\u0440\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u043d\u0435\u0433\u043e, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<h3>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b:<\/h3>\n<ul>\n<li>\n<p><a href=\"https:\/\/youtu.be\/q_8UUhVDV7c?t=2583\"><u>\u041a\u0430\u043a \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0442\u0435\u0441\u0442\u044b \u0438 \u043d\u0435 \u0441\u043e\u0439\u0442\u0438 \u0441 \u0443\u043c\u0430<\/u><\/a><\/p>\n<\/li>\n<li>\n<p>\u200b\u200b<a href=\"https:\/\/habr.com\/ru\/company\/redmadrobot\/blog\/532306\/\"><u>\u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u0441\u0442\u0430\u0440\u0442: \u0433\u0430\u0439\u0434 \u043f\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0434\u043b\u044f Android-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. JVM<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/company\/maxilect\/blog\/430530\/\"><u>\u041c\u043e\u043a-\u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/JorgeCastilloPrz\/hiroaki\"><u>https:\/\/github.com\/JorgeCastilloPrz\/hiroaki<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/andrzejchm\/RESTMock\"><u>https:\/\/github.com\/andrzejchm\/RESTMock<\/u><\/a>\u00a0<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \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\/company\/deliveryclub\/blog\/700014\/\"> https:\/\/habr.com\/ru\/company\/deliveryclub\/blog\/700014\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u043c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041d\u0438\u043a\u043e\u043b\u0430\u0439. \u041c\u043e\u044f \u0434\u043e\u043b\u0436\u043d\u043e\u0441\u0442\u044c \u0432 Delivery Club \u2014 QA Automation Engineer \u0432 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u044b \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0438 \u0445\u0440\u0430\u043d\u0438\u043c \u043e\u0442\u0432\u0435\u0442\u044b \u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u043f\u0440\u0438 UI-\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0443\u0440\u044c\u0435\u0440\u0441\u043a\u043e\u0433\u043e Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0442\u0440\u0443\u0434\u043d\u043e\u0434\u043e\u0441\u0442\u0438\u0436\u0438\u043c\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u0442\u0435\u0441\u0442\u0435, \u0438\u043b\u0438 \u0432\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u044e\u0442 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b, \u0438\u043b\u0438 \u0432\u044b \u0437\u0430\u0432\u0438\u0441\u0438\u0442\u0435 \u043e\u0442 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b? \u0418 \u0435\u0441\u043b\u0438 \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u044d\u0442\u043e, \u0442\u043e \u0443 \u0432\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u0441 \u043f\u043e\u0434\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u043c \u0431\u044d\u043a\u0435\u043d\u0434\u043e\u043c. \u041f\u0440\u043e\u0435\u043a\u0442\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f, \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 JSON-\u0444\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u0432\u0435\u0442\u043e\u0432, \u043d\u043e \u0443 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438, \u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0445. \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0431\u044d\u043a\u0435\u043d\u0434\u0430, \u043e\u043f\u0438\u0448\u0443 \u0438\u0445 \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438. \u041e\u0431\u0449\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c UI-\u0442\u0435\u0441\u0442\u043e\u0432, \u043c\u044b \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c.<\/p>\n<ol>\n<li>\n<p><a href=\"#theory\"><u>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#swap\"><u>\u0418\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u0432 Android-\u0442\u0435\u0441\u0442\u0430\u0445<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#dependencies\"><u>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#assets\"><u>\u0421\u0442\u0430\u0431\u044b \u0438\u0437 JSON-\u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#rawstrings\"><u>\u0421\u0442\u0430\u0431\u044b \u0438\u0437 Raw Strings<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#dto\"><u>\u0421\u0442\u0430\u0431\u044b \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#keyvalue\"><u>\u0421\u0442\u0430\u0431\u044b \u0438\u0437 Key Value<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#freestyle\"><u>\u0421\u0442\u0430\u0431\u044b \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#compare\"><u>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0431\u043e\u0432<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#summary\"><u>\u0412\u044b\u0432\u043e\u0434\u044b<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438<\/h2>\n<p><a class=\"anchor\" name=\"theory\" id=\"theory\"><\/a><\/p>\n<p>\u0420\u0430\u0437\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0443\u0431\u043b\u0435\u0440\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u0441\u0442\u0430\u0431\u044b \u0438 \u043c\u043e\u043a\u0438.\u00a0<\/p>\n<p><strong>Test doubles<\/strong> (\u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0443\u0431\u043b\u0435\u0440\u044b) \u2014 \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0434\u0443\u0431\u043b\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0440\u043e\u043b\u044f\u0445.<\/p>\n<p><strong>Stub<\/strong> (\u0441\u0442\u0430\u0431) \u2014 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0430\u044f \u0438 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u043d\u0430 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p><strong>Mock<\/strong> (\u043c\u043e\u043a) \u2014 \u0437\u0430\u043c\u0435\u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0430\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a \u043d\u0435\u0439, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432\u044b\u0437\u043e\u0432\u0430 \u0438 \u043f\u0440\u043e\u0447\u0435\u0435.<\/p>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u044f \u0440\u0435\u0448\u0438\u043b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0435 <strong>Mock<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u044b\u0445 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 <strong>Mock<\/strong>WebServer (\u043e\u0431 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0434\u0430\u043b\u0435\u0435). \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0438\u043c\u0435\u0442\u044c \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c <strong>Stub<\/strong> \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0430\u0432\u0442\u043e\u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u2014 \u0430\u0432\u0442\u043e\u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0435 \u0438\u043b\u0438 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435. \u0421\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0443\u0431\u043b\u0435\u0440\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0435\u0442\u0435\u0432\u0443\u044e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c \u0431\u0435\u0437 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0445\u0443\u0434\u0448\u0435\u043d\u0438\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u0442\u0435\u0441\u0442\u044b c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0443\u0431\u043b\u0435\u0440\u043e\u0432 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u043c\u0435\u043d\u043e\u0439 e2e-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e.<\/p>\n<h2>\u0418\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u0432 Android-\u0442\u0435\u0441\u0442\u0430\u0445<\/h2>\n<p><a class=\"anchor\" name=\"swap\" id=\"swap\"><\/a><\/p>\n<p>\u041c\u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0437\u0430\u0433\u043b\u0443\u0448\u0435\u043a \u0432 Android-\u0442\u0435\u0441\u0442\u0430\u0445:<\/p>\n<ul>\n<li>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0434\u043b\u044f MockWebServer, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043b\u0435\u0435 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 JSON \u0432 Assets.<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 JSON \u0432 Kotlin-\u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u043a\u0430\u043a Raw strings.<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0442\u0435\u043b\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 Map \u0438\u0437 Key Value, \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u043e\u0439 \u0432 JSON.<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0442\u0435\u043b\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 DTO \u043c\u043e\u0434\u0435\u043b\u0438, \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u043e\u0439 \u0432 JSON.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u0430\u0431-\u0441\u0435\u0440\u0432\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 Record and Playback (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, WireMock).<\/p>\n<\/li>\n<li>\n<p>\u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u0441\u0442\u0430\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438. \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0438\u0437 Swagger (Open API). \u0421\u0442\u0430\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a\u0430\u043a \u043f\u0440\u043e\u043a\u0441\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0447\u0430\u0441\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0430 \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0431\u044d\u043a\u0435\u043d\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u043a\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 HTTP-\u043a\u043b\u0438\u0435\u043d\u0442\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Retrofit). \u042d\u0442\u043e \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0447\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0441\u0445\u043e\u0436\u0435 \u0441 MockWebServer \u0438 WireMock.<\/p>\n<\/li>\n<\/ul>\n<h2>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h2>\n<p><a class=\"anchor\" name=\"dependencies\" id=\"dependencies\"><\/a><\/p>\n<h3>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/h3>\n<p>\u0421\u0435\u0442\u0435\u0432\u044b\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 Retrofit, \u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 JSON \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c kotlinx-serialization. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u043c\u0435\u043d\u044b \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d MockWebServer \u043e\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u0439 OkHttp\/Retrofit. \u042d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438\u043c\u0435\u0435\u0442 \u0440\u044f\u0434 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u0441\u0440\u0435\u0434\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u043c\u0435\u043d\u0430 \u043e\u0442\u0432\u0435\u0442\u043e\u0432. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Kaspresso.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432 build.gradle \u0438 \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c AndroidManifest, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u043d\u0435\u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u043e\u043c\u0443 HTTP.<\/p>\n<p>build.gradle <\/p>\n<pre><code class=\"java\">dependencies {    androidTestImplementation 'com.squareup.okhttp3:mockwebserver:x.x.x' }<\/code><\/pre>\n<p>network_security_config.xml \u0434\u043b\u044f <strong>debug<\/strong> \u0441\u0431\u043e\u0440\u043a\u0438<\/p>\n<pre><code class=\"xml\">&lt;network-security-config xmlns:tools=\"http:\/\/schemas.android.com\/tools\">    &lt;base-config        cleartextTrafficPermitted=\"true\"        tools:ignore=\"InsecureBaseConfiguration\"        >    &lt;\/base-config> &lt;\/network-security-config><\/code><\/pre>\n<p>AndroidManifest.xml\u00a0<\/p>\n<pre><code class=\"xml\">&lt;application    android:networkSecurityConfig=\"@xml\/network_security_config\" &lt;\/application><\/code><\/pre>\n<h3>DI-\u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f\u00a0<\/h3>\n<p>DI-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0434\u043b\u044f \u043d\u0443\u0436\u0434 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e\u043c\u0438\u043c\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e Application \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 Test Application. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u043f\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0438. \u041f\u043e\u043b\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/primechord\/stubwebserver\/pull\/1\/commits\/de68d451b8d45b0df0cacbe5984cc57b79257d85#diff-0b70724976d8bb03a57f492debdb70a028c796f50af4d7d35a55ecf0ba309e95\"><u>\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/u><\/a>.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 baseUrlProvider: <\/p>\n<pre><code class=\"kotlin\">Retrofit.Builder().baseUrl(baseUrlProvider.getUrl())<\/code><\/pre>\n<p>\u0433\u0434\u0435 \u0434\u043b\u044f Application \u0430\u0434\u0440\u0435\u0441 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c:<\/p>\n<pre><code class=\"kotlin\">override fun getUrl() = \"https:\/\/api.github.com\"<\/code><\/pre>\n<p>\u0430 \u0434\u043b\u044f Test Application \u0430\u0434\u0440\u0435\u0441 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438:<\/p>\n<pre><code class=\"kotlin\">override fun getUrl() = \"http:\/localhost:8080\"<\/code><\/pre>\n<p>\u041f\u043e\u0440\u0442 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u044f\u0432\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0435\u0441\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0441 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u044c\u044e.\u00a0<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430 AndroidJUnitRunner \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0432 \u043d\u0435\u043c \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 Test Application. \u0410 \u043d\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430 AndroidJUnitRunner \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u0441\u044b\u043b\u0430\u0435\u043c\u0441\u044f \u0432 build.gradle:<\/p>\n<pre><code class=\"kotlin\">@Suppress(\"unused\") class CustomTestRunner : AndroidJUnitRunner() {    override fun newApplication(cl: ClassLoader?, className: String?, context: Context?    ): Application {        return super.newApplication(cl, TestApplication::class.java.name, context)    } }<\/code><\/pre>\n<p>build.gradle <\/p>\n<pre><code class=\"java\">android { \u00a0\u00a0\u00a0defaultConfig { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0testInstrumentationRunner \"com.primechord.stubwebserver.application.CustomTestRunner\" \u00a0\u00a0\u00a0} }<\/code><\/pre>\n<h2>\u0421\u0442\u0430\u0431\u044b \u0438\u0437 JSON-\u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/h2>\n<p><a class=\"anchor\" name=\"assets\" id=\"assets\"><\/a><\/p>\n<p>\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u0432\u0435\u0442\u0430 endpoint\u2019\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0439, \u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0441 endpoint&#8217;\u0430\u043c\u0438 \u0438\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 production-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c: <a href=\"https:\/\/api.github.com\/users\/primechord\/repos\"><u>https:\/\/api.github.com\/users\/primechord\/repos<\/u><\/a>. \u041c\u043d\u043e\u0433\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0435\u0439 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432.<\/p>\n<h3>\u0423\u0442\u0438\u043b\u0438\u0442\u043d\u044b\u0439 \u043a\u043e\u0434<\/h3>\n<p>Dispatcher \u2014 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c MockWebServer, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.\u00a0<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0439 Dispatcher. \u0415\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043a\u043b\u044e\u0447\u0443 \u0438\u0437 Map, \u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442. \u0412 MockWebServer \u043e\u0442\u0432\u0435\u0442 \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u043b\u0430\u0441\u0441 MockResponse. \u0415\u0441\u043b\u0438 MockWebServer \u0443\u0432\u0438\u0434\u0438\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f Path, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u0442 \u0441\u0440\u0435\u0434\u0438 \u043a\u043b\u044e\u0447\u0435\u0439, \u0442\u043e \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u0434 404. \u0412 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044e endpoint&#8217;\u0430 (endsWith).<\/p>\n<pre><code class=\"kotlin\">fun createDispatcher(    mockResponsesMap: Map&lt;String, MockResponse?> ) = object : Dispatcher() {    override fun dispatch(request: RecordedRequest): MockResponse {        mockResponsesMap.forEach {            if (request.path?.endsWith(it.key) == true) {                return mockResponsesMap[it.key] ?: failNotFoundResponseMock()            }        }        return failNotFoundResponseMock()    } }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0432\u043e\u0436\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u0442\u0430\u0431\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c \u0442\u0435\u0441\u0442 \u0441 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 endpoint&#8217;\u0430\u0445.<\/p>\n<pre><code class=\"kotlin\">class MockUtils {    companion object {        const val SOME_REQUEST_PATH = \"\/api\/v1\/hello\/world\"        const val SOME_RESPONSE_FILE = \"hello\/world_pretty.json\"    }    val baseRequestResponseMap: HashMap&lt;String, MockResponse?> = hashMapOf(        SOME_REQUEST_PATH to successResponse(SOME_RESPONSE_FILE),    ) }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0442\u0435\u043b\u0430 \u043e\u0442\u0432\u0435\u0442\u0430:<\/p>\n<pre><code class=\"kotlin\">fun failNotFoundResponseMock(): MockResponse = \u00a0\u00a0\u00a0MockResponse() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.setResponseCode(HttpURLConnection.HTTP_NOT_FOUND)  fun successResponse(fileName: String): MockResponse = \u00a0\u00a0\u00a0MockResponse() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.setResponseCode(HttpURLConnection.HTTP_OK) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.setBody(jsonUtil.readJSONFromAsset(fileName))  fun successResponse(body: () -> String): MockResponse = \u00a0\u00a0\u00a0MockResponse() \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.setResponseCode(HttpURLConnection.HTTP_OK) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.setBody(body.invoke())<\/code><\/pre>\n<p>\u041d\u0443 \u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0442\u0435\u0441\u0442\u043e\u0432:<\/p>\n<pre><code class=\"kotlin\">abstract class BaseTest(    protected val server: MockWebServer = MockWebServer(),    builder: Kaspresso.Builder = Kaspresso.Builder.simple {        beforeEachTest {            server.start(8080)        }        afterEachTest {            server.shutdown()        }    }, ) : TestCase(builder)<\/code><\/pre>\n<h3>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0435\u0441\u0442\u044b \u0438 \u0438\u0445 \u0441\u0442\u0430\u0431\u044b<\/h3>\n<h4>Assets \u0431\u0435\u0437 \u043e\u0431\u0435\u0440\u0442\u043a\u0438<\/h4>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u043f\u0440\u043e\u0441\u0442, \u0445\u043e\u0442\u044f \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u043e\u043b\u044c \u0443\u0433\u043e\u0434\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432 \u0431\u043b\u043e\u043a\u0435 when:<\/p>\n<pre><code class=\"kotlin\">@Test fun pureDispatcher() {    server.dispatcher = object : Dispatcher() {        val mockUtils = MockUtils()        override fun dispatch(request: RecordedRequest): MockResponse {            return when {                request.path?.contains(\"\/repos\") == true -> {                    mockUtils.successResponse {                        mockUtils.jsonUtil.readJSONFromAsset(\"repos.json\")                    }                }                else -> mockUtils.failNotFoundResponseMock()            }        }    }     \/\/ kaspresso code }<\/code><\/pre>\n<p>\u0410 \u0432\u043e\u0442 \u0431\u043e\u043b\u0435\u0435 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0443\u0442\u0438\u043b\u0438\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<pre><code class=\"kotlin\">private fun MockWebServer.mockRepos(reposResponseAsset: String) {    val mockUtils = MockUtils()    val requestResponseMap = mockUtils.baseRequestResponseMap    requestResponseMap[\"\/repos\"] = mockUtils.successResponse(reposResponseAsset)    dispatcher = mockUtils.createDispatcher(requestResponseMap) }  @Test fun withExtension() {    server.mockRepos(\"repos.json\")     \/\/ kaspresso code }<\/code><\/pre>\n<h4>\u041e\u0431\u0435\u0440\u0442\u043a\u0430 \u0434\u043b\u044f \u0443\u0440\u043e\u0432\u043d\u044f \u0442\u0435\u0441\u0442\u043e\u0432<\/h4>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f MockWebServer, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0434\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0442\u0435\u0441\u0442\u0430:<\/p>\n<pre><code class=\"kotlin\">fun MockWebServer.mockResponses(vararg pairs: Pair&lt;String, MockContainer>) {    val mockUtils = MockUtils()    val requestResponseMap = mockUtils.baseRequestResponseMap    for (pair in pairs) {        requestResponseMap[pair.first] = pair.second.getResponse()    }    dispatcher = mockUtils.createDispatcher(requestResponseMap) }  sealed interface MockContainer {    fun getResponse(): MockResponse }  class AnyContainer(private val mockResponse: MockResponse) : MockContainer {    override fun getResponse() =<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-341510","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341510","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=341510"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341510\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=341510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=341510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=341510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}