1page.title=Trade Federation Overview 2@jd:body 3 4<!-- 5 Copyright 2015 The Android Open Source Project 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18--> 19<div id="qv-wrapper"> 20 <div id="qv"> 21 <h2>In this document</h2> 22 <ol id="auto-toc"> 23 </ol> 24 </div> 25</div> 26 27<p>Trade Federation (tradefed or TF for short) is a continuous test framework designed for running tests 28on Android devices. It's a Java application which runs on a host computer, and communicates to one or 29more Android devices using ddmlib (the library behind DDMS) over adb.</p> 30 31<p>We've listed some of TF's main features below, along with a couple sample usecases. That said, 32if you want to jump right in and get started, you can head straight for the 33<a href="/devices/tech/test_infra/tradefed/fundamentals/index.html">Start Here</a> page.</p> 34 35<h2>Features</h2> 36<ul> 37<li>modular, flexible, scalable design</li> 38<li>has built in support for running many different types of Android tests: 39 <a href="http://developer.android.com/tools/testing/testing_android.html#Instrumentation">instrumentation</a>, 40 <a href="http://developer.android.com/tools/testing/testing_ui.html">uiautomator</a>, 41 native/gtest, host-based JUnit, etc</li> 42<li>provides reliability and recovery mechanisms on top of adb</li> 43<li>supports scheduling and running tests on multiple devices in parallel</li> 44</ul> 45 46<h2>Sample Trade Federation Usecases</h2> 47<p>Trade Federation's modularity makes it straightforward to slot into environments with existing 48build, test, and reporting infrastructures. We list below a few demonstrative 49usecases where tradefed could enable efficient, scalable test practices.</p> 50 51<p>First, it is useful to consider the landscape of potential usecases in terms of the question 52"which parts are modifiable, and what parts are static?" For instance, a Device OEM can modify the 53framework, the system, and the hardware, but has little or no influence over existing applications. 54An application developer, on the other hand, can modify the app, but has little control over most 55aspects of the system or the framework.</p> 56 57<p>As a result, an entity in each usecase will have different testing goals, and will have different 58options in the case of a set of test failures. Despite these differences, Trade Federation can 59help make each of their test processes efficient, flexible, and scalable.</p> 60 61<h3>Device OEM</h3> 62<p>A Device OEM builds hardware, and will often tweak the Android system and frameworks to run well 63on that hardware. The OEM might strive to accomplish those goals while retaining stability 64and performance at the hardware and system levels, and making sure the framework changes don't break 65compatibility with existing applications.</p> 66 67<p>The OEM could implement a device flashing module that will execute during the Target Setup stage 68of the <a href="/devices/tech/test_infra/tradefed/fundamentals/lifecycle.html">lifecycle</a>. That 69module would have complete control over the device during its execution period, which would allow 70it to potentially force the device into the bootloader, flash, and then force the device to reboot 71back into userspace mode. Combined with a module to tie into a continuous build system, this would 72allow the OEM to run tests on their device as they make changes to the system-level firmware and 73Java-level frameworks.</p> 74 75<p>Once the device is fully booted, the OEM would be able to leverage existing JUnit-based tests, 76or write new ones, to verify the functionality of interest. Finally, they could write one or more 77result reporting modules to tie into existing test-result repositories, or to report results 78directly (for instance, 79<a href="/reference/com/android/tradefed/result/EmailResultReporter.html">by email</a>).</p> 80 81<h3>App Developer</h3> 82<p>An Application Developer builds an app which needs to run well across a variety of platform 83versions and a variety of devices. If an issue comes up on a particular platform version and/or 84device, the only remedy is to add a workaround and move on. For larger developers, the test 85process might be incorporated into a continuous build sequence. For smaller developers, it 86might be kicked off periodically or by hand.</p> 87 88<p>Most app developers would use the apk test installation modules that already exist in TF. 89There's a version that <a href="/reference/com/android/tradefed/targetprep/InstallApkSetup.html" 90>installs from the local filesystem</a>, as well as a version that can 91<a href="/reference/com/android/tradefed/targetprep/InstallBuildEnvApkSetup.html">install 92apks downloaded from a build service</a>. It is important to note that the latter version would 93continue to work properly with arbitrarily many TF instances running on the same host machine.</p> 94 95<p>Because of TF's proficiency at dealing with multiple devices, it would be straightforward to 96classify each test result by the type of device that was used for that test. Thus, TF could 97potentially generate a 2-dimensional (or multi-dimensional) compatibility matrix for every 98build of the application.</p> 99 100<h3>Testing Service</h3> 101<p>A Test Service might, for instance, allow app developers to submit apps and run tests on devices 102instrumented with power-measurement tools to determine power usage for the app. This differs from 103the prior two usecases in that the service builder does not control the devices or the applications 104that are being run</p> 105 106<p>Because Trade Federation can run any Java class that implements the simple 107<a href="/reference/com/android/tradefed/testtype/IRemoteTest.html">IRemoteTest</a> interface, it's 108trivial to write drivers that can coordinate some external piece of hardware with the test case 109that's being run on the device. The driver itself can spawn Threads, send requests to other 110servers, or do anything else that it might need. Moreover, the simplicity and versatility of the 111result reporting interface, 112<a href="/reference/com/android/tradefed/result/ITestInvocationListener.html" 113>ITestInvocationListener</a>, means that it is likewise straightforward to 114represent arbitrary test results (including, for instance, numerical power metrics) into the 115standard result reporting pipeline.</p> 116