Software Engineering Large Practical Debugging and Testing Android - - PowerPoint PPT Presentation

software engineering large practical debugging and
SMART_READER_LITE
LIVE PREVIEW

Software Engineering Large Practical Debugging and Testing Android - - PowerPoint PPT Presentation

Software Engineering Large Practical Debugging and Testing Android apps Stephen Gilmore School of Informatics, University of Edinburgh November 13th, 2013 Stephen Gilmore Software Engineering Large Practical News This is the last SELP


slide-1
SLIDE 1

Software Engineering Large Practical Debugging and Testing Android apps

Stephen Gilmore

School of Informatics, University of Edinburgh

November 13th, 2013

Stephen Gilmore Software Engineering Large Practical

slide-2
SLIDE 2

News

◮ This is the last SELP lecture.

Stephen Gilmore Software Engineering Large Practical

slide-3
SLIDE 3

Debugging Android Apps

In this lecture we consider debugging and testing our Android apps, using the Android debugger and the Android Robotium unit testing suite. We follow an example due to Lars Vogel, available at http://www.vogella.com/articles/AndroidDebugging/article.html

Stephen Gilmore Software Engineering Large Practical

slide-4
SLIDE 4

The problem: our app should display a list of countries, but it doesn’t

Stephen Gilmore Software Engineering Large Practical

slide-5
SLIDE 5

Getting started: Choose “Debug As”

Stephen Gilmore Software Engineering Large Practical

slide-6
SLIDE 6

Debug configurations

Stephen Gilmore Software Engineering Large Practical

slide-7
SLIDE 7

Switch to the “Debug” perspective to see new views such as “Variables” and “Breakpoints”

Stephen Gilmore Software Engineering Large Practical

slide-8
SLIDE 8

Stopping at a breakpoint in the onCreate method

Stephen Gilmore Software Engineering Large Practical

slide-9
SLIDE 9

Assigning a value to the list of countries

Stephen Gilmore Software Engineering Large Practical

slide-10
SLIDE 10

Inspecting the value of the countries variable: an array of empty strings [””, ””, ””, ””, ””, ..., ””]

Stephen Gilmore Software Engineering Large Practical

slide-11
SLIDE 11

Problem identified: Restart the debugging session

Stephen Gilmore Software Engineering Large Practical

slide-12
SLIDE 12

Entering the getCountries method

Stephen Gilmore Software Engineering Large Practical

slide-13
SLIDE 13

Continue executing, looking for updates to countries

Stephen Gilmore Software Engineering Large Practical

slide-14
SLIDE 14

Continue execution

Stephen Gilmore Software Engineering Large Practical

slide-15
SLIDE 15

A simple logic error is discovered: we want the country name if it is not empty

Stephen Gilmore Software Engineering Large Practical

slide-16
SLIDE 16

We are not able to swap in the new version of the code

Stephen Gilmore Software Engineering Large Practical

slide-17
SLIDE 17

We can terminate and relaunch this debugging session

14.59.05.png Stephen Gilmore Software Engineering Large Practical

slide-18
SLIDE 18

Success: a list of countries is displayed

Stephen Gilmore Software Engineering Large Practical

slide-19
SLIDE 19

Software testing

A test framework called Robotium is available for testing Android

  • applications. Using Robotium we can automate tests of Android

apps, and collect statistics on which tests passed and which tests failed, using the JUnit test framework.

Stephen Gilmore Software Engineering Large Practical

slide-20
SLIDE 20

Import Robotium and make an instance of Solo

Stephen Gilmore Software Engineering Large Practical

slide-21
SLIDE 21

Write a void method whose name begins with “test”

Stephen Gilmore Software Engineering Large Practical

slide-22
SLIDE 22

Run as an Android JUnit test

Stephen Gilmore Software Engineering Large Practical

slide-23
SLIDE 23

The emulator appears

Stephen Gilmore Software Engineering Large Practical

slide-24
SLIDE 24

The app under test launches

Stephen Gilmore Software Engineering Large Practical

slide-25
SLIDE 25

Values are entered in the fields

Stephen Gilmore Software Engineering Large Practical

slide-26
SLIDE 26

These values have been entered programmatically

Stephen Gilmore Software Engineering Large Practical

slide-27
SLIDE 27

The button click also is performed for us

Stephen Gilmore Software Engineering Large Practical

slide-28
SLIDE 28

All tests passed (there was only one)

Stephen Gilmore Software Engineering Large Practical

slide-29
SLIDE 29

If some failed, we can see which

Stephen Gilmore Software Engineering Large Practical

slide-30
SLIDE 30

Software testing

A testing framework such as Robotium allows us to formally document a series of tests which we expect our app to pass. These are embedded in the code of the test harness. After every change to our code we can re-run the test harness and check that all tests still pass. Automating testing in this way can turn a boring manual task which is a chore to do into a simple automatic task which is easy to re-run and operates entirely without human intervention.

Stephen Gilmore Software Engineering Large Practical