Commit | Line | Data |
---|---|---|
408ae4df DV |
1 | These tests are run with js-test-driver |
2 | (http://code.google.com/p/js-test-driver/). | |
3 | ||
4 | Running tests | |
5 | ------------- | |
6 | ||
86a3e64f DV |
7 | With phantomjs: |
8 | ||
9 | - Install phantomjs (http://www.phantomjs.org). | |
10 | ||
11 | - Start a terminal window at the dygraphs root directory (one | |
12 | directory up from here.) | |
13 | ||
14 | - Run "./test.sh". This will tell you whether the tests passed. | |
15 | ||
16 | ||
17 | With a real browser: | |
18 | ||
408ae4df DV |
19 | - Start a terminal window at the dygraphs root directory (one |
20 | directory up from here.) | |
21 | ||
22 | - From there, you start the test server and capture at least one slave | |
23 | browser: | |
24 | ||
25 | Run: | |
1a27bd14 | 26 | $ java -jar ./auto_tests/lib/JsTestDriver-1.3.3c.jar --port 9876 |
408ae4df DV |
27 | |
28 | Open | |
29 | http://localhost:9876/capture | |
30 | in the browser you want to use for your test. | |
31 | ||
32 | - Run the tests with: | |
33 | ||
1a27bd14 | 34 | $ java -jar ./auto_tests/lib/JsTestDriver-1.3.3c.jar --tests all |
408ae4df DV |
35 | |
36 | ||
37 | Debugging tests | |
38 | --------------- | |
39 | ||
40 | This is a bit of a hack, but you can also run tests manually inside the browser | |
41 | using auto_tests/misc/local.html. | |
42 | ||
43 | Once you've opened that page, open up the JavaScript console and run something | |
44 | like: | |
45 | ||
46 | new SimpleDrawingTestCase().runTest("testDrawSimpleRangePlusOne") | |
47 | ||
48 | to run just one test. This is useful for seeing the dygraph that the test | |
49 | creates, setting breakpoints, etc. | |
50 | ||
51 | Please don't rely on it as proof that your tests pass; the command-line is the | |
52 | reference for ensuring Dygraphs automated tests pass. | |
53 | ||
54 | ||
55 | (This is a specialized version of the instructions found at | |
56 | http://code.google.com/p/js-test-driver/wiki/GettingStarted. | |
57 | They're listed as a courtesy, but you really should get to understand | |
58 | js-test-driver, which has lots of powerful features.) | |
49cb8afc DV |
59 | |
60 | ||
61 | Code Coverage | |
62 | ------------- | |
63 | ||
64 | To generate code coverage data, start the jstd test server: | |
65 | ||
66 | $ java -jar ./auto_tests/lib/JsTestDriver-1.3.3c.jar --port 9876 | |
67 | ||
68 | Then run the tests with the --outputCoverage option: | |
69 | ||
70 | $ java -jar ./auto_tests/lib/JsTestDriver-1.3.3c.jar --tests all --testOutput . | |
71 | ||
72 | This can take a few minutes. It will spew out gobs of XML files, which should | |
73 | be deleted. The one file you care about is jsTestDriver.conf-coverage.dat. It | |
74 | contains LCOV-format coverage data. It contains coverage data for _all_ JS | |
75 | files, including the tests themselves and library code which is irrelevant for | |
76 | coverage analysis. So you need to filter it down: | |
77 | ||
78 | $ cat jsTestDriver.conf-coverage.dat | ./auto_tests/misc/filter-lcov.py | |
79 | ||
80 | To post the coverage data to coveralls, you'll need to export a few environment | |
81 | variables and install node-coveralls: | |
82 | ||
83 | $ npm install # installs node-coveralls, which is listed in package.json | |
84 | $ export COVERALLS_SERVICE_NAME=jstd | |
85 | $ export COVERALLS_REPO_TOKEN=... # get this by visiting http://coveralls.io | |
86 | $ export COVERALLS_GIT_COMMIT=$(git rev-parse HEAD) | |
87 | $ cat jsTestDriver.conf-coverage.dat \ | |
88 | | ./auto_tests/misc/filter-lcov.py \ | |
89 | | ./node_modules/coveralls/bin/coveralls.js | |
90 | ||
91 | If all goes well, you should see your coverage data posted at | |
92 | https://coveralls.io/r/danvk/dygraphs. |