SimpleTest is Drupal's custom testing framework and allows module's code, functionalities and features to be tested automatically from code.
Adding Test Cases to the module would also allow preparing for an upcoming stable version by testing automatically from code as many features of the module as possible.
In terms of code organization, as it is suggested at Organizing your test cases, it seems to be recommended to group in a base/utility Test Case class commonly used properties, setup or methods, and other test case classes could extend this common base class.
This would allow breaking into separate test cases the tests.
Test Cases:
- Test Page Visibility, 403/404 and DNT configuration settings.
- Test Baidu Analytics Tracker Code (BATC) generation and page inclusion in different scopes.
- Test Baidu Analytics Custom Variables configuration and implemented tokens replacements.
- Test Baidu Analytics configuration for different Roles.
Although we would be adding more tests, none of these changes or updates would add any new feature or functionnality to the module, however, it would certainly improve its code organization, readability, maintainability as well as its possibility to be further extended in the future.
Please let me know if you would have any questions, objections, comments, suggestions, recommendations or concerns on any aspects of feature request, I would be glad to provide more information or explain in more details.
Any questions, feedback, testing, changes, ideas or recommendations would be highly appreciated.
Thanks to all in advance.
Comments
Comment #1
dydave commentedQuick follow-up on this feature request:
Added an initial round of Test Cases with the file
baidu_analytics.test:BaiduAnalyticsTestCase(extending DrupalWebTestCase) which now groups thesetupmethod with module inclusion and the$baCodeproperty to store the Baidu Analytics Web Property ID used for the tests.BaiduAnalyticsBasicTestwhich performs two major series of tests:testBaiduAnalyticsPageVisibilityto test Page Visibility, 403/404 and DNT configuration settings: The admin page and sub-pages are excluded path, vibility of the code on a 403/404 page and DNT headers set or unset.testBaiduAnalyticsTrackingCodeto test Baidu Analytics Tracker Code (BATC) generation and page inclusion in different scopes: Check the correct JavaScript code with the configured Web Property ID is found in the right location of the page whether the scope is set to default, header or footerBaiduAnalyticsCustomVariablesTestto test Baidu Analytics Custom Variables configuration and implemented tokens replacements: Check the generated JavaScript code contains configured Custom Variables, empty values should not display and tokens implemented by the Baidu Analytics modulecurrent-user:baidu_analytics:role-namesandcurrent-user:baidu_analytics:role-idsshould be property replaced.BaiduAnalyticsRolesTestto test Baidu Analytics configuration for different Roles: Check the option to selectively include or exclude certain roles, in particular check for the Anonymous and Authenticated roles if the tracking JavaScript code would display in different configurations.BaiduAnalyticsTestCasebase class.Modified the
baidu_analytics.infofile to declare test file and a Test Dependency required by the Drupal.org Testbots to include the Token module, included by the test caseBaiduAnalyticsCustomVariablesTestfor checking tokens replacements in Custom Variables.The
getInfomethod was also modified to add thedependenciesproperty key to declare inclusion of the Token module (external contributed module required by the Test Case).I went ahead and committed the changes against the 7.x-1.x branch at 6357889.
I allowed myself to mark this issue as fixed for now, but feel free to re-open it, or post a new ticket, at any time if you have any further objections with this issue or related commit 6357889 (we would surely be happy to hear your feedback).
Please let me know if you would have any further comments, feedback, questions, issues, objections, suggestions or concerns on the commit or this feature request in general, I would be glad to provide more information or explain in more details.
Thanks in advance to everyone for your testing, reviews, feedback and comments on this issue.
Cheers!