Whether you are developing an enterprise-wide application or a simple cell phone game, the cycle of debugging and testing proceeds similarly — through successive rounds of debugging and testing. Wireless consumers tend to be less technically oriented than desktop computer users and will be less tolerant when programs fail to work properly. Thorough debugging and testing of wireless applications is extremely important.
Testing
Before testing on actual devices, you can test on an emulator integrated with your development environment. By testing your MIDlets on multiple emulators, you can get an instant sense of how your application will look and function on the actual devices. Ultimately, of course, your wireless application should be tested on the actual device(s) it will run on.
Coding Errors
Three broad categories of errors can occur in your code: compile errors, runtime errors, and logic errors.
Compile errors appear at the time your source code is compiled. Syntax errors commonly appear at compile time.
A runtime error causes the program to fail or terminate prematurely. Runtime errors result from problems that will not occur until the code is being executed. For example, trying to open a file that does not exist, or attempting to divide by zero, are errors that cannot be caught at compile time.
In a typical development environment, when your program throws an exception, a debugger will print a stack trace in the Console output view, input view, and error view. You then double-click a line of the stack trace to go directly to the line of source code listed in the trace. As execution proceeds, you monitor the program's behaviour step by step, until the error is produced or the program fails. At that point, you fix the bugs, recompile the program, and resume testing.
A logic error is a non-fatal problem with the design or implementation of your application. Although the program statements may not throw exceptions, they do not produce the results you intended when you wrote the code. For example, logic errors can occur when variables contain incorrect values, when graphic images don't look right, or when output is simply incorrect. Memory leaks and attempting to insert more elements into an array than were allocated to the array can also result from logic errors.
A debugger can help locate logic errors by allowing you to monitor the values of program variables and data objects as the program executes. Modifying data values during a debugging session is a good way to test hypothetical bug fixes.
Note: Enabling optional compiler warnings in your IDE allows you to make full use of its debugging features. However, this can considerably slow down the process. In Eclipse, compiler warnings can be turned on or off by selecting in the Eclipse menu bar Run > Debug > Nokia SDK Plug-in and then choosing the appropriate warnings.
The JavaTM Verified testing program is an industry-wide initiative for testing Java ME applications. In the program, applications are tested against Unified Testing Criteria, which is developed and maintained by Unified Testing Initiative™ launched by Motorola, Nokia, Siemens, Sony Ericsson, and Sun Microsystems. It is recommendable to use Unified Testing Criteria (UTC) and also implement its requirements to the applications. For more information about Java Verified, see The Java Verified Program Web site.
For more information on designing applications, see the documentation on Forum Nokia. Among others, the following documents are available:
For more information on efficient programming and usability guidelines, see for example the following documentation:
For more information on debugging, see the documentation on Forum Nokia, for example, MIDP: Debugging Basics (With Example).