README.md
1 # Longevity Library
2
3 This library serves as a test runner for longevity suites, which exercise test cases repeatedly in
4 order to exercise or stress the device under test. Annotate a collection of JUnit test classes as a
5 `LongevitySuite`, and voila...you now have longevity tests!
6
7 ## Examples
8
9 There is both host-side (core) and device-side (platform) for longevity tests with only
10 minor differences. All of the examples below use the sample suites bundled as part of the
11 `LongevityHostLibSamples` and `LongevityPlatformLibSamples` modules under the `samples/` directory.
12 Follow the samples directory to see how longevity suites are constructed.
13
14 ### Host
15
16 **Template command with stubbed out options.**
17
18 `java <options> -cp <jar> org.junit.runner.JUnitCore <suite>`
19
20 **Run simple test suite 50 times, and quit when an error is encountered.**
21
22 `java -Diterations=5 -Dquitter=true out/host/linux-x86/framework/LongevityHostSamples.jar
23 org.junit.runner.JUnitCore android.longevity.core.samples.SimpleSuite`
24
25 **Run simple test suite 10 times, shuffle all tests, and quit after 30 minutes.**
26
27 `java -Diterations=10 -Dsuite-timeout_msec=1800000 -Dshuffle=true
28 out/host/linux-x86/framework/LongevityHostSamples.jar
29 org.junit.runner.JUnitCore android.longevity.core.samples.SimpleSuite`
30
31 ### Device
32
33 **Template command with stubbed out options.**
34
35 `adb shell am instrument -w -r -e <option> <value> -e class <suite>
36 android.platform.longevity.samples/android.support.test.runner.AndroidJUnitRunner`
37
38 **Run simple test suite 50 times, and quit when an error is encountered.**
39
40 `adb shell am instrument -w -r -e iterations 50 -e quitter true
41 -e class android.platform.longevity.samples.SimpleSuite
42 android.platform.longevity.samples/android.support.test.runner.AndroidJUnitRunner`
43
44 **Run simple test suite 10 times, shuffle all tests, and quit after 30 minutes.**
45
46 `adb shell am instrument -w -r -e iterations 10 -e shuffle true -e suite-timeout_msec 1800000
47 -e class android.platform.longevity.samples.SimpleSuite
48 android.platform.longevity.samples/android.support.test.runner.AndroidJUnitRunner`
49
50 **Run simple test suite 100 times, and quit when battery drops below 5%.**
51
52 `adb shell am instrument -w -r -e iterations 100 -e min-battery 0.05
53 -e class android.platform.longevity.samples.SimpleSuite
54 android.platform.longevity.samples/android.support.test.runner.AndroidJUnitRunner`
55
56 ## Options
57
58 * `iterations <int>` - the number of times to repeat the suite.
59 * `min-battery <double>` - quit if battery falls below this threshold.
60 * `shuffle <bool>` - shuffles all test cases in the repeated suite.
61 * `suite-timeout_msec <long>` - an overall timeout for the suite.
62 * `timeout_msec <long>` - a timeout for individual test methods.
63 * `quitter <bool>` - quit the suite if any test errors are encountered.
64
65 ## Tests
66
67 Host-side tests for the library can be built with the `LongevityHostLibTests` module under the
68 `tests/` directory. Run them using `java out/host/linux-x86/framework/LongevityHostLibTests.jar
69 org.junit.runner.JUnitCore <test class>`.
70
71 Device-side tests for the library can be built with the `LongevityLibTests` module under the
72 `tests/` directory. Run them using `adb shell am instrument -w -r
73 android.platform.longevity.tests/android.support.test.runner.AndroidJUnitRunner`.
74
75 ## Issues
76
77 If any issues are encountered, please send patches to recent contributors.
78