aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/testing/unittest/pytests/test_subject/tests.cpp
blob: 677e5130eddfd14dc7c6fbd1082df799f0c858e6 (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
#include <library/cpp/testing/unittest/registar.h>

namespace NSubjectTests {
    class TAlwaysTearDownFixture : public NUnitTest::TBaseFixture {
    public:
        void TearDown(NUnitTest::TTestContext&) override {
            Cerr << Name_ << ": TearDown is ran" << Endl;
        }
    };

    class TAlwaysTearDownSetUpThrowsFixture : public NUnitTest::TBaseFixture {
    public:
        void SetUp(NUnitTest::TTestContext&) override {
            ythrow yexception() << "hope this won't skip teardown";
        }

        void TearDown(NUnitTest::TTestContext&) override {
            Cerr << Name_ << ": TearDown is ran" << Endl;
        }
    };

    Y_UNIT_TEST_SUITE(TestsAlwaysTearDown) {
        Y_UNIT_TEST_F(TestFail, TAlwaysTearDownFixture) {
            UNIT_ASSERT(false);
        }

        Y_UNIT_TEST_F(TestThrow, TAlwaysTearDownFixture) {
            ythrow yexception() << "hope this won't skip teardown";
        }

        Y_UNIT_TEST_F(TestSetUpThrows, TAlwaysTearDownSetUpThrowsFixture) {
        }
    }
}