Makes the example more Jasmine-like.
This commit is contained in:
@@ -15,18 +15,60 @@ namespace JTest {
|
||||
};
|
||||
|
||||
testresults_t operator+(const testresults_t& left, const testresults_t& right);
|
||||
testresults_t operator+(const testresults_t& left, const testresults_t& right) {
|
||||
return add(left, right);
|
||||
}
|
||||
|
||||
testresults_t& operator+=(testresults_t& left, const testresults_t& right);
|
||||
testresults_t& operator+=(testresults_t& left, const testresults_t& right) {
|
||||
left = left + right;
|
||||
return left;
|
||||
}
|
||||
|
||||
|
||||
testresults_t make_testresults();
|
||||
testresults_t make_testresults(uint32_t total, uint32_t skipped, uint32_t passed, uint32_t failed);
|
||||
testresults_t add(const testresults_t&, const testresults_t&);
|
||||
void print_test_results(const testresults_t&, wostream&);
|
||||
|
||||
struct testbundle_t {};
|
||||
|
||||
// Executes the tests in tests. Possibly in parallel. Will block until all async tests have completed.
|
||||
testresults_t execute(testbundle_t tests);
|
||||
|
||||
|
||||
typedef std::function<testbundle_t()> make_testbundle_fn;
|
||||
|
||||
typedef std::function<void()> configure_fn;
|
||||
struct describeoptions_t {
|
||||
// TODO: Should these configure_fn params be const and/or &?
|
||||
describeoptions_t& beforeEach(configure_fn);
|
||||
describeoptions_t& afterEach(configure_fn);
|
||||
describeoptions_t& beforeAll(configure_fn);
|
||||
describeoptions_t& afterAll(configure_fn);
|
||||
private:
|
||||
configure_fn _beforeEach;
|
||||
configure_fn _afterEach;
|
||||
configure_fn _beforeAll;
|
||||
configure_fn _afterAll;
|
||||
};
|
||||
|
||||
//
|
||||
testbundle_t describe(const std::wstring& label, const make_testbundle_fn& make_tests, std::optional<describeoptions_t> options = std::nullopt);
|
||||
|
||||
struct testoptions_t {};
|
||||
|
||||
|
||||
struct test_t {};
|
||||
|
||||
testbundle_t make_testbundle(const std::vector<testbundle_t>& tests, const describeoptions_t& options);
|
||||
// testbundle_t make_testbundle( initializer_list tests, const testoptions_t& options);
|
||||
|
||||
typedef std::function<test_t()> make_test_fn;
|
||||
|
||||
// TODO: Make this return a test_t instead.
|
||||
// TOOD: Bake make_test_fn not need to return testresults_t. Method calls should be surrounded with try/catch.
|
||||
// The label should be extracted from the test_t it returns.
|
||||
// The testresults_t should be constructed based on the try/catch block and whether this was called as it/xit.
|
||||
testbundle_t it(const std::wstring& label, const make_test_fn& test_method, std::optional<testoptions_t> options = std::nullopt);
|
||||
|
||||
describeoptions_t make_describeoptions();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user