{"id":265238,"date":"2015-09-09T11:28:02","date_gmt":"2015-09-09T07:28:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=265238"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=265238","title":{"rendered":"\u041a\u0430\u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0411\u0414 \u0432 dUnit"},"content":{"rendered":"<p>       \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0432 xUnit-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u0445, \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 test-case \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 SetUp, TestSomething, TearDown. \u0418 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0432 unit-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043f\u0435\u0440\u0435\u0434 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438. \u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u044d\u0442\u043e\u0433\u043e \u2014 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418 \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0432\u0435\u0441\u044c\u043c\u0430 \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0441\u0442\u043e\u0432, \u043f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0411\u0414 \u0432 SetUp, \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0432 TearDown.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0434\u0443\u043b\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"delphi\">... type   TTestDB1 = class(TTestCase)   protected   public     procedure SetUp; override;     procedure TearDown; override;   published     procedure TestDB1_1;     procedure TestDB1_2;   end; ... implementation ... procedure TTestDB1.SetUp; begin   inherited;   \/\/ connect to DB end;  procedure TTestDB1.TearDown; begin   \/\/ disconnect from DB   inherited; end; ... initialization   RegisterTest(TTestDB1.Suite); end. <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/fa1\/d30\/099\/fa1d30099658418abaacfd185d3052ce.png\"\/>  <\/div>\n<\/div>\n<p>  \u0421\u0445\u0435\u043c\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0430\u044f:<\/p>\n<pre><code class=\"delphi\">-- TTestDB1.SetUp ---- TTestDB1.TestDB1_1 -- TTestDB1.TearDown -- TTestDB1.SetUp ---- TTestDB1.TestDB1_2 -- TTestDB1.TearDown <\/code><\/pre>\n<p>  <i>\u041a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0441 \u0411\u0414 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043a \u0411\u0414 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f, \u0435\u0451 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439.<\/i><\/p>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 <a href=\"http:\/\/dunit.sourceforge.net\/\">dUnit<\/a> \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 TTestSetup (\u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 TTestExtensions).<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041e\u043d, \u043f\u043e \u0441\u0443\u0442\u0438, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0442\u043e\u0442 \u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>ITest<\/code>, \u0447\u0442\u043e \u0438 TTestCase, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0443 \u0436\u0435 \u0441\u0445\u0435\u043c\u0443: SetUp, Test&#8230;, TearDown, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 \u0432\u0441\u0435\u0433\u043e test-case&#8217;\u0430, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438 \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438. \u0422.\u0435. \u0432\u0438\u0434\u043e\u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u043c\u043e\u0434\u0443\u043b\u044c:<\/p>\n<pre><code class=\"delphi\">uses   ...   TestExtensions;  type   TTestDBSetup = class(TTestSetup)   public     procedure SetUp; override;     procedure TearDown; override;   \/\/ published-\u043c\u0435\u0442\u043e\u0434\u044b \u0432 TTestSetup \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f   end;    TTestDB1 = ... ... implementation ... initialization   RegisterTest(TTestDBSetup.Create(TTestDB1.Suite)); end. <\/code><\/pre>\n<p>  \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u0445\u0435\u043c\u0443 \u0432\u044b\u0437\u043e\u0432\u043e\u0432:  <\/p>\n<pre><code class=\"delphi\">-- TTestDBSetup.SetUp  ---- TTestDB1.SetUp ------ TTestDB1.TestDB1_1 ---- TTestDB1.TearDown  ---- TTestDB1.SetUp ------ TTestDB1.TestDB1_2 ---- TTestDB1.TearDown  -- TTestDBSetup.TearDown <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/268\/fd1\/eb6\/268fd1eb6a6f4469b8a4df5d25710a42.png\"\/><\/p>\n<p>  \u041f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e \u0441\u0445\u0435\u043c\u0430 suite + test-cases. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043a \u0411\u0414 \u0432 TTestDBSetup.SetUp, \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c TestDB1_1 \u0438 TestDB1_2.<\/p>\n<p>  \u042d\u0442\u043e \u0434\u043ec\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d test-case \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0439 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0411\u0414. \u041d\u043e \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 test-case, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0442\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0411\u0414 (\u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0433\u043e TTestDB2 \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 TestDB2_1, TestDB2_2, \u0438 \u0442.\u0434)?<\/p>\n<p>  \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>TTestSetup.Create<\/code> \u043e\u043f\u0438\u0441\u0430\u043d \u0442\u0430\u043a:<\/p>\n<pre><code class=\"delphi\">constructor TTestSetup.Create(ATest: ITest; AName: string = ''); <\/code><\/pre>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c \u00ab\u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u00bb \u0432 suite \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d test-case. \u0415\u0441\u043b\u0438 \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"delphi\">  RegisterTest(TTestDBSetup.Create(TTestDB1.Suite));   RegisterTest(TTestDBSetup.Create(TTestDB2.Suite)); <\/code><\/pre>\n<p>  \u0422\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u044b\u0437\u043e\u0432\u044b \u043f\u043e \u0441\u0445\u0435\u043c\u0435:  <\/p>\n<pre><code class=\"delphi\">-- TTestDBSetup.SetUp  ---- TTestDB1.SetUp ------ TTestDB1.TestDB1_1 ---- TTestDB1.TearDown  ---- TTestDB1.SetUp ------ TTestDB1.TestDB1_2 ---- TTestDB1.TearDown  -- TTestDBSetup.TearDown  -- TTestDBSetup.SetUp  ---- TTestDB2.SetUp ------ TTestDB2.TestDB2_1 ---- TTestDB2.TearDown  ---- TTestDB2.SetUp ------ TTestDB2.TestDB2_2 ---- TTestDB2.TearDown  -- TTestDBSetup.TearDown <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b46\/bed\/d0e\/b46bedd0ec0a4bc19b21a42afcd69c8c.png\"\/><\/p>\n<p>  \u042d\u0442\u043e \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c. \u041c\u044b \u0432\u0435\u0434\u044c \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u0411\u0414 \u043b\u0438\u0448\u044c \u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b.<\/p>\n<p>  \u0422\u0443\u0442 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u0431\u0443\u0434\u0438\u043b\u043e \u043c\u0435\u043d\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e. \u041e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 RegisterTest:  <\/p>\n<pre><code class=\"delphi\">procedure RegisterTest(SuitePath: string; test: ITest); begin   assert(assigned(test));   if __TestRegistry = nil then CreateRegistry;   RegisterTestInSuite(__TestRegistry, SuitePath, test); end; <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0437\u0430 <code>SuitePath<\/code>? \u0421\u043c\u043e\u0442\u0440\u0438\u043c <code>RegisterTestInSuite<\/code>:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"delphi\">procedure RegisterTestInSuite(rootSuite: ITestSuite; path: string; test: ITest); ... begin   if (path = '') then   begin     \/\/ End any recursion     rootSuite.addTest(test);   end   else   begin     \/\/ Split the path on the dot (.)     dotPos := Pos('.', Path);     if (dotPos &lt;= 0) then dotPos := Pos('\\', Path);     if (dotPos &lt;= 0) then dotPos := Pos('\/', Path);     if (dotPos &gt; 0) then     begin       suiteName := Copy(path, 1, dotPos - 1);       pathRemainder := Copy(path, dotPos + 1, length(path) - dotPos);     end     else     begin       suiteName := path;       pathRemainder := '';     end; ... <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0418 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e SuitePath \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0447\u0430\u0441\u0442\u0438, \u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u044d\u0442\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u2014 \u0442\u043e\u0447\u043a\u0430, \u0442.\u0435. \u044d\u0442\u043e \u043d\u0435\u043a\u0438\u0439 \u00ab\u043f\u0443\u0442\u044c suite\u00bb, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0439 test-case.<\/p>\n<p>  \u041f\u0440\u043e\u0431\u0443\u0435\u043c TestDB2 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a (\u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c TTestDB2 \u00ab\u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c \u0443\u0437\u043b\u043e\u043c\u00bb \u0432 TTestDBSetup):  <\/p>\n<pre><code class=\"delphi\">RegisterTest('Setup decorator ((d) TTestDB1)', TTestDB2.Suite); <\/code><\/pre>\n<p>  \u041d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/604\/0e5\/282\/6040e5282b334545b66bdff0b32f4752.png\"\/><\/p>\n<p>  \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u043f\u044f\u0442\u044c \u043a\u043e\u0434 <code>RegisterTestInSuite<\/code>:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"delphi\">procedure RegisterTestInSuite(rootSuite: ITestSuite; path: string; test: ITest); ... begin ...       currentTest.queryInterface(ITestSuite, suite);       if Assigned(suite) then       begin ... <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e test-case \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 ITestSuite, \u0430 TTestSetup \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u041a\u0430\u043a \u0436\u0435 \u0431\u044b\u0442\u044c?<\/p>\n<p>  \u0422\u0443\u0442 \u043f\u043e\u0434\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u0435\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 IndySoap (\u0432 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c \u0442\u0435\u0441\u0442\u044b dUnit, \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0433\u0440\u0443\u043f\u043f\u0430\u043c) \u0438 <a href=\"https:\/\/github.com\/ashumkin\/IndySoap\/blob\/master\/tests\/IdSoapTestsRegistration.pas\">\u0432\u0438\u0434\u0438\u043c \u0442\u0430\u043c<\/a> \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 (\u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a \u043d\u0430\u0448\u0438\u043c \u0442\u0435\u0441\u0442\u0430\u043c):<\/p>\n<pre><code class=\"delphi\">... function DBSuite: ITestSuite; begin   Result := TTestSuite.Create('DB tests');   Result.AddTest(TTestDB1.Suite);   Result.AddTest(TTestDB2.Suite); end; ... initialization   RegisterTest(TTestDBSetup.Create(DBSuite)); <\/code><\/pre>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c suite \u0438\u0437 \u043d\u0430\u0448\u0438\u0445 test-case&#8217;\u043e\u0432, \u0430 \u0443\u0436\u0435 \u044d\u0442\u043e\u0442 suite \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 TTestSetup.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/0c3\/810\/6eb\/0c38106eb69640838cb5d970e8dabf9b.png\"\/><\/p>\n<p>  \u0418 \u0432\u0440\u043e\u0434\u0435 \u0431\u044b, \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438 \u0432\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e. \u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u044b \u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c.<\/p>\n<p>  \u041d\u043e \u0435\u0441\u043b\u0438 (\u0442\u043e\u0447\u043d\u0435\u0435, \u00ab\u043a\u043e\u0433\u0434\u0430\u00bb) \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0435\u0449\u0451 \u0442\u0435\u0441\u0442\u044b \u0411\u0414 (\u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0438\u0445, TTestDB3), \u0442\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u0438 \u0432 DBSuite:<\/p>\n<pre><code class=\"delphi\">... function DBSuite: ITestSuite; begin   ...   Result.AddTest(TTestDB3.Suite); end; ... <\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043f\u043e-\u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443, \u0438\u0445 \u043d\u0430\u0434\u043e \u0432\u044b\u043d\u043e\u0441\u0438\u0442\u044c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u0430 \u0443\u0436\u0435 \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043c\u043e\u0434\u0443\u043b\u044c \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 DBSuite. \u042d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 DBSuite \u043b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f (\u043a \u0442\u043e\u043c\u0443 \u0436\u0435, \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u00ab\u043b\u0438\u0448\u043d\u0438\u0439\u00bb \u0443\u0437\u0435\u043b \u00abDB tests\u00bb, \u0445\u043e\u0442\u044f TTestDB1\/TTestDB2 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u00ab\u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442\u044c\u00bb \u0441\u0440\u0430\u0437\u0443 TTestDBSetup). \u042f \u0445\u043e\u0447\u0443 \u043b\u0438\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c \u0442\u0435\u0441\u0442\u043e\u0432 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u043e\u043d\u0438 \u00ab\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u00bb \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u0431\u044b \u0432 TTestDBSetup.<\/p>\n<p>  \u0427\u0442\u043e \u0436, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043a\u0430\u043a \u0445\u043e\u0442\u0438\u043c. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043c\u043d\u0435 \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0438\u043c\u044f Setup&#8217;\u0430 \u0432\u0438\u0434\u0430 \u00abSetup decorator ((d)&#8230;\u00bb. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u043f\u043e\u0442\u043e\u043c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0435\u0441\u0442\u044b \u0432 \u044d\u0442\u043e\u0442 Setup, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0438\u043c\u044f. \u041f\u043e\u043c\u0435\u043d\u044f\u0435\u043c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"delphi\">function TTestSetup.GetName: string; begin   Result := Format(sSetupDecorator, [inherited GetName]); end; <\/code><\/pre>\n<p>  \u0418 \u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>AName<\/code> \u0432  <\/p>\n<pre><code class=\"delphi\">constructor TTestSetup.Create(ATest: ITest; AName: string = ''); <\/code><\/pre>\n<p>  \u041a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f  <\/p>\n<pre><code class=\"delphi\">constructor TAbstractTest.Create(AName: string); ...   FTestName := AName; ... <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c  <\/p>\n<pre><code class=\"delphi\">... TTestDBSetup = ...   public     function GetName: string; override; ... implementation  ... function TTestDBSetup.GetName: string; begin   Result := FTestName; end; ... initialization   RegisterTest(TTestDBSetup.Create(DBSuite, 'DB')); <\/code><\/pre>\n<p>  \u0422\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/d95\/619\/91a\/d9561991ad5540008500215b158e5863.png\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c test-case&#8217;\u044b \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442. \u0422\u043e \u0435\u0441\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"delphi\">unit uTestDB3; ... initialization   RegisterTest('DB', TTestDB3.Suite)); <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e (\u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c <code>RegisterTestInSuite<\/code>), \u0447\u0442\u043e\u0431\u044b TTestDBSetup \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 ITestSuite.<\/p>\n<pre><code class=\"delphi\">...  ITestSuite = interface(ITest)     ['{C20E38EF-7369-44D9-9D84-08E84EC1DCF0}']      procedure AddTest(test: ITest);     procedure AddSuite(suite : ITestSuite);   end; <\/code><\/pre>\n<p>  \u0422\u0430\u043c \u0432\u0441\u0435\u0433\u043e-\u0442\u043e \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"delphi\">...   TTestDBSetup = class(TTestSetup, ITestSuite)   public     procedure AddTest(test: ITest);     procedure AddSuite(suite : ITestSuite);   end; ... implementation ... procedure TTestDBSetup.AddTest(test: ITest); begin   Assert(Assigned(test));    FTests.Add(test); end;  procedure TTestDBSetup.AddSuite(suite: ITestSuite); begin   AddTest(suite); end; ... <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/bba\/c96\/f9d\/bbac96f9dd674cd4add610d4300ed5af.png\"\/><\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c!<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 (F9, \u043a\u0441\u0442\u0430\u0442\u0438) \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0442\u0435\u0441\u0442\u044b TTestDB3 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/0df\/0f5\/430\/0df0f543094f42b395bec6fa8a3a88c3.png\"\/><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u043e\u0447\u0435\u043c\u0443, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"delphi\">procedure TTestDecorator.RunTest(ATestResult: TTestResult); begin   FTest.RunWithFixture(ATestResult); end; <\/code><\/pre>\n<p>  \u0422.\u0435. \u0442\u0435\u0441\u0442\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 (<code>FTest<\/code>), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0437\u0430\u0434\u0430\u043d\u044b \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 TTestDBSetup:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"delphi\">constructor TTestDecorator.Create(ATest: ITest; AName: string); begin   ...   FTest := ATest;   FTests:= TInterfaceList.Create;   FTests.Add(FTest); end; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0410 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043f\u043e\u0437\u0436\u0435 (<code>FTests<\/code>) \u2014 \u043d\u0435\u0442. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0438 \u0438\u0445, \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 RunTest:<\/p>\n<pre><code class=\"delphi\">...   TTestDBSetup = ...   protected     procedure RunTest(ATestResult: TTestResult); override; ...   end. ... procedure TTestDBSetup.RunTest(ATestResult: TTestResult); var   i: Integer; begin   inherited;   \/\/ \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0442.\u043a. \u044d\u0442\u043e FTest   for i := 1 to FTests.Count - 1 do     (FTests[i] as ITest).RunWithFixture(ATestResult); end; <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/6fa\/d9d\/802\/6fad9d802d7a4983a2693fcc6c4259eb.png\"\/><\/p>\n<p>  \u0412\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c, \u0432\u0440\u043e\u0434\u0435, \u0432\u0441\u0451 \u043e\u043a. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0433\u043b\u044f\u0434\u0435\u0442\u044c\u0441\u044f, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432 \u2014 4, \u0430 \u0431\u044b\u043b\u043e \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043e \u2014 6. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u0430\u0448\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f. \u041d\u0435\u043f\u043e\u0440\u044f\u0434\u043e\u043a.<\/p>\n<p>  \u041d\u0430\u0432\u0435\u0434\u0451\u043c \u043a\u0440\u0430\u0441\u043e\u0442\u0443:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"delphi\"> ...   TTestDBSetup = ...   protected ...     function CountTestInterfaces: Integer;     function CountEnabledTestInterfaces: Integer;   public ...     function CountTestCases: Integer; override;     function CountEnabledTestCases: Integer; override;   end; ...  function TTestDBSetup.CountTestCases: Integer; begin   Result := inherited;   if Enabled then     Inc(Result, CountTestsInterfaces); end;  function TTestDBSetup.CountTestInterfaces: Integer; var   i: Integer; begin   Result := 0;   \/\/ skip FIRST test case (it is FTest)   for i := 1 to FTests.Count - 1 do     Inc(Result, (FTests[i] as ITest).CountTestCases); end;  function TTestDBSetup.CountEnabledTestCases: Integer; begin   Result := inherited;   if Enabled then     Inc(Result, CountEnabledTestInterfaces); end;  function TTestDBSetup.CountEnabledTestInterfaces: Integer; var   i: Integer; begin   Result := 0;   \/\/ skip FIRST test case (it is FTest)   for i := 1 to FTests.Count - 1 do     if (FTests[i] as ITest).Enabled then       Inc(Result, (FTests[i] as ITest).CountTestCases); end; ...  <\/code><\/pre>\n<p>  <i>\u0417\u0434\u0435\u0441\u044c CountEnabledTestCases \u0438 CountEnabledTestInterfaces \u2014 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/i><\/p>\n<p>  <b>Nota bene.<\/b> \u0412 GUI \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f CountEnabledTestCases, \u0430 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u043c \u2014 CountTestCases.  <\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/29d\/9a0\/84f\/29d9a084f85d4da8bb655c36de102421.png\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/620\/e01\/061\/620e010613e744f6b49c6200aa15a6ab.png\"\/><\/p>\n<p>  \u0412\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a.<\/p>\n<p>  \u0414\u043e\u0447\u0438\u0442\u0430\u0432\u0448\u0438\u0439 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c, \u0430 \u0441\u0442\u041e\u0438\u0442 \u043b\u0438 \u0442\u0430\u043a \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e \u0442\u0438\u043f\u0443 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 DBSuite? \u042f \u0438 \u0441\u0430\u043c \u043e\u0431 \u044d\u0442\u043e\u043c \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0434\u0443\u043c\u0430\u043b. \u041d\u043e \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u043b\u044e\u0441\u043e\u0432 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u043a\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u043e\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f, \u0435\u0449\u0451 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u0441 dUnit \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e, \u0434\u0435\u043b\u0430\u043b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443. \u0418 \u0434\u043b\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043a \u0442\u0430\u043a\u043e\u0439 \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0441\u0442\u0438 \u0442\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u043f\u0430\u0440\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (\u043d\u0443 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441).<\/p>\n<p>  P.S.: \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043a\u043e\u0434\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u2014 <a href=\"https:\/\/github.com\/ashumkin\/habr-dunit-ttestsetup-demo\">github.com\/ashumkin\/habr-dunit-ttestsetup-demo<\/a>       <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/266487\/\"> http:\/\/habrahabr.ru\/post\/266487\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0432 xUnit-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u0445, \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 test-case \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 SetUp, TestSomething, TearDown. \u0418 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0432 unit-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043f\u0435\u0440\u0435\u0434 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438. \u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u044d\u0442\u043e\u0433\u043e \u2014 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418 \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0432\u0435\u0441\u044c\u043c\u0430 \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0441\u0442\u043e\u0432, \u043f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0411\u0414 \u0432 SetUp, \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0432 TearDown.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0434\u0443\u043b\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"delphi\">... type   TTestDB1 = class(TTestCase)   protected   public     procedure SetUp; override;     procedure TearDown; override;   published     procedure TestDB1_1;     procedure TestDB1_2;   end; ... implementation ... procedure TTestDB1.SetUp; begin   inherited;   \/\/ connect to DB end;  procedure TTestDB1.TearDown; begin   \/\/ disconnect from DB   inherited; end; ... initialization   RegisterTest(TTestDB1.Suite); end. <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/fa1\/d30\/099\/fa1d30099658418abaacfd185d3052ce.png\"\/>  <\/div>\n<\/div>\n<p>  \u0421\u0445\u0435\u043c\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0430\u044f:<\/p>\n<pre><code class=\"delphi\">-- TTestDB1.SetUp ---- TTestDB1.TestDB1_1 -- TTestDB1.TearDown -- TTestDB1.SetUp ---- TTestDB1.TestDB1_2 -- TTestDB1.TearDown <\/code><\/pre>\n<p>  <i>\u041a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0441 \u0411\u0414 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043a \u0411\u0414 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f, \u0435\u0451 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439.<\/i><\/p>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 <a href=\"http:\/\/dunit.sourceforge.net\/\">dUnit<\/a> \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 TTestSetup (\u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 TTestExtensions).  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-265238","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/265238","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=265238"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/265238\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=265238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=265238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=265238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}