Skip to content

Commit 3d5a74f

Browse files
committed
Update README
1 parent de9460d commit 3d5a74f

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

tests/README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
# GoogleTest
2+
- Ref: https://google.github.io/googletest/
23
- GoogleTest helps you write better C++ tests.
3-
## 1. Basic Concepts
4-
- **assertions:** the statememts that check whether a condition is true. The result can be:
5-
- success
6-
- nonfatal failure
7-
- fatal failure
8-
- **test suite:** that contains one or many tests.
9-
- **text fixture:** the class contain test suite used for multiple tests to share common objects and subroutines.
4+
- Basic Concepts:
5+
- **Assertions:** the statememts that check whether a condition is true. The result can be:
6+
- success
7+
- nonfatal failure
8+
- fatal failure
9+
- **Test Suite:** that contains one or many tests.
10+
- **Text fixture:** the class contain test suite used for multiple tests to share common objects and subroutines.
11+
12+
## 1. Assertions:
13+
- **ASSERT_** generates fatal failures and **abort** the current function.
14+
- **EXPECT_** generates nonfatal failures and don't abort the current function. (Preferred)
15+
- To provide a custom failure message, simply stream it into the macro using **`<<`**
16+
- Ref: https://google.github.io/googletest/reference/assertions.html
1017

1118
## 2. Test Fixtures: Using the Same Data Configuration for Multiple Tests
1219
- To create a fixture class:
@@ -16,7 +23,7 @@
1623
- write a default destructor or `TearDown()` function to release resources.
1724
- use `TEST_F(TestFixtureClassName, TestName)` instead of `TEST()`
1825

19-
>All documentation is covered in the official github repo. The primer documentation also covers a lot of information regarding the test macros. You could use the following summary and the examples linked to choose what you want to use. (https://stackoverflow.com/questions/58600728/what-is-the-difference-between-test-test-f-and-test-p)
26+
> All documentation is covered in the official github repo. The primer documentation also covers a lot of information regarding the test macros. You could use the following summary and the examples linked to choose what you want to use. (https://stackoverflow.com/questions/58600728/what-is-the-difference-between-test-test-f-and-test-p)
2027
2128
- **TEST()** is useful when you want to write unit tests for static or global functions or simple classes.
2229
- **TEST_F()** is useful when you need access to objects and subroutines in the unit test.
@@ -100,4 +107,5 @@ int main(int argc, char **argv) {
100107
+) first, you use some simple macros to describe the interface you want to mock, and they will expand to the implementation of your mock class;
101108
+) next, you create some mock objects and specify its expectations and behavior using an intuitive syntax;
102109
+) then you exercise code that uses the mock objects. gMock will catch any violation to the expectations as soon as it arises.
110+
103111
TBD https://google.github.io/googletest/gmock_for_dummies.html

0 commit comments

Comments
 (0)