Download - Introducción a Pruebas en Android
2
• Conocer los aspectos básicos para escribir pruebas en Android
• Aprender las primeras clases del api d epruebade Android.
Objetivos
Objetivos
3
1. Introducción
2. Android TestingProject
3. Asserts
4. Clases Base para Pruebas
5. Para Saber Más
Índice
Índice
4
Introducción
5
Introducción
6
Introducción
Clase base para pruebas
Proyectos de prueba
Mocks
Asserts
7
Android Testing Project
Proyecto de prueba
9
Asserts
Asserts
11
Clases Base paraPruebas + Mocks
Clases Base para Pruebas
Qué probar class TestCase
JUnit 3
framework::TestCase
- fName: String
+ countTestCases() : int
# createResult() : TestResult
+ getName() : String
+ run() : TestResult
+ run(TestResult) : void
+ runBare() : void
# runTest() : void
+ setName(String) : void
# setUp() : void
# tearDown() : void
+ TestCase()
+ TestCase(String)
+ toString() : String
framework::Assert
Código que no utiliza el API de Android.• Conectarse a Internet y traer un RSS
(librerías de apache incluidas en el API).
Clases Base para Pruebas
Qué probar class TestCase
android.test
JUnit 3
framework::TestCase
+ countTestCases() : int
+ getName() : String
+ run() : TestResult
+ run(TestResult) : void
+ runBare() : void
+ setName(String) : void
+ TestCase()
+ TestCase(String)
+ toString() : String
framework::Assert
test::AndroidTestCase
# mContext: Context
- mTestContext: Context
+ assertActivityRequiresPermission(String, String, String) : void
+ assertReadingContentUriRequiresPermission(Uri, String) : void
+ assertWritingContentUriRequiresPermission(Uri, String) : void
+ getContext() : Context
+ getTestContext() : Context
+ setTestContext(Context) : void
+ testAndroidTestCaseSetupProperly() : void
Código que utiliza el contexto de la aplicación:• Acceso a SQLite
Clases Clases Base para Pruebas Base para Pruebas
Qué probar class TestCase
android.test
JUnit 3
framework::TestCase
+ countTestCases() : int
+ getName() : String
+ run() : TestResult
+ run(TestResult) : void
+ runBare() : void
+ setName(String) : void
+ TestCase()
+ TestCase(String)
+ toString() : String
framework::Assert
ActivityTestCase
T:extends Activity
test::ActivityInstrumentationTestCase2
~ mActivityClass: Class<T>
~ mActivityIntent: Intent = null
~ mInitialTouchMode: boolean = false
+ ActivityInstrumentationTestCase2(String, Class<T>)
+ ActivityInstrumentationTestCase2(Class<T>)
+ getActivity() : T
+ setActivityInitialTouchMode(boolean) : void
+ setActivityIntent(Intent) : void
Actions• Actions en un
estado real• Métodos del ciclo
de vida• Vistas
Clases Base para Pruebas
Services
Content Providers
16
Para saber más
Para saber más
Snippets de ejemplo: https://github.com/javierj/android-test-
snippets