• No results found

Testing and Debugging using the Blackberry JDE

Introduction

Providing a good user experience in your mobile application is one of the key aspects in making it successful. A good user experience means that at bare minimum the mobile application should be free of runtime exceptions that would prevent the user from completely a task that your application provides. In order to ensure that you have developed an error free application testing and debugging your application prior to distribution is extremely important. The Blackberry JDE offers developers tools for both testing and debugging their mobile applications. This tutorial will describe how to use those tools.

Testing and Debugging with the Blackberry JDE

Open up the Blackberry JDE and load your Blackberry application into the workspace.

Once you are ready to begin testing your application you can go to the ‘Debug’ menu on the menu list and select ‘Go’, alternatively you can hit F5 in the Blackberry JDE. This will launch the Blackberry simulator and debugger. There is an output field at the bottom of the screen with the ‘Debug’ tag shown as figure 25, this field can be used to write System.out messages and System.err messages while running your application and viewing the status of the simulator. This is the quick and simple method of debugging your application.

Figure 25 - Debug Area

Prior to executing our application in the simulator we can also add breakpoints in our application to help us diagnose problems or look at current issues in our application. To set breakpoints in our application we can return to the ‘Debug’ menu at the top of the JDE as shown in figure 26. We can set breakpoints at any location our cursor is in the code or in specific instances such as when an exception is thrown.

Figure 26 - Debug Menu

Stopping at a breakpoint in our application will provide us with data regarding the current state of the application. Once you have set a breakpoint in your code, run your

application to that breakpoint. Once the Blackberry JDE hits that breakpoint we have several more screens that provide us information. We can view the call stack of our simulator to the left of our code, shown below in figure 27.

Figure 27 - Call Stack

We also have a number of commands we can execute such as stepping into the code, skipping lines, or exiting methods. These commands are found in the ‘Debug’ menu and the top of the screen as individual buttons. In the bottom right corner of the Blackberry JDE we can view the values of variables throughout our application shown as figure 28.

You can also view other aspects such as threads, locked objects, processes, etc. from the

‘View’ menu item on the menu bar.

Figure 28 - Variable View

At this point take some time to step through the code and view how the variables change in the different screens as the code is executed.

Moving back to the different views, we can examine which code in our

application is used at certain points in time. We can do this by going to the ‘View’ menu item and selecting ‘Coverage’. This action will open a window at the top of our

Blackberry JDE. Run your application again and stop at the breakpoint you have set. In the code coverage window we can hit the ‘Refresh’ button to see the results. We will see green and red markers in our code now. The green points will represent code executed while the red will represent code not executed. Finally, we can also attach the debugger to an actual Blackberry device. With your device plugged into your computer, return to the ‘Debug’ menu and select the ‘Attach to’ and then ‘Handheld’. You will be required to enter your password and may be displayed with a dialog with a missing debug file, we can ignore this missing file if it is not your application. You should see an ‘attach:

success’ message in the debug window at the bottom of the JDE. We can then continue debugging our application as we did with the simulator through the code on our screen if it is the same as the one on the device.

Conclusion

In this tutorial we saw the ability of the Blackberry JDE to assist us in testing and debugging our mobile applications. The Blackberry JDE has several different screens which provide information regarding variables, call stacks, code coverage, and others.

The Blackberry JDE can also debug on a physical device along with the simulator.

Glossary

.ALX

Blackberry Application Loader File BES

BlackBerry Enterprise Server Caret

The term used by to indicate the cursor used when editing a text field CDC

The Connected Device Configuration (CDC) is a specification for a Java ME

configuration. Conceptually, CDC deals with devices with more memory and processing power than CLDC; it is for devices with an always-on network connection and a

minimum of 2 MB of memory available for the Java system.

CLDC

The Connected, Limited Device Configuration (CLDC) is a specification for a Java ME configuration. The CLDC is for devices with less than 512 KB or RAM available for the Java system and an intermittent (limited) network connection. It specifies a stripped-down Java virtual machine1 called the KVM as well as several APIs for fundamental application services.

EDGE

Enhanced Data rates for GSM Evolution GPRS

General Packet Radio Service JAD

Java Application Descriptor (JAD) files describe the MIDlets (Java ME applications) that are distributed as JAR files. JAD files are commonly used to package Java applications or games that can be downloaded to mobile phones. Java applications enable Mobile phones to interact programmatically with online web services, such as the ability to send SMS messages via GSM mobile internet or interact in multiplayer games.

JDE

Java Development Environment KVM

The KVM is a compact Java virtual machine (JVM) that is designed for small devices. It supports a subset of the features of the JVM. For example, the KVM does not support floating-point operations and object finalization.

MIDP

The Mobile Information Device Profile is a set of Java APIs that is generally

implemented on the Connected Limited Device Configuration (CLDC). It provides a basic Java ME application runtime environment targeted at mobile information devices, such as mobile phones and two-way pagers. The MIDP specification addresses issues such as user interface, persistent storage, networking, and application model.

Persistent Data

The data needed to recreate an object in the same state as when it was written.

PIM

Personal Information Manager Porting

The process of adapting software so that a program can be created for a computing environment that is different from the one for which it was originally designed.

Preverification

Due to memory and processing power available on a device, the verification process of classes are split into two processes. The first process is the preverification which is off-device and done using the preverify tool. The second process is verification which is done on-device.

Set-top Boxes

A set-top box (STB) or set-top unit (STU) is a device that connects to a television and an external source of signal, turning the signal into content which is then displayed on the television screen.

Trackball

Hardware interface for interacting with the BlackBerry. In this document the term is interchangeable with trackball (BlackBerry Pearl models).

WLAN

Wireless Local Area Network Wi-Fi

Wireless Fidelity

References

http://www.onjava.com/pub/a/onjava/2001/03/08/Java ME.html

http://www-128.ibm.com/developerworks/wireless/library/wi-arch23.html http://www.uoguelph.ca/~qmahmoud/javame/Java ME-intro.pdf

http://developers.sun.com/mobility/midp/articles/wtoolkit/

http://developers.sun.com/mobility/midp/articles/blackberrydev/

http://ezinearticles.com/?BlackBerry-Programming-101-How-to-Get-Started-With-BlackBerry-Software-Development&id=432477

http://www.devx.com/wireless/Article/27869/0/page/3

http://www.blackberry.com/developers/docs/4.1api/index.html http://na.blackberry.com/eng/developers/downloads/jde.jsp

http://na.blackberry.com/eng/developers/downloads/simulators.jsp

http://devsushi.com/2007/12/02/blackberry-jde-api-user-interface-field-reference/

http://www.blackberry.com/developers/docs/4.0api/net/rim/device/api/ui/component/pac kage-summary.html

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/8003

32/800505/800608/How_To_-_Distinguish_between_a_full_menu_and_a_primary_actions_menu.html?nodeid=131188 9&vernum=0

http://apsquared.net/blog/2007/07/10/blackberry-gpslocation-api/

http://na.blackberry.com/eng/developers/resources/journals/jan_2005/multimedia.jsp http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/8003

32/800441/What_Is_-_Bluetooth_support_on_BlackBerry_devices.html?nodeid=1151480&vernum=0

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/8003 32/800441/How_To_-_Use_the_Bluetooth_classes.html?nodeid=1106807&vernum=0 http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/8003

32/800429/How_To_-_Establish_an_HTTP_connection.html?nodeid=800632&vernum=0 http://www.blackberry.com/DevMediaLibrary/view.do?name=debug

Related documents