1 / 18

Google C++ Testing Framework

Google C++ Testing Framework. Running Test Programs: Advanced Options. Two methods. Environment variables/ Command line flags Command –help or command /? Flag in code. Disables elapsed time –command. Default Execution Code. Default Execution Results. Flag in code - GTEST_FLAG.

herbst
Download Presentation

Google C++ Testing Framework

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Google C++ Testing Framework Running Test Programs: Advanced Options

  2. Two methods • Environment variables/ Command line flags • Command –help or command /? • Flag in code

  3. Disables elapsed time –command

  4. Default Execution Code

  5. Default Execution Results

  6. Flag in code - GTEST_FLAG

  7. Added Flag

  8. Priority • Command line flags>Flag in code

  9. Other Commands-Listing Test Names • Sometimes it is necessary to list the available tests in a program before running them so that a filter may be applied if needed. • Including the flag --gtest_list_tests overrides all other flags and lists tests in the following format:

  10. Running a Subset of the Tests • Run only a subset of the tests (e.g. for debugging or quickly verifying a change). • GTEST_FILTER environment variable • --gtest_filterflag to a filter string • Examples • gtest_demo • Has no flag, and thus runs all its tests. • gtest_demo --gtest_filter=*  • Also runs everything, due to the single match-everything * value. • gtest_demo  --gtest_filter=FooTest.*  • Runs everything in test case FooTest. • gtest_demo  --gtest_filter=*Null*:*Constructor*  • Runs any test whose full name contains either "Null" or "Constructor". • gtest_demo  --gtest_filter=-*DeathTest.*  • Runs all non-death tests. • gtest_demo  --gtest_filter=FooTest.*-FooTest.Bar • Runs everything in test case FooTest except FooTest.Bar.

  11. Repeating Tests • Once in a while you'll run into a test whose result is hit-or-miss. Perhaps it will fail only 1% of the time, making it rather hard to reproduce the bug under a debugger. This can be a major source of frustration. • The --gtest_repeat flag allows you to repeat all (or selected) test methods in a program many times. Hopefully, a flaky test will eventually fail and give you a chance to debug.

  12. Generating Reports • Google Test can emit a detailed XML report to a file in addition to its normal textual output. • The report contains the duration of each test, and thus can help you identify slow tests. •  environment variable • GTEST_OUTPUT  • Flag • --gtest_output • Example • --gtest_output=xml[:DIRECTORY_PATH\|:FILE_PATH] • xml:_path_to_output_file_ • which will create the file at the given location. • default name: test_detail.xml in current directory.

  13. Gtest_demo –gtest_output=xml

  14. Test_detail.xml

  15. Structure of XML

  16. Example

  17. Notes • The tests attribute of a <testsuites> or <testsuite> element tells how many test functions the Google Test program or test case contains, while the failures attribute tells how many of them failed. • The time attribute expresses the duration of the test, test case, or entire test program in milliseconds. • Each <failure> element corresponds to a single failed Google Test assertion. • Some JUnit concepts don't apply to Google Test, yet we have to conform to the DTD. Therefore you'll see some dummy elements and attributes in the report. You can safely ignore these parts.

More Related