Profile cover photo
Profile photo
Alessio Franceschelli
software/web developer
software/web developer

Alessio's posts

Post has attachment

Post has attachment
Advantages and drawbacks of #ecmascript6 backward compatibility. At least #strict is on by default! #javascript

Post has attachment
Initialising a new device with +Android  #lollipop  it's a breeze! #nfc  

Post has attachment
Playing with the Google Drive Realtime API is damn fun! I added some black magic to this friend's page.

Good morning followers!

Google and the accidental mystery of Webdriver Torso via Engadget Android

Post has attachment

Post has attachment
Finally a Calendar update to easily pick the location!

Post has shared content
nice and easy!
Today’s #AndroidTesting #Protip from +Stephan Linzner is about unit testing your code using  Mockito.

Writing unit tests is an important part of the Android development cycle as it encourages an incremental development approach and allows you to easily refactor your code, to continuously improve its quality. Unit tests are all about dependencies or about replacing dependencies with test doubles [0]. This allows you to run your tests in isolation as much as possible. But this raises the question on how you can efficiently create test doubles in your unit tests. One way to create test doubles on Android is to use Mockito [1]. Mockito is an open source mocking framework that offers a fluent and readable API which allows for both “state-based-testing” (stubbing) as well as “behavioral-testing” (verifications) [2].

To get started with Mockito in your unit tests you need to include the following dependencies in your build.gradle file [3]:

dependencies {
    androidTestCompile 'org.mockito:mockito-core:1.9.5'
    androidTestCompile ''
    androidTestCompile ''

To create a mock object in your tests you can either use Mockito’s static methods or use annotations. 

AccountManager mMockAccountManager = mock(AccountManager.class);

This will create a mock object for Android’s AccountManager class. A slightly cleaner approach is to use the @Mock annotation which greatly improves readability of the test code.

private AccountSelectionUi mAccountSelectionUi;

Stubbing methods with mockito follows the when/then pattern. To stub a method, call 


Here, AccountMananger.getAccounts() will return a fake account when it is called by the AccountsController. This lets you easily simulate dependencies, which can be very handy when dealing with framework classes. But Mockito also allows for verifying interactions.


In this case we verify that the showAccounts() method was called on the AccountSelectionUi with the expected array of Account objects. You can find the sample code for the AccountsControllerTest in this gist

Mockito can be a very handy tool when it comes to creating test doubles, but be aware of it’s limitations. Mockito can't create mocks for final classes and methods. Mockito’s philosophy is that tests should be easy to understand and low maintenance, therefore use mocks to stub  dependent methods of the unit under test and assert on the state of your unit rather than using behavioral verification which will more likely result in a fragile test. Have other Mockito tips? Let us know in the comments. Happy testing!

[3] To use Mockito in Eclipse, you need to copy the following dependencies into the /libs folder of your Android test project.


Post has shared content
You MUST upgrade your iOS and OSX devices NOW to secure your network communications.

Apple SSL implementation is flawed and allows an attacker to intercept ALL encrypted (HTTPS) communication. Every iOS Apps are vulnerables (Safari, Facebook, Google+, Mail...) . On OSX Safari, iCloud, Mail and  many other apps  are also affected. Chrome is not affected on OSX.

Please it is very important that you  upgrade now as this vulnerability has been made public last night. In particular DO NOT connect to a public WiFi with an unpatched device.

To test if your device is vulnerable you can use the public website:

Help spread the word by re-sharing or +1 this post to ensure everyone promptly patch their devices.

For those interested in the technical details:
Apple cryptic patch notes After refers to a bug introduced in libsecurity_ssl which is the SSL library used by Apple ( This bug lead the SSL library to not check properly the hostname associated with a
given SSL cert which allows an attacker to easily snoop on any HTTPS site.
Wait while more posts are being loaded