Transfer from http://www.cnblogs.com/coderzh/archive/2009/04/06/1426755.html
Golang unit test database
Some time ago to learn and understand the next Google's open-source C + + unit Testing Framework Google test, unit test golang mock referred to as gtest, is very good. We used to be our own implementation of a set of unit testing framework, in the use of the process, found more and more use of inconvenience, and such inconvenience, gtest just very good solution.
Golang unit test best practices
In fact, the implementation of Gtest itself is not complex, we can imitate gtest, constantly improve our testing framework, but finally we decided to use Gtest to replace the original test framework, the reason is:
Unit testing in golang
1. After perfecting our testing framework, golang unit test example we will find that the equivalent of Gtest again, although the wheel made very cool, but is not necessary.
2. The use of gtest can eliminate the hassle of maintaining the testing framework, allowing us to devote more effort to case design.
Unit test golang
The 3.gtest improves the functionality and is simple to use, greatly improving the efficiency of writing test cases.
Golang unit test
Gtest's official website is:
http://code.google.com/p/googletest/
From the official use document, you can almost get everything you want.
Http://code.google.com/p/googletest/wiki/GoogleTestPrimer
Http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide
If you still want to gtest inside to find out, just download its code to study it, this is the benefits of open source, ha!
The official already has such a complete document, why do I have to write it? On the one hand is to remember notes, good memory than rotten pen, later I want to check some usage can also be directly found here, on the one hand is not want to see a lot of English documents friends, in my here can quickly find gtest related content.
Here is the catalog of the series:
1. Go to Google Open source C + + unit Test Framework one of the Google Test series (gtest)-Initial knowledge gtest
2. Google Open source C + + unit Test framework Google Test series (gtest) II-assertion
3. Google Open source C + + unit Test framework Google Test series (gtest) three-event mechanism
4. Google Open source C + + unit Test framework Google Test series (gtest) quad-parametric
5. Google Open source C + + unit Test framework Google Test series (gtest) five-death test
6. Google Open source C + + unit Test framework Google Test series (gtest) six-operating parameters
7. Google Open source C + + unit Test framework Google Test series (gtest) seven-in-depth analysis gtest
8. Google Open source C + + unit Test framework Google Test series (gtest) eight-build your own unit testing framework
Additional articles:
How to jump out of the current test case in 1.gtest
2. Writing beautiful gtest test Cases
3.gtest Parametric test code example (full engineering example included)
Go: Play Google Open source C + + unit Test framework Google Test series