Monday, May 16, 2016

How to Install Android Studio on Ubuntu 14.04

Followings are steps needed to install Android Studio on Ubuntu 14.04:

There are some tutorials that suggest the installation using PPA. However, sometime it does not work because the PPA listed is no longer available or for any other reasons. In this post, I write manual way for installation. This way is much safer and more guarantee that it will work. Please let me know if you have any problem.

Preparation
If you run 64-bit ubuntu, install the following packages first. If you run 32-bit, you may skip this step and go to the next step
$ sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6
Download JDK from Oracle
You can download from their website. When I write this post, the download page is located here. However, they may move the download page. In case you don't find in that link, you can ask Google to find the download page for you.

Extract JDK
You can use Files Manager or use terminal. If you want to use terminal, you can use this command:
$ tar xzf jdk-8u92-linux-x64.tar.gz
Install JDK 
Install jdk into /usr/bin
$ update-alternatives --install /usr/bin/java java /home/arwan/Downloads/jdk1.8.0_92/bin/java 100

$ update-alternatives --install /usr/bin/javac javac /home/arwan/Downloads/jdk1.8.0_92/bin/javac 100

Check if java has been installed
$ java -version

Download Android Studio
You can download Android studio here.

Extract Android Studio
$ unzip android-studio-ide-143.2821654-linux.zip

Move all android-studio folder to /usr/local
$ mv /home/arwan/Downloads/android-studio /usr/local

Install Android Studio
$ /usr/local/android-studio/bin/studio.sh
Next, just follow the steps until your Android Studio is installed.

Friday, April 22, 2016

Make UnitTest Report Using HTMLTestRunner

I am a big fan of Python, and I am a big fan of TDD (Test Driven Development). The problem that I face for team development was that it is quite difficult to communicate the testing results to the team, because the results are in terminal so only us and God know :D

Fortunately, somebody out there know my problem and create this amazing HTMLTestRunner.py. This tool is very handy and very easy to use. It almost feels like you don't need to do anything. OK, here's one example on how we use HTMLTestRunner. Ah, forget it. Download HTMLTestRunner.py from this website, and put somewhere in your computer. Say in this example, I put in ~/Downloads/HTMLTestRunner folder

import unittest
import sys
_path = r"Downloads/HTMLTestRunner"
sys.path.append(_path)
import HTMLTestRunner

class TestDemo(unittest.TestCase):
    def testA(self):
        assert True
    def testB(self):
        assert False

class TestDemo2(unittest.TestCase):
    def testC(self):
        assert True
    def testD(self):
        assert True

def suite():
    suite = unittest.TestSuite()
    # TestDemo
    suite.addTest(TestDemo('testA'))
    suite.addTest(TestDemo('testB'))
    # TestDemo2
    suite.addTest(TestDemo2('testC'))
    suite.addTest(TestDemo2('testD'))

    return suite

if __name__ == "__main__":
    suite = suite()
    unittest.TextTestRunner(verbosity=2)
    output = open("results.html", 'w')
    runner = HTMLTestRunner.HTMLTestRunner(stream=output, title='Test Report', description='This is a test')
    runner.run(suite)

After you run it, boom... you will get a beautiful and informative report in html file. Here is the results in my example:

Thursday, April 21, 2016

Import Python Script to SikuliX

When we need to import python script into sikulix workspace, here is one of the way to do:

1. Import sys
2. Append the path to the script into sys.path
3. Import your python script

Here is an example

import sys

sys.path.append("/Users/arwankhoiruddin/Downloads/python_packages/HTMLTestRunner")

import HTMLTestRunner

However, it has some limitations. You should refer to this document: https://answers.launchpad.net/sikuli/+faq/1114