diff options
author | Manoj Srivastava <srivasta@debian.org> | 2016-01-27 12:43:59 -0800 |
---|---|---|
committer | Manoj Srivastava <srivasta@debian.org> | 2016-01-27 12:50:09 -0800 |
commit | 76fce162659078323fcd5e54b3195dae371faca2 (patch) | |
tree | c1d93d415b96238aae3c54eb83cb0815af2e4bca /vendor/bandit/specs/run.spec.cpp | |
parent | b4456969cd02d75c599a5b86b225c0774697e85d (diff) | |
parent | 4aa1a39402c3908e9e8b6eb3fd4e2183d5e5c52e (diff) |
Merge branch 'development' into upstream
Signed-off-by: Manoj Srivastava <srivasta@debian.org>
# Conflicts:
# src/.gitignore
# src/maid-x11.c
# src/quest.pkg
Diffstat (limited to 'vendor/bandit/specs/run.spec.cpp')
-rw-r--r-- | vendor/bandit/specs/run.spec.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/vendor/bandit/specs/run.spec.cpp b/vendor/bandit/specs/run.spec.cpp new file mode 100644 index 00000000..6e59bac7 --- /dev/null +++ b/vendor/bandit/specs/run.spec.cpp @@ -0,0 +1,77 @@ +#include <specs/specs.h> +using namespace bandit::fakes; +using namespace bandit::specs::util; +namespace bd = bandit::detail; + +go_bandit([](){ + + describe("run:", [&](){ + std::unique_ptr<bd::spec_registry> specs; + std::unique_ptr<argv_helper> argv; + fake_reporter_ptr reporter; + std::unique_ptr<bd::contextstack_t> context_stack; + + auto call_run = [&]() -> int { + bd::options opt(argv->argc(), argv->argv()); + return bandit::run(opt, *specs, *context_stack, *reporter); + }; + + before_each([&](){ + specs = std::unique_ptr<bd::spec_registry>(new bd::spec_registry()); + + reporter = fake_reporter_ptr(new fake_reporter()); + + context_stack = std::unique_ptr<bd::contextstack_t>(new bd::contextstack_t()); + + const char* args[] = {"executable"}; + argv = std::unique_ptr<argv_helper>(new argv_helper(1, args)); + }); + + it("pushes the global context on the context stack", [&](){ + call_run(); + AssertThat(*context_stack, Is().OfLength(1)); + }); + + describe("a successful test run", [&](){ + int number_of_specs_called; + + before_each([&](){ + number_of_specs_called = 0; + specs->push_back([&](){ number_of_specs_called++; }); + }); + + it("calls the context", [&](){ + call_run(); + AssertThat(number_of_specs_called, Equals(1)); + }); + + it("tells reporter a test run is about to start", [&](){ + call_run(); + AssertThat(reporter->call_log(), Has().Exactly(1).EqualTo("test_run_starting")); + }); + + it("tells reporter a test run has completed", [&](){ + call_run(); + AssertThat(reporter->call_log(), Has().Exactly(1).EqualTo("test_run_complete")); + }); + + it("returns 0 as no specs failed", [&](){ + AssertThat(call_run(), Equals(0)); + }); + }); + + + describe("a failing test run", [&](){ + + before_each([&](){ + reporter->set_test_run_status(false); + }); + + it("returns a non-zero error code", [&](){ + AssertThat(call_run(), IsGreaterThan(0)); + }); + + }); + }); + +}); |