Skip to content

Instantly share code, notes, and snippets.

@bkuhns
Last active January 11, 2017 16:19
Show Gist options
  • Save bkuhns/135c079e0248a752c948 to your computer and use it in GitHub Desktop.
Save bkuhns/135c079e0248a752c948 to your computer and use it in GitHub Desktop.
SCENARIO("...", "[...]")
{
QEventLoop eventLoop;
MockRepository mockRepo;
GIVEN("An exporter") {
auto exporterAndMocks = setUpExporterAndMocks();
auto exporter = exporterAndMocks.first;
auto mocks = exporterAndMocks.second;
auto dataConverter = get<TupleDataConverter>(mocks);
mockRepo.ExpectCall(dataConverter, DataConverter::convert).Do([] { return vector<unique_ptr<Record>>(); });
WHEN("`exportAsync()` is called.") {
exporter->exportAsync(getStuff(), [&] {
eventLoop.exit();
});
eventLoop.exec();
THEN("the data converter should be used to export data.") {
REQUIRE(true);
}
}
}
}
@Kosta-Github
Copy link

I find the REQUIRE(true) a bit misleading; I would have expected something like REQUIRE(mockRepo.validate()) or so...

@bkuhns
Copy link
Author

bkuhns commented Aug 8, 2013

Good point. I'll see if my mocking framework supports something like this. I've just relied on the fact that Catch invalidates the test if an exception is thrown, even if previous REQUIRE()'s passed. Certainly misleading, as you say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment