Commit 5d3a2cd9 authored by Gennadiy Civil's avatar Gennadiy Civil
Browse files

Update docs, TestCase->TestSuite

parent ac8c102d
This diff is collapsed.
# Googletest FAQ
## Why should test case names and test names not contain underscore?
## Why should test suite names and test names not contain underscore?
Underscore (`_`) is special, as C++ reserves the following to be used by the
compiler and the standard library:
......@@ -14,26 +14,26 @@ User code is *prohibited* from using such identifiers.
Now let's look at what this means for `TEST` and `TEST_F`.
Currently `TEST(TestCaseName, TestName)` generates a class named
`TestCaseName_TestName_Test`. What happens if `TestCaseName` or `TestName`
Currently `TEST(TestSuiteName, TestName)` generates a class named
`TestSuiteName_TestName_Test`. What happens if `TestSuiteName` or `TestName`
contains `_`?
1. If `TestCaseName` starts with an `_` followed by an upper-case letter (say,
1. If `TestSuiteName` starts with an `_` followed by an upper-case letter (say,
`_Foo`), we end up with `_Foo_TestName_Test`, which is reserved and thus
invalid.
1. If `TestCaseName` ends with an `_` (say, `Foo_`), we get
1. If `TestSuiteName` ends with an `_` (say, `Foo_`), we get
`Foo__TestName_Test`, which is invalid.
1. If `TestName` starts with an `_` (say, `_Bar`), we get
`TestCaseName__Bar_Test`, which is invalid.
`TestSuiteName__Bar_Test`, which is invalid.
1. If `TestName` ends with an `_` (say, `Bar_`), we get
`TestCaseName_Bar__Test`, which is invalid.
`TestSuiteName_Bar__Test`, which is invalid.
So clearly `TestCaseName` and `TestName` cannot start or end with `_` (Actually,
`TestCaseName` can start with `_` -- as long as the `_` isn't followed by an
So clearly `TestSuiteName` and `TestName` cannot start or end with `_` (Actually,
`TestSuiteName` can start with `_` -- as long as the `_` isn't followed by an
upper-case letter. But that's getting complicated. So for simplicity we just say
that it cannot start with `_`.).
It may seem fine for `TestCaseName` and `TestName` to contain `_` in the middle.
It may seem fine for `TestSuiteName` and `TestName` to contain `_` in the middle.
However, consider this:
```c++
......@@ -44,7 +44,7 @@ TEST(Time_Flies, Like_An_Arrow) { ... }
Now, the two `TEST`s will both generate the same class
(`Time_Flies_Like_An_Arrow_Test`). That's not good.
So for simplicity, we just ask the users to avoid `_` in `TestCaseName` and
So for simplicity, we just ask the users to avoid `_` in `TestSuiteName` and
`TestName`. The rule is more constraining than necessary, but it's simple and
easy to remember. It also gives googletest some wiggle room in case its
implementation needs to change in the future.
......@@ -472,7 +472,7 @@ switch to `EXPECT_*()` if that works. This
C++ is case-sensitive. Did you spell it as `Setup()`?
Similarly, sometimes people spell `SetUpTestCase()` as `SetupTestCase()` and
Similarly, sometimes people spell `SetUpTestSuite()` as `SetupTestSuite()` and
wonder why it's never called.
## How do I jump to the line of a failure in Emacs directly?
......
......@@ -61,21 +61,19 @@ The related term _Test_, as it is used in the googletest, is corresponding to
the term _[Test Case](http://glossary.istqb.org/search/test%20case)_ of ISTQB
and others.
The term _Test_ is commonly of broad enough sense, including ISTQB's
definition of _Test Case_, so it's not much of a problem here. But the
term _Test Case_ as used in Google Test is of contradictory sense and thus confusing.
The term _Test_ is commonly of broad enough sense, including ISTQB's definition
of _Test Case_, so it's not much of a problem here. But the term _Test Case_ as
was used in Google Test is of contradictory sense and thus confusing.
Unfortunately replacing the term _Test Case_ by _Test Suite_ throughout the
googletest is not easy without breaking dependent projects, as `TestCase` is
part of the public API at various places.
googletest recently started replacing the term _Test Case_ by _Test Suite_ The
preferred API is TestSuite*. The older TestCase* API is being slowly deprecated
and refactored away
So for the time being, please be aware of the different definitions of
the terms:
So please be aware of the different definitions of the terms:
Meaning | googletest Term | [ISTQB](http://www.istqb.org/) Term
:----------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------- | :----------------------------------
Exercise a particular program path with specific input values and verify the results | [TEST()](#simple-tests) | [Test Case](http://glossary.istqb.org/search/test%20case)
A set of several tests related to one component | [TestCase](#basic-concepts) | [TestSuite](http://glossary.istqb.org/search/test%20suite)
## Basic Concepts
......@@ -252,7 +250,7 @@ To create a test:
entire test fails. Otherwise, it succeeds.
```c++
TEST(TestCaseName, TestName) {
TEST(TestSuiteName, TestName) {
... test body ...
}
```
......@@ -324,7 +322,7 @@ When using a fixture, use `TEST_F()` instead of `TEST()` as it allows you to
access objects and subroutines in the test fixture:
```c++
TEST_F(TestCaseName, TestName) {
TEST_F(TestSuiteName, TestName) {
... test body ...
}
```
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment