-
Notifications
You must be signed in to change notification settings - Fork 55
Test driven development
In general, when implementing new features or resolving bugs one should first implement unit tests that cover the feature and implement the feature afterwards.
This way, during development, the test can already be run to control progress.
See also: https://en.wikipedia.org/wiki/Test-driven_development
See also: https://github.com/DLR-AMR/t8code/wiki/Testing-with-GoogleTest
It is good practice to implement and add unit tests for a bug or new feature even though you are currently not working towards resolving this feature.
However, until the feature is implemented the tests will fail, how do we handle this situation?
Our strategy is as follows:
-
Implement and add the new test cases.
-
Add the GoogleTest Macro
GTEST_SKIP()
to your tests, such that it will be skipped when t8code executes its tests. See: https://google.github.io/googletest/advanced.html#skipping-test-execution
Example:
TEST(SkipTest, DoesSkip) {
GTEST_SKIP() << "Skipping single test";
EXPECT_EQ(0, 1); // Won't fail; it won't be executed
}
class SkipFixture : public ::testing::Test {
protected:
void SetUp() override {
GTEST_SKIP() << "Skipping all tests for this fixture";
}
};
// Tests for SkipFixture won't be executed.
TEST_F(SkipFixture, SkipsOneTest) {
EXPECT_EQ(5, 7); // Won't fail
}
-
If it does not exist yet, create a new issue covering the bug/feature.
-
Add the link of the issue as a comment in the new tests.
/* This test tests the functionality described in Issue: [LINK]
* Remove the GTEST_SKIP() macros when you start working on the issue.
*/
TEST(SkipTest, DoesSkip) {
GTEST_SKIP() << "Skipping single test";
EXPECT_EQ(0, 1); // Won't fail; it won't be executed
}
- In the issue add a new message/text that links to the new tests.
// Issue text here
For this issue, tests have already been implemented at [PATH/TO/TEST1] [PATH/TO/TEST2] ... .
Remember to activate the tests by removing any `GTEST_SKIP()` macros when you start working on this issue.
Installation Guide
Configure Options
Setup t8code on JUWELS and other Slurm based systems
Setup t8code for VTK
General
Step 0 Hello World
Step 1 Creating a coarse mesh
Step 2 Creating a uniform forest
Step 3 Adapting a forest
Step 4 Partition,-Balance,-Ghost
Step 5 Store element data
Step 6 Computing stencils
Step 7 Interpolation
Features
Documentation
Tree Indexing
Element Indexing
Running on JUWELS using Slurm
Overview of the most used API functions
Known issues
Workflow - FreeCAD to t8code
Reproducing Scaling Results
Coding Guidelines
Tips
Debugging with gdb
Debugging with valgrind
Test driven development
Testing with GoogleTest
Writing C interface code