aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/testing/unittest/simple.h
blob: 2a5300d886e11956aedce23c5b87d478ffe333ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once

#include "registar.h"

namespace NUnitTest {
    struct TSimpleTestExecutor: public TTestBase {
        typedef TVector<TBaseTestCase> TTests;

        TTests Tests;

        virtual void Execute() override final {
            AtStart();

            for (typename TTests::iterator i = Tests.begin(), ie = Tests.end(); i != ie; ++i) {
                if (!CheckAccessTest(i->Name_)) {
                    continue;
                }
                TTestContext context(this->Processor());
                try {
                    BeforeTest(i->Name_);
                    {
                        TCleanUp cleaner(this);
                        TTestBase::Run([i, &context] { i->Body_(context); }, Name(), i->Name_, i->ForceFork_);
                    }
                } catch (const ::NUnitTest::TAssertException&) {
                } catch (const yexception& e) {
                    CATCH_REACTION_BT(i->Name_, e, &context);
                } catch (const std::exception& e) {
                    CATCH_REACTION(i->Name_, e, &context);
                } catch (...) {
                    AddError("non-std exception!", &context);
                }
                Finish(i->Name_, &context);
            }

            AtEnd();
        }
    };
}