We have reasonable unit test coverage, but there are parts of BrowserSwitcher that are hard to test without integration tests. Those can give us confidence that the whole feature works as intended.
In particular, AlternativeBrowserDriver does a lot of I/O, and is platform specific. This makes it difficult to write unit tests, and is a good candidate for integration testing.
We could write a test that checks that BrowserSwitcher runs a command line as configured by the admin. In order to do this without changing AlternativeBrowserDriver internals too much, we can:
- In the unit test, configure BrowserSwitcher's "alternative browser" to run a script that writes the URL to a temporary file.
- Wait for a set amount of time, then check that the file has been created with the right content.
e.g. the configuration could be something like
"browser_switcher": {
"url_list": ["example.com"],
"alternative_browser_path": "/bin/sh",
"alternative_browser_parameters": ["-c", "echo ${url} >/tmp/fooXXX.txt"]
}
Comment 1 by bugdroid1@chromium.org
, Nov 12