Month: June 2015

Automation of basic software installation on Ubuntu

2015-06-30 Linux, Ubuntu No comments

Recently, I had to re-install my system again and I didn’t want to go again through manual installation of software I use daily. Due to this fact, I decided to create shell script, which will download, install & configure software for me. It can be executed right after installing Ubuntu. Please remember, this applies to my configuration and may be not appropriate for yours (e.g. drivers for wireless Logitech headset). This script won’t install IDEs & editors like: Android Studio, IntelliJ IDE, Pycharm and Atom. You can download them manually from their websites. I realize, not everything is automated and we will have to confirm a few installations manually. Moreover, script won’t do everything I need. Nevertheless, it performs a lot of work for me and in case of system re-installation I can re-use this solution.
If you want to know more about software installed with this script, browse Linux & Ubuntu categories on this blog.

You can run the script with the following command:

$ curl -L https://gist.githubusercontent.com/pwittchen/1a6abe83cb7067d66f1c/raw/337564c6fd4e36d2ee372c5bce53bafeab162d62/install-stuff.sh | sh

Devoxx Poland 2015 – conference summary

2015-06-29 Conferences, Java No comments

This year, for the first time the Devoxx conference was held in Poland. There were plenty of lectures and experts to learn from.

On technical blog of Future Processing, you can find Devoxx Conference summary:
http://www.future-processing.pl/blog/devoxx-conference-summary/

In my opinion, one of the most interesting talks was prepared by Venkat Subrananiam and titled: “Get Past the Syntax, The Real Scare is in the Semantics”. That’s why I presented my thoughts connected with this presentation. Please, check out mentioned article to find more information about this and other topics.

Releasing Prefser v. 1.0.5

2015-06-18 Android No comments

I am happy to announce that I released version 1.0.5 of Prefser Android library.
Prefser is a wrapper for Android SharedPreferences with object serialization and RxJava Observables.

What has been done in this version:

Moreover you can browse auto-generated reports:

Some improvements wouldn’t be implemented without engagement of the open-source community on GitHub, so thanks for reporting your issues and providing suggestions! I am always open for improvements in my projects.

You can get new version of the library, its source code, download instructions and documentation at:

https://github.com/pwittchen/prefser

Java Annotated Monthly – June 2015 by JetBrains

2015-06-10 Java No comments

Today JetBrains published an interesting article about news and current state of Java on their blog.

jam_pic

We can read there about: JVM, Frameworks, Android, Performance and Community. It’s worth reading. Article can be found at:

http://blog.jetbrains.com/idea/2015/06/java-annotated-monthly-june-2015/

Test coverage report for Android application

2015-06-03 Android, Continuous Integration, Unit Tests 68 comments

Update: see newer article about Unit test coverage report with Travis CI for Robolectric on Android.

For a long time, I wasn’t able to find the right way to generate test coverage reports for Android instrumentation unit tests created with AndroidJUnit4 runner. In the past I’ve found many solutions, but none of them was working or they were compatible only with Robolectric, which I currently don’t use. Other developers also stopped using it for the new projects. E.g. Sqlbrite from Square is using AndroidJUnit4 runner as my projects do. Recently, I’ve found an interesting discussion on Reddit, where we can find information about enabling test coverage very easily without additional plugins, scripts and many lines of configuration. Moreover, Android SDK currently has built-in support for Emma Test Coverage, what we can read in official documentation.

Basically, the only thing we need to do, is to apply jacoco-android plugin in build.gradle file:

apply plugin: 'jacoco-android'

and then set testCoverageEnabled parameter to true as follows:

android {
   buildTypes {
      debug {
         testCoverageEnabled = true
      }
   }
}

In order to create test coverage report, we need Android device or emulator connected to the computer, because connectedCheck task needs to be executed before creating the report.

Next, we can execute the following Gradle task from CLI:

./gradlew createDebugCoverageReport

Task will analyze code of our project in /src/main/java/ directory and unit tests placed in /src/androidTest/java/ directory.
After executing this task, we can find test coverage report in the following directory of the module:

/build/outputs/reports/coverage/debug/

When we open index.html file, we can see visual report from test coverage, which can be viewed in a web browser.
Moreover, in the same directory, we can find report.xml file, which can used for test coverage analysis on continuous integration server.
Besides mentioned files, Gradle will generate coverage.ec file in the following directory:

/build/outputs/code-coverage/connected/

In some cases, we may need this file. E.g. if chosen Jenkins plugin or another tool will need it in order to generate test coverage report properly.

Below, you can see exemplary test coverage report for Prefser, which is an open-source Android library.

prefser_test_coverage_report_03.06.2015

This report was generated with JaCoCo code coverage library.

After analyzing test coverage report, I’ve added a few new unit tests, slightly modified the project and managed to obtain 100% test coverage.

prefser_test_coverage_04.06.2015

In order to publish our report on Jenkins CI, we can use test coverage plugins, but I am not sure about their stability. Another solution is HTML Publisher plugin. We can add post-build action and publish our test coverage report generated by default as HTML website inside Jenkins job. In my opinion, it’s quite convenient solution, because it is easy to set up and allows us to navigate to the code, browse uncovered lines, methods and branches.

Finally, with this clean and fast solution we can easily monitor test coverage of our Android projects, find bottlenecks and increase overall quality of the applications and libraries.