MCPcopy Create free account
hub / github.com/catboost/catboost / TBaseTestCase

Class TBaseTestCase

library/cpp/testing/unittest/registar.h:818–874  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

816 };
817
818 struct TBaseTestCase {
819 // NOTE: since EACH test case is instantiated for listing tests, its
820 // ctor/dtor are not the best place to do heavy preparations in test fixtures.
821 //
822 // Consider using SetUp()/TearDown() methods instead
823
824 inline TBaseTestCase()
825 : TBaseTestCase(nullptr, nullptr, false)
826 {
827 }
828
829 inline TBaseTestCase(const char* name, std::function<void(TTestContext&)> body, bool forceFork)
830 : Name_(name)
831 , Body_(std::move(body))
832 , ForceFork_(forceFork)
833 , File_(nullptr)
834 , Line_(0)
835 {
836 }
837
838 // TODO: YA-3943 будет открыто в следующем PR, активироввать функционал нужно в два шага
839 // inline TBaseTestCase(const char* name, std::function<void(TTestContext&)> body, bool forceFork, const char* file, int line)
840 // : Name_(name)
841 // , Body_(std::move(body))
842 // , ForceFork_(forceFork)
843 // , File_(file)
844 // , Line_(line)
845 // {
846 // }
847
848 virtual ~TBaseTestCase() = default;
849
850 // Each test case is executed in 3 steps:
851 //
852 // 1. SetUp() (from fixture)
853 // 2. Execute_() (test body from Y_UNIT_TEST macro)
854 // 3. TearDown() (from fixture)
855 //
856 // Both SetUp() and TearDown() may use UNIT_* check macros and are only
857 // called when the test is executed.
858
859 virtual void SetUp(TTestContext& /* context */) {
860 }
861
862 virtual void TearDown(TTestContext& /* context */) {
863 }
864
865 virtual void Execute_(TTestContext& context) {
866 Body_(context);
867 }
868
869 const char* Name_;
870 std::function<void(TTestContext&)> Body_;
871 bool ForceFork_;
872 const char* File_;
873 int Line_;
874 };
875

Callers 1

AddTestMethod · 0.85

Calls

no outgoing calls

Tested by 1

AddTestMethod · 0.68