|
5 | 5 |
|
6 | 6 | ---
|
7 | 7 |
|
8 |
| -## Testing |
| 8 | +### Testing |
9 | 9 |
|
10 | 10 | > "If you liked it then you should have put a test on it", Beyonce rule
|
11 | 11 |
|
|
14 | 14 |
|
15 | 15 | * Improve your productivity with GUnit, a library which extends/simplifies [Google.Test/Google.Mock](https://github.com/google/googletest) and adds support for [Gherkin](https://github.com/cucumber/cucumber/wiki/Gherkin) (Behaviour Driven Development) to it.
|
16 | 16 |
|
17 |
| -## Motivation |
| 17 | + * Why it's based on [Google.Test/Google.Mock](https://github.com/google/googletest)? |
| 18 | + * (+) Google.Test is **widely used** (The most popular testing framework according to https://www.jetbrains.com/research/devecosystem-2017/cpp) |
| 19 | + * (+) Google.Test is **stable** |
| 20 | + * (+) Google.Test is **powerful** |
| 21 | + * (+) Google.Test comes with **Google.Mock** |
| 22 | + * (+) Google.Test is **well documented** |
| 23 | + * (-) Google.Test **doesn't have support for - [gherkin](https://github.com/cucumber/cucumber/wiki/Gherkin) style - tests** |
| 24 | + * (-) Google.Test and Google.Mock have a lot **boilerplate macros** |
18 | 25 |
|
19 |
| -> ### No more base classes and labels as identifiers - [GUnit.GTest](docs/GTest.md) / [GUnit.GTest-Lite](docs/GTest-Lite.md) |
| 26 | +### Motivation Examples |
| 27 | + |
| 28 | +> #### No more base classes and labels as identifiers - [GUnit.GTest](docs/GTest.md) / [GUnit.GTest-Lite](docs/GTest-Lite.md) |
20 | 29 | ```cpp
|
21 | 30 | Google.Test | GUnit.GTest
|
22 | 31 | --------------------------------------------------+------------------------------------------------------
|
|
51 | 60 | [----------] 2 tests from CalcTest (1 ms total) | [----------] 1 tests from Example (0 ms total)
|
52 | 61 | ```
|
53 | 62 |
|
54 |
| -> ### No more hand written mocks - [GUnit.GMock](docs/GMock.md) |
| 63 | +> #### No more hand written mocks - [GUnit.GMock](docs/GMock.md) |
55 | 64 | ```cpp
|
56 | 65 | struct interface {
|
57 | 66 | virtual ~interface() = default;
|
|
80 | 89 | } | }
|
81 | 90 | ```
|
82 | 91 |
|
83 |
| -> ### Simplified creation and injection of SUT (System Under Test) and mocks - [GUnit.GMake](docs/GMake.md) |
| 92 | +> #### Simplified creation and injection of SUT (System Under Test) and mocks - [GUnit.GMake](docs/GMake.md) |
84 | 93 | ```cpp
|
85 | 94 | class coffee_maker {
|
86 | 95 | public:
|
|
109 | 118 | }
|
110 | 119 | ```
|
111 | 120 |
|
112 |
| -> ### Support for - [Gherkin](https://github.com/cucumber/cucumber/wiki/Gherkin) style - BDD (Behaviour Driven Development) scenarios - [GUnit.GSteps](docs/GSteps.md) |
| 121 | +> #### Support for - [Gherkin](https://github.com/cucumber/cucumber/wiki/Gherkin) style - BDD (Behaviour Driven Development) scenarios - [GUnit.GSteps](docs/GSteps.md) |
113 | 122 |
|
114 | 123 | > Feature specification
|
115 | 124 |
|
|
178 | 187 | [ PASSED ] 1 tests.
|
179 | 188 | ```
|
180 | 189 |
|
181 |
| -## Overview |
182 |
| -* Extensions (independent) |
183 |
| - * `GUnit.GTest` - Google.Test with strings and more friendly macros |
184 |
| - * Test cases with string as names |
185 |
| - * No more SetUp/TearDown (SHOULD clauses) |
186 |
| - * One (GTEST) macro for all types of tests |
187 |
| - * 100% Compatible with tests using GTest |
188 |
| - * `GUnit.GTest-Lite` - lightweight, limited, no-macro way of defining simple tests |
189 |
| - * `GUnit.GMock` - Google.Mock without hand written mocks |
190 |
| - * No more hand written mocks! |
191 |
| - * Support for more than 10 parameters |
192 |
| - * Quicker compilation times |
193 |
| - * Support for unique_ptr without any tricks |
194 |
| - * Support for overloaded operators |
195 |
| - * Support for mocking classes with constructors |
196 |
| - * 100% Compatible with Google Mocks |
197 |
| - * `GUnit.GMake` - Makes creation of System Under Test (SUT) and Mocks easier |
198 |
| - * No need to instantiate SUT (System Under Test) and mocks |
199 |
| - * Automatic mocks injection |
200 |
| - * `GUnit.GSteps` - Behaviour Driven Development |
201 |
| - * Support for - [Gherkin](https://github.com/cucumber/cucumber/wiki/Gherkin) style - BDD tests |
202 |
| -* Based on top of [Google.Test/Google.Mock](https://github.com/google/googletest) |
203 |
| - * (+) Widely used (The most popular testing framework according to https://www.jetbrains.com/research/devecosystem-2017/cpp) |
204 |
| - * (+) Stable |
205 |
| - * (+) Powerful |
206 |
| - * (+) Comes with GoogleMock |
207 |
| - * (+) Well documented |
208 |
| - * (-) No support for - [Gherkin](https://github.com/cucumber/cucumber/wiki/Gherkin) style - BDD tests |
209 |
| - * (-) Boilerplate macros |
210 |
| -* Requirements |
| 190 | +### Overview |
| 191 | +
|
| 192 | +* `GUnit.GTest` - Google.Test with strings and more friendly macros |
| 193 | + * Test cases with string as names |
| 194 | + * No more SetUp/TearDown (SHOULD clauses) |
| 195 | + * One (GTEST) macro for all types of tests |
| 196 | + * 100% Compatible with tests using GTest |
| 197 | +* `GUnit.GTest-Lite` - lightweight, limited, no-macro way of defining simple tests |
| 198 | +* `GUnit.GMock` - Google.Mock without hand written mocks |
| 199 | + * No more hand written mocks! |
| 200 | + * Support for more than 10 parameters |
| 201 | + * Quicker compilation times |
| 202 | + * Support for unique_ptr without any tricks |
| 203 | + * Support for overloaded operators |
| 204 | + * Support for mocking classes with constructors |
| 205 | + * 100% Compatible with Google Mocks |
| 206 | +* `GUnit.GMake` - Makes creation of System Under Test (SUT) and Mocks easier |
| 207 | + * No need to instantiate SUT (System Under Test) and mocks |
| 208 | + * Automatic mocks injection |
| 209 | +* `GUnit.GSteps` - Behaviour Driven Development |
| 210 | + * Support for - [Gherkin](https://github.com/cucumber/cucumber/wiki/Gherkin) style - BDD tests |
| 211 | +
|
| 212 | +### Quick Start |
| 213 | +
|
| 214 | +* If your project is **NOT** using [Google.Test/Google.Mock](https://github.com/google/googletest) |
| 215 | + * Follow instructions from https://github.com/google/googletest/tree/master/googletest |
| 216 | +* Clone the repository |
| 217 | + * `git clone https://github.com/cpp-testing/GUnit.git` |
| 218 | +* Add `GUnit/include` directory to your include path |
| 219 | + * `-I GUnit/include` |
| 220 | +* Write some tests... |
| 221 | +* Compile and Run! |
| 222 | +
|
| 223 | +--- |
| 224 | +
|
| 225 | +* [**Optional**] For [gherkin](https://github.com/cucumber/cucumber/wiki/Gherkin) support |
| 226 | + * Compile `gherkin-cpp` |
| 227 | + ```sh |
| 228 | + $cd libs/gherkin-cpp && make lib |
| 229 | + $ls libs/gherkin-cpp |
| 230 | + libgherkin-cpp.a |
| 231 | + libgherkin-cpp.so |
| 232 | + ``` |
| 233 | + * Add include paths |
| 234 | + * `-I GUnit/gherkin-cpp/include` |
| 235 | + * `-I GUnit/json/src` |
| 236 | + * Link with `libgherkin-cpp.{a, so}` |
| 237 | + * `-L libgherkin-cpp` |
| 238 | + * Write some feature tests... |
| 239 | + * Compile and Run! |
| 240 | +
|
| 241 | +--- |
| 242 | +
|
| 243 | +* To run GUnit tests/benchmarks |
| 244 | + ```sh |
| 245 | + $mkdir build && cd build && cmake .. |
| 246 | + $make && ctest |
| 247 | + ``` |
| 248 | +
|
| 249 | +### Requirements |
211 | 250 | * [C++14](https://ubershmekel.github.io/cppdrafts/c++14-cd.html)
|
212 | 251 | * `GTest/GTest-Lite/GMock/GMake`
|
213 | 252 | * [libs/googletest](https://github.com/google/googletest) - compatible with all versions
|
214 | 253 | * `GSteps`
|
215 | 254 | * [libs/json](https://github.com/nlohmann/json)
|
216 | 255 | * [libs/gherkin-cpp](https://github.com/c-libs/gherkin-cpp)
|
217 |
| - * Building libgherkin-cpp |
218 |
| - ``` |
219 |
| - $cd libs/gherkin-cpp && make lib |
220 |
| - $ls libs/gherkin-cpp |
221 |
| - libgherkin-cpp.a |
222 |
| - libgherkin-cpp.so |
223 |
| - ``` |
224 |
| -* Tested compilers |
| 256 | +
|
| 257 | +### Tested compilers |
225 | 258 | * [Linux - GCC-5+](https://travis-ci.org/cpp-testing/GUnit)
|
226 | 259 | * [Linux - Clang-3.7+](https://travis-ci.org/cpp-testing/GUnit)
|
227 | 260 | * [Mac OSx - Xcode-7.3+](https://travis-ci.org/cpp-testing/GUnit)
|
228 |
| -* Quick start |
229 |
| - ```sh |
230 |
| - $mkdir build && cd build && cmake .. |
231 |
| - $make && ctest |
232 |
| - ``` |
233 |
| -* User Guide |
234 |
| - * [GUnit.GTest](docs/GTest.md) |
235 |
| - * [GUnit.GTest-Lite](docs/GTest-Lite.md) |
236 |
| - * [GUnit.GMock](docs/GMock.md) |
237 |
| - * [GUnit.GMake](docs/GMake.md) |
238 |
| - * [GUnit.GSteps](docs/GSteps.md) |
239 |
| -* [FAQ](docs/FAQ.md) |
| 261 | +
|
| 262 | +### User Guide |
| 263 | + * **[GUnit.GTest](docs/GTest.md)** |
| 264 | + * **[GUnit.GTest-Lite](docs/GTest-Lite.md)** |
| 265 | + * **[GUnit.GMock](docs/GMock.md)** |
| 266 | + * **[GUnit.GMake](docs/GMake.md)** |
| 267 | + * **[GUnit.GSteps](docs/GSteps.md)** |
| 268 | +
|
| 269 | +### [FAQ](docs/FAQ.md) |
240 | 270 | * [C++ Now 2017: Towards Painless Testing](https://www.youtube.com/watch?v=NVrZjT5lW5o)
|
241 | 271 |
|
242 | 272 | ### Acknowledgements
|
|
0 commit comments