[MD WebUI] Improve reliability and friendliness of test suite |
|||
Issue descriptionPlanned changes: * Convert tests to use replaceApp() to prevent global state persisting between tests * Where appropriate, make tests more unit-testy by creating a single instance of the element being tested * Remove the registerTests() 'namespacing' * Ensure tests are in the appropriate suite * Remove excessive uses of the flush() promise method, replacing them with Polymer.dom.flush() where possible * Try using the BrowserProxy testing pattern rather than relying on registerMessageCallback() (see: https://docs.google.com/document/d/1c20VYdwpUPyBRQeAS0CMr6ahwWnb0s26gByomOwqDjk/edit)
,
Nov 25 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/b3451f9f323fed4630432f989fa6c678089d96f8 commit b3451f9f323fed4630432f989fa6c678089d96f8 Author: tsergeant <tsergeant@chromium.org> Date: Fri Nov 25 04:35:48 2016 MD History: Remove unnecessary namespacing from tests (part 1) These tests followed the (outdated) practice of defining tests inside a dedicated `registerTests` function. This no longer has any benefit for isolating tests, and just reduces the amount of horizontal space available for test code. This CL only removes these registerTests functions and deindents the corresponding code -- there are no functional changes to any tests. BUG= 647115 Review-Url: https://codereview.chromium.org/2504813002 Cr-Commit-Position: refs/heads/master@{#434433} [modify] https://crrev.com/b3451f9f323fed4630432f989fa6c678089d96f8/chrome/test/data/webui/md_history/history_item_test.js [modify] https://crrev.com/b3451f9f323fed4630432f989fa6c678089d96f8/chrome/test/data/webui/md_history/history_list_test.js [modify] https://crrev.com/b3451f9f323fed4630432f989fa6c678089d96f8/chrome/test/data/webui/md_history/history_metrics_test.js [modify] https://crrev.com/b3451f9f323fed4630432f989fa6c678089d96f8/chrome/test/data/webui/md_history/history_overflow_menu_test.js [modify] https://crrev.com/b3451f9f323fed4630432f989fa6c678089d96f8/chrome/test/data/webui/md_history/history_supervised_user_test.js [modify] https://crrev.com/b3451f9f323fed4630432f989fa6c678089d96f8/chrome/test/data/webui/md_history/history_synced_tabs_test.js [modify] https://crrev.com/b3451f9f323fed4630432f989fa6c678089d96f8/chrome/test/data/webui/md_history/md_history_browsertest.js
,
Jan 9 2017
it has recently come up as to whether the whole "registerTests()" namespacing and registration is needed in md-settings' tests as well.
to be perfectly clear: it's never useful to add extra namespacing. in almost all cases, extra namespaces / registration only adds cruft and provides no benefit as pretty much every _test.js file is run in isolation. though it's possible this may change in the future, RIGHT NOW it's better just to drop this stuff.
soooo
// my_test.js
cr.define('overly_long_namespace', function() {
function registerTests() {
... real code starts here ...
}
return {
registerTests: registerTests,
},
});
// cr_settings_browsertest.js
TEST_F('BrowserTestGroupName', 'TestCaseName', function() {
overly_long_namespace.registerTests();
mocha.run();
})
should become (and has, generally, in newer tests):
// my_test.js
... code starts here ...
// cr_settings_browsertest.js
TEST_F('BrowserTestGroupName', 'TestCaseName', function() {
mocha.run();
});
until concretely proven otherwise useful.
,
Jan 10 2017
it's never useful to add unnecessary** namespacing
,
Jan 12 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/1a17a732d52a25fc250243aa4b968de6b3d50739 commit 1a17a732d52a25fc250243aa4b968de6b3d50739 Author: tsergeant <tsergeant@chromium.org> Date: Thu Jan 12 22:07:30 2017 MD History: Remove unnecessary namespacing from tests (part 2) These files define test cases inside a dedicated `registerTests` function. This no longer has any benefit for isolating tests, and just reduces the amount of horizontal space available for test code. This CL only removes these registerTests functions and deindents the corresponding code -- there are no functional changes to any tests. BUG= 647115 Review-Url: https://codereview.chromium.org/2627263002 Cr-Commit-Position: refs/heads/master@{#443380} [modify] https://crrev.com/1a17a732d52a25fc250243aa4b968de6b3d50739/chrome/test/data/webui/md_history/browser_service_test.js [modify] https://crrev.com/1a17a732d52a25fc250243aa4b968de6b3d50739/chrome/test/data/webui/md_history/history_drawer_test.js [modify] https://crrev.com/1a17a732d52a25fc250243aa4b968de6b3d50739/chrome/test/data/webui/md_history/history_grouped_list_test.js [modify] https://crrev.com/1a17a732d52a25fc250243aa4b968de6b3d50739/chrome/test/data/webui/md_history/history_toolbar_test.js [modify] https://crrev.com/1a17a732d52a25fc250243aa4b968de6b3d50739/chrome/test/data/webui/md_history/md_history_browsertest.js
,
Jun 29 2017
This is as fixed as it's ever going to be. MD History tests have been split apart into smaller chunks and generally use replaceApp()/replaceBody() wherever possible. |
|||
►
Sign in to add a comment |
|||
Comment 1 by bugdroid1@chromium.org
, Nov 14 2016