Android the Agile way

Post on 28-May-2015

830 views 4 download

Tags:

description

Thiyagu, Krishna, Soundar and Ashwin presented at xconf on some tools that can help support extreme programming practices on a project based of the Android platform

Transcript of Android the Agile way

Android - A Practitioner's take on doing it The Agile Way

Thiyagu, Krishna, Soundar, Ashwin

Can we run an Android Application Development Project the Agile Way?

As a practitioner, what are the effects of the Technical Stack

on the process?

How can I follow the 'Extreme Programming' Practices?

As ThoughtWorks why can we expect Android Projects?

Enterprises are looking for a Mobile Presence

Mostly CRUD Applications though.

Then Why a native app over a Web App?

Native Applications are much more enabled than a web

application 

etc.....

But why Android?

Steep increase in the user  base

Lots of new Vendors

So as ThoughtWorks, why have this capability?

We want to build something cool !

Disclaimer

Why is this not just a Java Project?

When you’re working with Android, it sure feels like you

are writing regular old standard Java SE code

You are not!!

So what is the difference?Its the runtime!!!!

In the Android platform, we have the Dalvik Runtime which

is specially designed for devices that are contrained in terms of memory, speed and

battery power.

Dalvik is not even a Java Virtual Machine at all!

It does not understand byte code. Instead...

It understands Dex Code

Everything you need as a programmer is available in the Dalvik implementation of Java

Why do I mention all this?

Because you might want to use something like JMock to

mock your dependencies when writing your unit tests

Its not a full Java SE implementation

Test Driven Development

The Application to be tested must/needs to run on a device

instance

Any entity that aims to test the Android Application must be on

the device instance as well

So the test in itself is Another Application!

Android Testing and Instrumentation

public class LoginActivity extends Activity     /* declarations of states*/        @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.login);             loginButton = (Button) findViewById(R.id.login_login_button);        usernameText = (TextView) findViewById(R.id.user_name_input);        passwordText = (TextView)findViewById(R.id.pass_word_input);        

        loginButton.setOnClickListener(new OnClickListener() {            public void onClick(View v) {                String username = usernameText.getText().toString();                String password = passwordText.getText().toString();                MyApplication.getLoginService().login(username, password);            }        });    }}

public class LoginActivityTest extends ActivityUnitTestCase<LoginActivity> {    public LoginActivityTest() {         super(LoginActivity.class);    }     protected void setUp() throws Exception {

        super.setUp();        ...    }   /* Other tests for testing whether the button and text box exists*/    public void testOnClickOfLoginButtonItShouldSendUserNameAndPassWordToLoginServiceForVerifying(){        String userName = "rapidftr";        userNameEditText.setText(userName);        String passWord = "rapidftr";        passWordEditText.setText(passWord);         LoginService loginService = EasyMock.createMock(LoginService.class);        EasyMock.expect(loginService.login(userName, passWord)).andReturn(true);        EasyMock.replay(loginService);         RapidFTRApplication.setLoginService(loginService);                loginButton.performClick();                 EasyMock.verify(loginService);    }}

Does the service Locator Pattern Seem like a bad idea?

Ensure that your Mocking Framework is supported by the

Dalvik VM

The problem with easy mock .... Mocking Concrete

Classes

So can we clean up this mockery?

Split the code into 2 types:1.Android Framework Dependent 2.Android Framework Independent

Over Engineering the code is Dangerous.

ActivityInstrumentationTestCase    

Continuous Integration

Android Debugger Bridge

adb install, -r, standup-timer-app.apk

The Testing Application and the Application under test are deployed on the same device

instance

Android Maven Plugin &Ant Script

  Android SDK Path

Platform UsedDevice Instance to use

<plugin>                   <groupId>com.jayway.maven.plugins.android.generation2</groupId>                   <artifactId>maven-android-plugin</artifactId>                   <version>2.5.1</version>                   <configuration>                       <sdk>                            <path>android_sdk</path>                           <platform>7</platform>                       </sdk>                       <emulator>                           <avd>my_avd</avd>                       </emulator>                       <deleteConflictingFiles>                            true                       </deleteConflictingFiles>                       <undeployBeforeDeploy>true</undeployBeforeDeploy>                   </configuration>                   <extensions>true</extensions>   </plugin>

Independent parts of the build

    // start tracing to "/sdcard/calc.trace"    Debug.startMethodTracing("calc");    // ...    // stop tracing    Debug.stopMethodTracing();

Time for Demo