Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
176eccfb
Unverified
Commit
176eccfb
authored
Jun 17, 2019
by
Gennadiy Civil
Committed by
GitHub
Jun 17, 2019
Browse files
Merge pull request #2287 from PhilLab/patch-1
docs/primer: Fixed usage of test case
parents
fd20d1ec
b72b1bee
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
googletest/docs/primer.md
googletest/docs/primer.md
+11
-11
No files found.
googletest/docs/primer.md
View file @
176eccfb
...
@@ -253,10 +253,10 @@ TEST(TestSuiteName, TestName) {
...
@@ -253,10 +253,10 @@ TEST(TestSuiteName, TestName) {
```
```
`TEST()`
arguments go from general to specific. The
*first*
argument is the name
`TEST()`
arguments go from general to specific. The
*first*
argument is the name
of the test
cas
e, and the
*second*
argument is the test's name within the test
of the test
suit
e, and the
*second*
argument is the test's name within the test
case. Both names must be valid C++ identifiers, and they should not contain
case. Both names must be valid C++ identifiers, and they should not contain
underscore (
`_`
). A test's
*full name*
consists of its containing test
cas
e and
underscore (
`_`
). A test's
*full name*
consists of its containing test
suit
e and
its individual name. Tests from different test
cas
es can have the same
its individual name. Tests from different test
suit
es can have the same
individual name.
individual name.
For example, let's take a simple integer function:
For example, let's take a simple integer function:
...
@@ -282,13 +282,13 @@ TEST(FactorialTest, HandlesPositiveInput) {
...
@@ -282,13 +282,13 @@ TEST(FactorialTest, HandlesPositiveInput) {
}
}
```
```
googletest groups the test results by test
cas
es, so logically-related tests
googletest groups the test results by test
suit
es, so logically-related tests
should be in the same test
cas
e; in other words, the first argument to their
should be in the same test
suit
e; in other words, the first argument to their
`TEST()`
should be the same. In the above example, we have two tests,
`TEST()`
should be the same. In the above example, we have two tests,
`HandlesZeroInput`
and
`HandlesPositiveInput`
, that belong to the same test
cas
e
`HandlesZeroInput`
and
`HandlesPositiveInput`
, that belong to the same test
suit
e
`FactorialTest`
.
`FactorialTest`
.
When naming your test
cas
es and tests, you should follow the same convention as
When naming your test
suit
es and tests, you should follow the same convention as
for
[
naming functions and
for
[
naming functions and
classes
](
https://google.github.io/styleguide/cppguide.html#Function_Names
)
.
classes
](
https://google.github.io/styleguide/cppguide.html#Function_Names
)
.
...
@@ -324,7 +324,7 @@ TEST_F(TestSuiteName, TestName) {
...
@@ -324,7 +324,7 @@ TEST_F(TestSuiteName, TestName) {
}
}
```
```
Like
`TEST()`
, the first argument is the test
cas
e name, but for
`TEST_F()`
this
Like
`TEST()`
, the first argument is the test
suit
e name, but for
`TEST_F()`
this
must be the name of the test fixture class. You've probably guessed:
`_F`
is for
must be the name of the test fixture class. You've probably guessed:
`_F`
is for
fixture.
fixture.
...
@@ -339,7 +339,7 @@ declaration`".
...
@@ -339,7 +339,7 @@ declaration`".
For each test defined with
`TEST_F()`
, googletest will create a
*fresh*
test
For each test defined with
`TEST_F()`
, googletest will create a
*fresh*
test
fixture at runtime, immediately initialize it via
`SetUp()`
, run the test,
fixture at runtime, immediately initialize it via
`SetUp()`
, run the test,
clean up by calling
`TearDown()`
, and then delete the test fixture. Note that
clean up by calling
`TearDown()`
, and then delete the test fixture. Note that
different tests in the same test
cas
e have different test fixture objects, and
different tests in the same test
suit
e have different test fixture objects, and
googletest always deletes a test fixture before it creates the next one.
googletest always deletes a test fixture before it creates the next one.
googletest does
**not**
reuse the same test fixture for multiple tests. Any
googletest does
**not**
reuse the same test fixture for multiple tests. Any
changes one test makes to the fixture do not affect other tests.
changes one test makes to the fixture do not affect other tests.
...
@@ -436,7 +436,7 @@ your defined tests in order to run them.
...
@@ -436,7 +436,7 @@ your defined tests in order to run them.
After defining your tests, you can run them with
`RUN_ALL_TESTS()`
, which
After defining your tests, you can run them with
`RUN_ALL_TESTS()`
, which
returns
`0`
if all the tests are successful, or
`1`
otherwise. Note that
returns
`0`
if all the tests are successful, or
`1`
otherwise. Note that
`RUN_ALL_TESTS()`
runs
*all tests*
in your link unit -- they can be from
`RUN_ALL_TESTS()`
runs
*all tests*
in your link unit -- they can be from
different test
cas
es, or even different source files.
different test
suit
es, or even different source files.
When invoked, the
`RUN_ALL_TESTS()`
macro:
When invoked, the
`RUN_ALL_TESTS()`
macro:
...
@@ -508,7 +508,7 @@ class FooTest : public ::testing::Test {
...
@@ -508,7 +508,7 @@ class FooTest : public ::testing::Test {
// before the destructor).
// before the destructor).
}
}
// Objects declared here can be used by all tests in the test
cas
e for Foo.
// Objects declared here can be used by all tests in the test
suit
e for Foo.
};
};
// Tests that the Foo::Bar() method does Abc.
// Tests that the Foo::Bar() method does Abc.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment