UNPKG

node-webodf

Version:

WebODF - JavaScript Document Engine http://webodf.org/

67 lines (52 loc) 2.86 kB
General notes ============= There are three different ways to do testing: * two makefile targets: "nodetest" & "qtjsruntimetest" * one webserving test: "webodf/tests/tests.html" All three use the central file "tests.js". This file checks what runtime it is in, and depending on that enables different tests. All tests are written with classes implementing the interface core.UnitTest. There can be sync and async tests. Some tests expect to be run with a DOM document and use an empty div in it. They need to get that div in the setUp() method by calling core.UnitTest.provideTestAreaDiv, and should release it in the tearDown() method by calling core.UnitTest.cleanupTestAreaDiv. Running tests in the browser ============================ To run the tests in the browser(s) of your interest, you should use nodejs and the custom webserver implemented in webodf/httpserver.js. This webserver implements a certain handling of "PUT" requests, as expected by some tests. Using another webserver also works, but it will result in a few tests failing. From the toplevel directory of the sources run node webodf/httpserver.js and open http://127.0.0.1:8124/webodf/tests/tests.html with the browsers you want to run the tests in. How to add a new test class =========================== 1. Create new test class 2. Add an entry to this class in - CMakeLists.txt (file path & name) - webodf/tests/manifest.js (file path & name) - webodf/tests/tests.html (file path & name) - webodf/tests/tests.js (runtime.loadClass AND tests.push(...)) The best way to ensure all these entries are correct is to run all three test types (node, qt & browser). In each of these (including the browser) there should be no classpath failures. The browser often masks these because the order loading is slightly more forgiving. Common issues ============= qtjsruntimetest throws a "undefined is not an object error" ----------------------------------------------- - Ensure tests.js has the appropriate runtime.loadClass entry tests are not run / do not appear ----------------------------------------------- - Ensure tests.js has the appropriate tests.push entry one or more tests throw "Cannot load class ..." ----------------------------------------------- This is caused by the required class not being available when runtime.loadClass is called. This causes the runtime to attempt to dynamically load the class, which for tests is never expected to happen, hence the classpaths are all wildly incorrect. The fix is to ensure the required classes are listed in build/webodf/simplecompilex.js BEFORE any runtime.loadClass lines that use them. - Ensure the tests are listed *after* their dependencies in all files - Ensure any new classes are listed *after* their dependencies in all files