The tests in test_GitRepository.cc are written in this way:
TEST_CASE("GitRepository Wrapper Test all", "[GitWrapper]")
{
SECTION("Construct GitRepository object")
{
...
}
SECTION("Stage files")
{
// add some files to the index (`git add`)
// and check the index directly
...
}
SECTION("Commit")
{
// commit any changes that are staged
// and check the index directly
...
}
The tests in the 3rd section and only ever succeed when the 2nd section did it works.
Furthermore the scope above the first section is empty.
In catch2, sections are most useful when there is code before the first section, because that is done before every section. The resulting code is not what it looks like. Take this example
TEST_CASE("test", "test")
{
int i = 3;
SECTION("do something")
{
REQUIRE(i == 3);
i = 5;
}
SECTION("do something other")
{
++i;
REQUIRE(i == 4);
}
}
All tests succeed!
Furthermore when one section fails the other sections are still executed as they are intended to be no depending one on another.
For this we should just throw out all the SECTION markers. If you want to add some comments that only show on fails use INFO or equivalents.
The tests in
test_GitRepository.cc
are written in this way:The tests in the 3rd section and only ever succeed when the 2nd section did it works. Furthermore the scope above the first section is empty.
In catch2, sections are most useful when there is code before the first section, because that is done before every section. The resulting code is not what it looks like. Take this example
All tests succeed!
Furthermore when one section fails the other sections are still executed as they are intended to be no depending one on another.
For this we should just throw out all the
SECTION
markers. If you want to add some comments that only show on fails useINFO
or equivalents.