Testing with Android Part I of II. Android Testing Framework Based on JUnit The Android JUnit extensions provide component-specific test case classes.

Slides:



Advertisements
Similar presentations
Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.
Advertisements

1.A tool helps us mange the state of an emulator instance or Android-powered device 2.It is client-sever program that include three comopnents: 1). A.
Content Testing In Eclipse, with ADT Android Testing Framework
J-Unit Framework.
Android Tools & Wireless ADB Αντρέας Λύμπουρας Θεόφιλος Φωκάς Ζαχαρίας Χ’’Λάμπρου.
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
Cell phones off Name signs out – congrats Sean! CSE 116 Introduction to Computer Science for Majors II1.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
The Android Development Environment.  Getting started on the Android Platform  Installing required libraries  Programming Android using the Eclipse.
Introduction to Eclipse, Unit Testing and JUnit David Rabinowitz.
More Java: Encapsulation, Getters, Setters, Anonymous Class 1 CS300.
JUnit. What is unit testing? A unit is the smallest testable part of an application. A unit test automatically verifies the correctness of the unit. There.
Android: Hello World Frank Xu Gannon University. Steps Configuration ▫Android SDK ▫Android Development Tools (ADT)  Eclipse plug-in ▫Android SDK and.
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of The Java Development Tools project.
Presentation Outline What is JUnit? Why Use JUnit? JUnit Features Design of JUnit Downloading JUnit Writing Tests – TestCase – TestSuite Organizing The.
Basic, Basic, Basic Android. What are Packages? Page 346 in text Package statement goes before any import statements Indicates that the class declared.
Automated Unit Testing. Test Automation Manual testing is laborious and time consuming. Computer automation has transformed many sectors of our economy.
Android Application Development with Java UPenn CS4HS 2011 Chris Murphy
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
Setting up the Development Environment Copyright © SUPINFO. All rights reserved Preparation.
How to make it work? Doncho Minkov Telerik Academy academy.telerik.com Technical Trainer
Robotium Tran Dai T1309L. Introduce What is Robotium ? How can setup ? Why we need Robotium ? When.
© Frank Mueller & Seokyong Hong (TA) North Carolina State University Center for Efficient, Secure and Reliable Computing Android Installation Guide (2)
Android Programming. Outline Preparation Create new project Build and Run a project Debug a project Deploy on devices.
Sayed Ahmed BSc. Eng. In Computer Sc. and Eng. (BUET), Bangladesh MSc., Computer Science, Canada President/Chief Architect/Lead Developer Justetc (Just.
Mobile Programming Lecture 1 Getting Started. Today's Agenda About the Eclipse IDE Hello, World! Project Android Project Structure Intro to Activities,
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Wireless Mobility with Android 1 Presented by: Ung Yean MS. Computer Science American University, Washington DC, USA.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
Intro to Android Development Ben Lafreniere. Getting up and running Don’t use the VM! ials/hello-world.html.
Ali Shahrokni Application Components Activities Services Content providers Broadcast receivers.
Capture and Replay Often used for regression test development –Tool used to capture interactions with the system under test. –Inputs must be captured;
DUE Hello World on the Android Platform.
Presented By: Muhammad Tariq Software Engineer Android Training course.
ANDROID – TESTING L. Grewe. With the AndroidStudio IDE.
CSC 216/001 Lecture 4. Unit Testing  Why is it called “unit” testing?  When should tests be written?  Before the code for a class is written.  After.
JUnit test and Project 3 simulation. 2 JUnit The testing problems The framework of JUnit A case study Acknowledgement: using some materials from JUNIT.
Android Development Environment Environment/tools Windows Eclipse IDE for Java Developers (v3.5 Galileo) Java Platform (JDK 6 Update 18) Android.
Creating an Example Android App in Android Studio Activity lifecycle & UI Resources.
(1) Unit Testing and Test Planning CS2110: SW Development Methods These slides design for use in lab. They supplement more complete slides used in lecture.
JUnit Dwight Deugo Nesa Matic
Unit Testing with JUnit and Clover Based on material from: Daniel Amyot JUnit Web site.
JUnit Dwight Deugo Nesa Matic
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
JUnit Eclipse, Java and introduction to Junit. Topics Covered  Using Eclipse IDE  Example Java Programs  Junit Introduction.
Testing in Android. Methods Unit Testing Integration Testing System Testing Regression Testing Compatibility Testing Black Box (Functional) White Box.
Enterprise Java v090125Dev Env Overview1 Enterprise Java ( ) Development Environment Overview.
1 CSC 216 Lecture 3. 2 Unit Testing  The most basic kind of testing is called unit testing  Why is it called “unit” testing?  When should tests be.
JUnit A Unit Testing Framework for Java. The Objective Introduce JUnit as a tool for Unit Testing Provide information on how to: Install it Build a test.
ANDROID APPLICATION DEVELOPMENT. ANDROID DEVELOPMENT DEVELOPER.ANDROID.COM/INDEX.HTML THE OFFICIAL SITE FOR ANDROID DEVELOPERS. PROVIDES THE ANDROID SDK.
Unit, Regression, and Behavioral Testing Based On: Unit Testing with JUnit and CUnit by Beth Kirby Dec 13, 2002 Jules.
Test a Little, Code a Little Colin Sharples IBM Global Services New Zealand Colin Sharples IBM Global Services New Zealand.
Unit Testing. F-22 Raptor Fighter Manufactured by Lockheed Martin & Boeing How many parts does the F-22 have?
Software Design– Unit Testing SIMPLE PRIMER ON Junit Junit is a free simple library that is added to Eclipse to all automated unit tests. The first step,
Topic: Junit Presenters: Govindaramanujam, Sama & Jansen, Erwin.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Guide To Develop Mobile Apps With Titanium. Agenda Overview Installation of Platform SDKs Pros of Appcelerator Titanium Cons of Appcelerator Titanium.
Is it really possible to test my app? By Paweł Suszek
SWE 434 SOFTWARE TESTING AND VALIDATION LAB2 – INTRODUCTION TO JUNIT 1 SWE 434 Lab.
Android Programming.
Lab7 – Advanced.
Introduction to JUnit CS 4501 / 6501 Software Testing
Development-Introduction
Introduction to JUnit CS 4501 / 6501 Software Testing
The Most Popular Android UI Automation Testing Tool Andrii Voitenko
JUnit Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from the Eclipse 3.0 and.
JUnit Tutorial Hong Qing Yu Nov 2005.
Presentation transcript:

Testing with Android Part I of II

Android Testing Framework Based on JUnit The Android JUnit extensions provide component-specific test case classes.

Android Testing Framework Test suites are contained in test packages that are similar to main application packages. The SDK tools for building and tests are available in Eclipse with ADT, and also in command-line form for use with other IDES.

Android Testing Framework These tools get information from the project of the application under test and use this information to automatically create the build files, manifest file, and directory structure for the test package. The SDK also provides monkeyrunner, an API testing devices with Python programs, and UI/Application Exerciser Monkey, a command-line tool for stress-testing UIs by sending pseudo- random events to a device.

Android Testing Framework

JUnit You can use the JUnit TestCase class to do unit testing on a plain Java object. TestCase is also the base class for AndroidTestCase, which you can use to test Android-dependent objects. Besides providing the JUnit framework, AndroidTestCase offers Android-specific setup, teardown, and helper methods.

Testing from Eclipse with ADT ADT provides several features that help you set up and manage your testing environment effectively: It lets you quickly create a test project and link it to the application under test. It lets you quickly import the classes of the application under test. It lets you create run configurations for your test package and include in them flags that are passed to the Android testing framework. It lets you run your test package without leaving Eclipse.

Creating a Test Project

The class contains definitions for four methods: HelloAndroidTest: This defines the constructor for the class. It is required by the Android testing framework. setUp(): This overrides the JUnit setUp() method. You use it to initialize the environment before each test runs. testPreconditions(): This defines a small test that ensures the Hello, Android application starts up correctly. testText(): This tests that what is displayed on the screen is the same as what is contained in the application's string resources. It is an example of a real unit test you would perform against an application's UI.

Creating the Test Case Class

HelloAndroidTest.java package com.example.helloandroid.test; import android.test.ActivityInstrumentationTestCase2; import com.example.helloandroid.HelloAndroid; public class HelloAndroidTest extends ActivityInstrumentationTestCase2 { }

Constructor private HelloAndroid mActivity; private TextView mView; private String resourceString; public HelloAndroidTest() { super("com.example.helloandroid",HelloAndroid. class); }

protected void setUp() throws Exception { super.setUp(); mActivity = this.getActivity(); mView = (TextView) mActivity.findViewById (com.example.helloandroid.R.id.textview); resourceString = mActivity.getString (com.example.helloandroid.R.string.hello); }

Adding a preconditions test A preconditions test checks the initial application conditions prior to executing other tests. public void testPreconditions() { assertNotNull(mView); }

Adding a unit test public void testText() { assertEquals(resourceString,(String)mView.getT ext()); }

Finished Class - 1 package com.example.helloandroid.test; import com.example.helloandroid.HelloAndroid; import android.test.ActivityInstrumentationTestCase2; import android.widget.TextView; public class HelloAndroidTest extends ActivityInstrumentationTestCase2 { private HelloAndroid mActivity; // the activity under test private TextView mView; // the activity's TextView (the only view) private String resourceString; public HelloAndroidTest() { super("com.example.helloandroid", HelloAndroid.class); }

Finished protected void setUp() throws Exception { super.setUp(); mActivity = this.getActivity(); mView = (TextView) mActivity.findViewById(com.example.helloandroid.R.id.textview); resourceString = mActivity.getString(com.example.helloandroid.R.strin g.hello); } public void testPreconditions() { assertNotNull(mView); } public void testText() { assertEquals(resourceString,(String)mView.getText()) ; }

Running Tests When you run a test package in Eclipse with ADT, the output appears in the Eclipse JUnit view. You can run the entire test package or one test case class. To do run tests, Eclipse runs the adb command for running a test package, and displays the output, so there is no difference between running tests inside Eclipse and running them from the command line.