I wondered the other day whether we have a mechanism in place to prevent network requests made in unittest contexts from actually hitting the network. Input from jam@:
"we try enforcing no network requests (e.g. outside the machien) in tests in browser tests, this is enforced by browser_test_base.cc instantiating a content::TestHostResolver
see the note in test_host_resolver.cc: https://cs.chromium.org/chromium/src/content/public/test/test_host_resolver.cc?rcl=cf2439b936f02d3c14518e1e00947f080d58c6d8&l=48
// To avoid depending on external resources and to reduce (if not preclude)
// network interactions from tests, we simulate failure for non-local DNS
// queries, rather than perform them.
if we don't have similar blocking in unit test binaries (which unfortunately we may not), it'd be good to add it."
We indeed don't, at least not via TestHostResolver; I added a DCHECK(0) to its constructor and verified that unit_tests still runs fine. It's possible of course that we do have such blocking via other means; I didn't dig deeper than that.
Comment 1 by benhenry@google.com
, Jan 11