Generate Android testing reports in XML/HTML with Android CTS
2012-08-16 11:16
567 查看
When you run automated Android tests with Eclipse or from the command line, you get text output, which isn't good for reporting purposes. If you run a large set
of test cases with automated build, the text report isn't very helpful. Fortunately, Android CTS generates
test reports in XML with accompanying XSL to make it look nice in a browser.
To run your own tests with Android CTS:
Download Android CTS
Make a new directory
Copy
Create directory
Create directory
Copy
Under
where:
The
I created this file manually, but it should be pretty straightforward to write a tool with Java reflection or scripting with regex search if you have the source code.
Copy the test suite apk into
Run the tests with
of test cases with automated build, the text report isn't very helpful. Fortunately, Android CTS generates
test reports in XML with accompanying XSL to make it look nice in a browser.
To run your own tests with Android CTS:
Download Android CTS
Make a new directory
MyRepositoryunder
android-cts, alongside the existing
repositorydirectory.
Copy
host_config.xmlfrom
repositoryto
MyRepository
Create directory
plansunder
MyRepository, add a test plan (
MyTests.xml):
<?xml version="1.0" encoding="UTF-8"?> <TestPlan version="1.0"> <Entry uri="android.AndroidTest"/> </TestPlan>
Create directory
testcasesunder
MyRepository.
Copy
TestDeviceSetup.apkfrom
repository/testcasesto
MyRepository/testcases
Under
MyRepository/testcases, create a test package definition (
AndroidTest.xml, but can be any name you pick):
<?xml version="1.0" encoding="UTF-8"?> <TestPackage AndroidFramework="Android 1.0" appNameSpace="com.android.test" appPackageName="android.AndroidTest" name="AndroidTest" runner="android.test.InstrumentationTestRunner" version="1.0"> <TestSuite name="com"> <TestSuite name="android.test"> <TestCase name="AndroidTest"> <Test name="testCase1"/> <Test name="testCase2"/> <Test name="testCase3"/> <Test name="thisIsNotATest"/> </TestCase> <TestCase name="AAndroidTest"> <Test name="testCase1"/> <Test name="testCase2"/> </TestCase> </TestSuite> </TestSuite> </TestPackage>
where:
appNameSpaceis the package name of the test suite apk
appPackageNameis the name specified in the test plan
nameis the file name of the test suite apk
Testare the test methods to call
The
TestSuiteand
TestCasepaths should add up to be the full Java class name of the test class. In fact, the above definition is equivalent to:
<?xml version="1.0" encoding="UTF-8"?> <TestPackage AndroidFramework="Android 1.0" appNameSpace="com.android.test" appPackageName="android.AndroidTest" name="AndroidTest" runner="android.test.InstrumentationTestRunner" version="1.0"> <TestSuite name="com"> <TestSuite name="android.test"> <TestCase name="AndroidTest"> <Test name="testCase1"/> <Test name="testCase2"/> <Test name="testCase3"/> <Test name="thisIsNotATest"/> </TestCase> </TestSuite> <TestCase name="android.test.AAndroidTest"> <Test name="testCase1"/> <Test name="testCase2"/> </TestCase> </TestSuite> </TestPackage>
I created this file manually, but it should be pretty straightforward to write a tool with Java reflection or scripting with regex search if you have the source code.
Copy the test suite apk into
MyRepository/testcases. The final directory structure looks like this:
$ find MyRepository -type f MyRepository/plans/MyTests.xml MyRepository/testcases/AndroidTest.apk MyRepository/testcases/AndroidTest.xml MyRepository/testcases/TestDeviceSetup.apk MyRepository/host_config.xml
Run the tests with
android-cts:
$ cd android-cts/tools/ $ ./startcts ../MyRepository/host_config.xml Android CTS version 2.3_r7 cts_host > ls --plan List of plans (1 in total): MyTests cts_host > ls --plan MyTests Packages of plan MyTests (1 in total): ================================= android.AndroidTest cts_host > start --plan MyTests
相关文章推荐
- Generate mp4 video with image files using MediaCodec in Android
- Android: Simplified source code for parsing and working with XML data and web services in Android
- Android display local image/CSS files in HTML with WebView
- Android: Reading, using and working with XML data and web services in Android
- No way to generate HTML markup with data-link and helper functions in JsViews like in JsRender
- Admob广告的android显示 "you must have AdActivity declared in AndroidManifest.xml with configChanges"
- Android: html in strings.xml
- Generate mp4 video with image files using Jcodec in Android
- Android的string.xml中使用html与变量
- Error:(949) Multiple substitutions specified in non-positional format; Android格式化string.xml
- 电子书下载:Pragmatic Unit Testing in C# with NUnit
- Take Picture in Android with MediaStore.ACTION_IMAGE_CAPTURE
- Cocos2dx 2.0.2版本Android环境出错:Cannot find module with tag 'CocosDenshion/android' in import path
- Eclipse导入Gradle时报错:SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable
- cannot be resolved in either web.xml or the jar files deployed with this application
- Error:No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi
- Robotium_Automated UI testing for Android applications with Robotium
- SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID
- Bug--Error creating bean with name 'sessionFactory' defined in class path resource [data_context.xml
- Pragmatic Unit Testing in Java with JUnit