MIDletTestRunner Guide

Sergio Morozov


A short & concise guide.

Contents

  1. Overview

  2. Usage

  3. Configuration

  4. UI Usage

Overview

MIDletTestRunner is a fully configurable MIDlet. It is intended to run tests in emulator (e.g. WTK emulator) or mobile device. It shows the results of tests run (progress bar, statistics, lists of failures or errors with detailed messages) in one screen. The tests can be run automatically during start-up (depends on configuration) and re executed more times later. It can print descriptive messages of failures and errors thrown together with stack-trace to the standard error output. It can also stop tests execution, when duration of their run exceeds specified time (for 1.1.1 and later versions).

Note: MIDletTestRunner is built upon MoMELib library. This is a J2ME library that offers possibilities to execute commands in separate from AMS (Application Management Software) callback thread, issue commands programmatically, associate key (game action) or sequence of keys and/or game actions with command, use any complimentary argument with command and much more. If you are interested, visit MoMELib Home Page

USAGE

Usage of MIDletTestRunner is pretty easy.

  1. Download MIDletTestRunner package from SourceForge.

  2. Add classes contained in this jar to your J2ME application. Use instructions of your IDE or just extract these classes to your source directory. In a case of pure WTK 2.2 just copy this jar to your project lib directory.

  3. Register MIDletTestRunner as midlet in manifest and/or JAD descriptor. Use instructions of your IDE or see an example of descriptor or MIDP documentation

  4. Configure MIDletTestRunner via properties. See below.

  5. Just run your application.

Configuration

MIDletTestRunner is fully configurable via properties. Your can put configuration properties to the manifest and/or JAD descriptor. Via configuration properties you can configure tests to be run, how result of tests are shown, auto start and timeout features and appearance of test screen (colors, fonts, etc.).

Test Execution Properties

"MoMEUnit-Tests"

Description of global test suite. Tests to be run should be specified here. Format of this property is a list of test names.

<Separator>*<TestName>?(<Separator>+<TestName>)*<Separator>*


Separator = [ ,;;\t]

a separator - comma, space, colon,semicolon or tab. Any separators can be grouped together (e.g. " , ").

TestName = <ClassName>|<TestSuiteName>

ClassName

a fully specified Test implementation class name as argument to Class.forName() method.

TestSuiteName

a name of TestSuite configured via "MoMEUnit-Test-<TestSuiteName>" property.

The default value is empty string (no tests).

Since version 1.0

"MoMEUnit-TestsName"

Name of global test suite shown as title. The default value is "Tests".

Since version 1.0

"MoMEUnit-Test-<TestSuiteName>"

Description of <TestSuiteName> test suite. Format of this property is the same as of "MoMEUnit-Tests". And of course it is possible to specify other test suites as part of this.

TestSuiteName any combination of characters except separators.

Note You shouldn't worry about recursion. If test suite contains itself either directly or indirectly, it will be notified by IllegalStateException.

Since version 1.0

"MoMEUnit-AutoStart"

If true tests are started at start-up. If false to start tests you should activate Test command. The default value is true.

Note You can re execute tests more then one time via Test command.

Since version 1.0

"MoMEUnit-TimeOut"

Maximum duration of tests execution measured from first test start (not from emulator start). If tests didn't finish after that amount of time, their execution stops, MIDletTestRunner prints descriptive message to the standard output and exits. Property takes the format

<DoubleLiteral>[<UnitSuffix>]

DoubleLiteral is positive double number string representation as specified by Double.valueOf(String).

UnitSuffix is an optional case insensitive specification of unit of time. It can be one of the following

  • h - for hours;
  • m - for minutes;
  • s - for seconds;
  • ms - for milliseconds.
If suffix is omitted milliseconds are implied.

To be valid this property must specify duration >= 1ms. If not given tests are executed without time boundaries.

Since version 1.1.1

Results Display Properties

"MoMEUnit-Print2StdErr"

If true failure and error events will be printed to standard error output. Default value false.

Note You can always print a descriptive message of failure or error by pressing FIRE key.

Since version 1.0

"MoMEUnit-PrintStackTrace"

If true stack-trace of failure or error is printed in addition to descriptive message. Default value false.

Note This includes prints executed via FIRE key.

Since version 1.0

Appearance Properties

"MoMEUnit-BGColor"

Background color. The format of this string is integer in hexadecimal format without leading "0x" or "h" suffix (e.g. 7FAD17). The default value is dark blue (7f).

Since version 1.0

"MoMEUnit-FGColor"

Foreground color. Color of all text elements except statistics. The format of this string is integer in hexadecimal format without leading "0x" or "h" suffix (e.g. 7FAD17). The default value is white.

Since version 1.0

"MoMEUnit-SelectedBGColor"

Background color of selected item. The format of this string is integer in hexadecimal format without leading "0x" or "h" suffix (e.g. 7FAD17). The default value is white.

Since version 1.0

"MoMEUnit-SelectedFGColor"

Foreground color of selected item. The format of this string is integer in hexadecimal format without leading "0x" or "h" suffix (e.g. 7FAD17). The default value is black.

Since version 1.0

"MoMEUnit-OkColor"

Color of progress bar if tests completed successfully. The format of this string is integer in hexadecimal format without leading "0x" or "h" suffix (e.g. 7FAD17). The default value is green.

Since version 1.0

"MoMEUnit-FailureColor"

Color of progress bar if some tests failed, but there were no errors and a color of failure statistics. The format of this string is integer in hexadecimal format without leading "0x" or "h" suffix (e.g. 7FAD17). The default value is magenta.

Since version 1.0

"MoMEUnit-ErrorColor"

Color of progress bar if some tests completed with errors and color of error statistics. The format of this string is integer in hexadecimal format without leading "0x" or "h" suffix (e.g. 7FAD17). The default value is red.

Since version 1.0

"MoMEUnit-Font"

Font of all text elements except statistics. The format of this property is
<Face>,<Style>,<Size>

Face = PROPRTIONAL|MONOSPACE|SYSTEM

Style = (PLAIN|BOLD|ITALIC|UNDERLINED)(;(PLAIN|BOLD|ITALIC|UNDERLINED))*

Size = LARGE|MEDIUM|SMALL

Note No spaces are allowed. Tests are case insensitive. The default value is as from Font.getDefaultFont().

Since version 1.0

"MoMEUnit-StatisticsFont"

Font of text of statistics. The format of this property is the same as above. The default value is as from Font.getDefaultFont().

Since version 1.0

UI Usage

This is one screen UI. It is very simple. If property "MoMEUnit-AutoStart" is set to true, tests are executed at start-up. If not you should activate Test command. If some test completed with errors, but there are no failures list of these tests is shown. If there are failures list of tests that fails is shown. You can switch between list by pressing LEFT and RIGHT keys (or any keys bound to respective game action). In bottom part of screen a descriptive message of failure or error of selected test is shown. You can move selection between tests by pressing UP and DOWN keys (or any keys bound to respective game action). By pressing FIRE key (or any keys bound to respective game action) you can print descriptive message of selected test with stack-trace (depends on configuration) to standard error output. In the top part of screen a statistics and a progress bar of tests run is shown. You can re execute tests by activating Test command and exit the application by activating Exit command.


Sergio Morozov. 2007