chromium - 测试工程的位置

前言

以前就想知道chromium工程中,哪个才是可以运行的测试工程。今天查资料时,找到了。

实验

chromium - 测试工程的位置_第1张图片
编译出来的PE文件为:Z:\chromium\src\out\my_x86_d\browser_tests.exe
直接运行,测试用例8000+。
browser_tests.exe 支持 --help命令行, 可以选择自己要测试的子类别。最重要的是,通过测试程序,后续可以找到测试代码的实现,看看每一个知识点,作者是怎么写的调用代码。

.\browser_tests.exe --help
Runs tests using the gtest framework, each batch of tests being
run in their own process. Supported command-line flags:

 Common flags:
  --gtest_filter=...
    Runs a subset of tests (see --gtest_help for more info).

  --help
    Shows this message.

  --gtest_help
    Shows the gtest help message.

  --test-launcher-jobs=N
    Sets the number of parallel test jobs to N.

  --single_process
    Runs the tests and the launcher in the same process. Useful
    for debugging a specific test in a debugger.

 Other flags:
  --test-launcher-retry-limit=N
    Sets the limit of test retries on failures to N.

  --test-launcher-summary-output=PATH
    Saves a JSON machine-readable summary of the run.

  --test-launcher-print-test-stdio=auto|always|never
    Controls when full test output is printed.
    auto means to print it when the test failed.

  --test-launcher-total-shards=N
    Sets the total number of shards to N.

  --test-launcher-shard-index=N
    Sets the shard index to run to N (from 0 to TOTAL - 1).

.\browser_tests.exe --gtest_help
This program contains tests written using Google Test. You can use the
following command line flags to control its behavior:

Test Selection:
  --gtest_list_tests
      List the names of all tests instead of running them. The name of
      TEST(Foo, Bar) is "Foo.Bar".
  --gtest_filter=POSTIVE_PATTERNS[-NEGATIVE_PATTERNS]
      Run only the tests whose name matches one of the positive patterns but
      none of the negative patterns. '?' matches any single character; '*'
      matches any substring; ':' separates two patterns.
  --gtest_also_run_disabled_tests
      Run all disabled tests too.

Test Execution:
  --gtest_repeat=[COUNT]
      Run the tests repeatedly; use a negative count to repeat forever.
  --gtest_shuffle
      Randomize tests' orders on every iteration.
  --gtest_random_seed=[NUMBER]
      Random number seed to use for shuffling test orders (between 1 and
      99999, or 0 to use a seed based on the current time).

Test Output:
  --gtest_color=(yes|no|auto)
      Enable/disable colored output. The default is auto.
  --gtest_print_time=0
      Don't print the elapsed time of each test.
  --gtest_output=(json|xml)[:DIRECTORY_PATH\|:FILE_PATH]
      Generate a JSON or XML report in the given directory or with the given
      file name. FILE_PATH defaults to test_details.xml.

Assertion Behavior:
  --gtest_break_on_failure
      Turn assertion failures into debugger break-points.
  --gtest_throw_on_failure
      Turn assertion failures into C++ exceptions for use by an external
      test framework.
  --gtest_catch_exceptions=0
      Do not report exceptions as test failures. Instead, allow them
      to crash the program or throw a pop-up (on Windows).

Except for --gtest_list_tests, you can alternatively set the corresponding
environment variable of a flag (all letters in upper-case). For example, to
disable colored text output, you can either specify --gtest_color=no or set
the GTEST_COLOR environment variable to no.

For more information, please read the Google Test documentation at
https://github.com/google/googletest/. If you find a bug in Google Test
(not one in your own code or tests), please report it to
.

列出测试子集的名称

.\browser_tests.exe --gtest_list_tests
PlatformAppBrowserTest.  # TypeParam = 
  RunningAppsAreRecorded  # GetParam() = 
  ActiveAppsAreRecorded  # GetParam() = 
  FileAccessIsSavedToPrefs  # GetParam() = 
  DISABLED_FileAccessIsRestored  # GetParam() = 
  LoadAndLaunchAppChromeRunning  # GetParam() = 
  LoadAndLaunchAppWithFile  # GetParam() = 
  CreateAndCloseAppWindow  # GetParam() = 
...
MimeHandlerViewTests/MimeHandlerViewTest.
  PostMessageW/0  # GetParam() = false
  PostMessageW/1  # GetParam() = true
  Basic/0  # GetParam() = false
  Basic/1  # GetParam() = true
  Embedded/0  # GetParam() = false
  Embedded/1  # GetParam() = true
  Iframe/0  # GetParam() = false
  Iframe/1  # GetParam() = true
  Abort/0  # GetParam() = false
  Abort/1  # GetParam() = true
  NonAsciiHeaders/0  # GetParam() = false
  NonAsciiHeaders/1  # GetParam() = true
  DataUrl/0  # GetParam() = false
  DataUrl/1  # GetParam() = true
  EmbeddedDataUrlObject/0  # GetParam() = false
  EmbeddedDataUrlObject/1  # GetParam() = true
  EmbeddedDataUrlEmbed/0  # GetParam() = false
  EmbeddedDataUrlEmbed/1  # GetParam() = true
  EmbeddedDataUrlLong/0  # GetParam() = false
  EmbeddedDataUrlLong/1  # GetParam() = true
  ResizeBeforeAttach/0  # GetParam() = false
  ResizeBeforeAttach/1  # GetParam() = true
  SingleRequest/0  # GetParam() = false
  SingleRequest/1  # GetParam() = true
  BackgroundPage/0  # GetParam() = false
  BackgroundPage/1  # GetParam() = true

测试一个子集

从上面的子集合列表中取自己想测试的子集,跟在--gtest_filter=后面测试。
.\browser_tests.exe --gtest_filter=BackgroundPage/1

IMPORTANT DEBUGGING NOTE: each test is run inside its own process.
For debugging a test inside a debugger, use the
--gtest_filter= flag along with either
--single_process (to run the test in one launcher/browser process) or
--single-process (to do the above, and also run Chrome in single-process mode).
Using sharding settings from environment. This is shard 0/1
Using 1 parallel jobs.
0 tests run

看测试程序打出的日志,好像测试并没有运行。
其实可以单步看看,就知道为啥不执行测试用例了。改天吧。

你可能感兴趣的:(chromium - 测试工程的位置)