QA/TDAI/Projects/Test Suite Integration
From MozillaWiki
Integrating existing AJAX test suites into our Mochitest infrastructure is critically important to ensure that our development doesn't break future (or existing) versions of those products and sites developed on those products.
How These Work
Here is a guide to how these work in our normal mochitest setup.
- First off, these tests will be living in a <suite name> directory here
- Create an HTML page that loads in AJAX_setup.js, MochiKit_packed.js, and SimpleTest.js from the lib directory. Here is an example HTML file from the scriptaculous project. Note that it must be named test_<framework>.html.
- Check out AJAX_setup.js. Here you can see that a manifest.json file is loaded and from that, each test file is loaded into mochitest.
- Tests continue to load until we finish the manifest. This is facilitated by our code that is added to the end of a javascript file in the global scope of the framework. You can see the implementation of this code in scriptaculous, and here you can find it in prototype. You can see that the only difference is made in regard to the method in which the results are tracked from these suites.
- Once the AJAX request stops, the next test is loaded and executed, and so on until all the tests in the manifest.json file are executed. Then SimpleTest.finish() is called.
Notable Notes
- The "tests" that are loaded through the manifest.json file need to be HTML pages. This can be done for javascript tests like the Prototype tests by creating simple HTML pages that load those javascripts into an iframe. As an example, check out this one.
- Run the tests first outside of Mochikit. This way you have a good idea of what will fail and what will pass.
- Ensure that you import the entire directory structure the Test Suite uses, so that relative links inside the tests work.
- There is a general page on doing this work (thought it seems a little dated) here.
- You can see how the Prototype library was added here.
- Anything with a test_ in the name is going to get executed first. So, change those names so that they are not picked up. You only want the main HTML file (the one referenced in point 2 above) to be named test_*
So what do I do
- Download the test suite
- Run it in Firefox 3
- Understand what the test files are, hopefully they are HTML
- Wrap the mochitest structure around those files (the manifest.json, the controlling HTML file etc)
- Add makefiles to each directory that adds each file in that directory to _TEST_FILES variable and uses a libs target to copy them out to the mochitest location in the object dir. There are sample makefiles throughout the tree.
- Wrap all of this effort into a patch and attach it to a bug in bugzilla.