Friday, September 10, 2010

Unit Testing for J2ME - JMUnit

In professional development environment it is a common practice to create Unit Tests. On Java platform there are lots of research and development done on Unit Tests for Enterprise Edition. As far as Java Micro Edition is concerned one of the framework available is JMUnit.

Creating and executing a test case using jmunit is quite simple and can be done without wasting much time to explore it. Following steps will guide you how to work with jmunit:

  •  In your mobile application right click on package (where you want to create a unit test) and select option 'New > Empty JMUnit Test'.
  • It will create a unit test class for you that will look like this:
    /*
     * ABCTest.java
     * JMUnit based test
     *
     */
    
    package hello;
    
    
    import jmunit.framework.cldc10.*;
    
    /**
     * @author rizwan
     */
    public class ABCTest extends TestCase {
        
        public ABCTest() {
            //The first parameter of inherited constructor is the number of test cases
            super(0,"ABCTest");
        }            
    
        public void test(int testNumber) throws Throwable {
        }    
    }  

    • Next you will create a test method in same class and call it in test() using switch cases.
    • Total count of test cases will also be mentioned in unit class constructor.
    • Now the code will look like this:

    /*
     * ABCTest.java
     * JMUnit based test
     *
     */
    
    package hello;
    
    
    import jmunit.framework.cldc10.*;
    
    /**
     * @author rizwan
     */
    public class ABCTest extends TestCase {
        
        public ABCTest() {
            //The first parameter of inherited constructor is the number of test cases
            super(1,"ABCTest");
        }            
    
        public void test(int testNumber) throws Throwable {
            switch(testNumber){
                case 0: 
                    testOne();
                    break;
            }
        }    
    
        private void testOne() throws Exception{
            String tmp = "Hello Rizwan";
            assertEquals(tmp, "Hello Rizwan");
        }
    } 

    • After that you have to mention 'ABCTest' as your Midlet.
    • Go into 'project properties > Application Descriptor > MIDlets' and define unit test name and package here.
    • Run application and you will also get Test option on screen:  
    • Test the project and it will show you the results




    Your mobile test case is ready !

    rizzz86

    Saturday, September 4, 2010

    Open Transport Tycoon Deluxe (TTD)

    TTD is one of my most favorite games that I have played and when I saw the 'Open' with it, I was really excited to install it on my Ubuntu OS.

    The installation of Open TTD is difficult and you need to be a bit keera of shell scripting to do this job. I have followed all the steps on this link and managed to install OTTD successfully. After completing installation and launching the game I was really amazed by watching the same TTD main screen as what I was playing on my 'Windows OS' four years back.


    The game is upgraded now and contains four different types of maps with each map containing different industries, disasters, vehicles etc. Maps are also really interesting with environment like a Desert area map, Snow area map, Toyland area map and a default one as well. I have some getty images of the game that are as follows:


    All TTD lovers do enjoy this on your Linux OS.

    rizzz86

    Friday, September 3, 2010

    Amir, Asif & Salman - From Hero to Zero


    Pakistani cricketers are again under a controversy and this time it is a serious one - the FIXING case :|

    The trio who are Hero of last week are now Zero. In my last blog I am really excited of Pakistan's fighting win over England and now I am not much interested to even watch a cricket match.

    Is it a non-professionalism or a trap or anything else - the trio-players has taken part in this show of money. The future of these players is still not clear and are at stake. But as a Pakistani I am still hoping these players will not have a life ban and will play cricket after completing their punishments.

    rizzz86

    Sunday, August 22, 2010

    Pakistan beat England after 9 Years


    A victory dedicated to the flood victims of Pakistan.

    Pakistan beat England in England after 9 years in a Test Match is another huge achievement by a rookie team within a month. Previously they beat Australia after 15  years in a Test Match.

    A good team work by Pakistani bowlers as well as batsmen has done the work for Pakistan. Taking a first inning lead and excellent comeback by Paki bowlers in the 2nd innings has provided them a victory. There are lots of moments and achievements in a match that really boost the team moral. Some of them includes 1) Wahab Riaz's superb debut 5 wicket hall, 2) M. Yousuf solid comeback in a International side, 3) M. Amir becomes the youngest bowler to take 5 wicket hall in England in a Test Match and become a Man of the Match, 4) Saeed Ajmal's Spin magic, 5) Azhar Ali's unbeaten rock knock of 92* in the first innings and 6) Kamran Akmal's shocking 8 catches to reach his 200 dismissals in a Test Match.

    Also a big relief for a new captain Salman Butt to still remain in the series. We all are hoping to win the Lord's Test to level the series.


    Yousuf is a class act.

    rizzz86

    Wednesday, August 18, 2010

    Flood Relief Update Link

    Following link contains the activities performed by a group of people ( from IT/Software Industry of Karachi) for flood victims:

    http://floodreliefupdates.blogspot.com/


    rizzz86

    Saturday, July 31, 2010

    Cricket - Rookie Paki Beat Aussies in Tests "Unbelievable"

    At last Pakistan has proved that they are now better than Bangladesh and Zimbabwe after beating Australia once in last 15 years. The hard fought three wicket win over Aussies boost the team's confidence and allow the rookie captain "Salman Butt" to retain his captaincy role.

    When you look at the Pakistani team, currently they are the most weakest team in the history of Pakistan cricket. There are no bowling option for Wasim, Waqar, Shoaib Akhtar, Saqlain, Mushtaq etc - even than they can able to bowl Aus out on 88. Also the worst ever batting line-up missing Saeed, Inzamam, Yousuf, Younus etc - even than they can able to chase the target (credit goes to the bowlers).

    Early Captaincy Role:
    Salman Butt is very early for Test match captaincy but he has to take this responsibility. The practice for assigning captaincy role to some one who is early in his career stages is not bad for some teams - for example we have Smith for SouthAfrica, Strauss for England and Dhoni for India. But these three players have proved themselves as a right captain with their performances. We are also expecting same from Butt.

    I have gathered some numbers/stats of the match that are as follows:

    The Age Factor:

    Australia:
    Shane Watson (29), Simon Katich (34), Ricky Ponting (35), Michael Clark (29), Michael Hussey (35), Marcus North (31), Tim Paine (25), Steven Smith (21), Mitchell Johnson (28), Ben Hilfenhaus (27), Dough Bollinger (29)
    Total Sum = 323
    Average Age = 29.3

    Pakistan:
    Imran Farhat (28), Slaman Butt (25), Azhar Ali (25), Umar Amin (20), Umar Akmal (20), Shoaib Malik (28), Kamran Akmal (28), Mohammad Amir (18), Umar Gul (26), Danish Kaneria (29), Mohammad Asif (28)
    Total Sum = 275 (Not even a single player exceeds Australia's average age)
    Average Age = 25

    Test Matches Played:

    Australia:

    Shane Watson (20), Simon Katich (52), Ricky Ponting (146), Michael Clark (62), Michael Hussey (52), Marcus North (17), Tim Paine (2), Steven Smith (2), Mitchell Johnson (36), Ben Hilfenhaus (11), Dough Bollinger (10)
    Total Sum =  410
    Average Matches = 37

    Pakistan:
    Imran Farhat (35), Slaman Butt (29), Azhar Ali (2), Umar Amin (2), Umar Akmal (8), Shoaib Malik (30), Kamran Akmal (50), Mohammad Amir (10), Umar Gul (28), Danish Kaneria (60), Mohammad Asif (19)
    Total Sum = 273
    Average Matches =24.8


    This is what talent and spirit is all about. Pakistan has beaten Australia that are much better as the stats suggests.

    rizzz86