stuff-from-scratch/test/test_utils/TestCaseRunner.h

36 lines
733 B
C
Raw Normal View History

2021-05-23 20:02:38 +00:00
#pragma once
#include "TestCase.h"
#include <vector>
2021-09-26 20:42:35 +00:00
#include <string>
2021-05-23 20:02:38 +00:00
2023-01-05 13:16:52 +00:00
class GuiApplication;
2021-05-23 20:02:38 +00:00
class TestCaseRunner
{
public:
2022-11-30 18:28:50 +00:00
TestCaseRunner();
2021-05-23 20:02:38 +00:00
2022-11-30 18:28:50 +00:00
static TestCaseRunner& getInstance();
2021-05-23 20:02:38 +00:00
2022-11-29 18:00:19 +00:00
~TestCaseRunner();
2023-01-05 13:16:52 +00:00
GuiApplication* getTestApplication();
2022-11-29 18:00:19 +00:00
void addTestCase(const std::string& label, const std::string& tag, TestCase::TestCaseFunction func);
2022-11-30 18:28:50 +00:00
void markTestFailure(const std::string& line);
2022-12-06 18:02:43 +00:00
bool run(const std::vector<std::string>& args);
2021-05-23 20:02:38 +00:00
2023-01-05 13:16:52 +00:00
void setTestApplication(GuiApplication* app);
2021-05-23 20:02:38 +00:00
private:
2023-01-05 13:16:52 +00:00
GuiApplication* mTestApplication{ nullptr };
2022-11-30 18:28:50 +00:00
std::vector<std::string> mFailingTests;
static bool sLastTestFailed;
static std::string sFailureLine;
2022-11-29 18:00:19 +00:00
std::vector<TestCase*> mCases;
2021-05-23 20:02:38 +00:00
};