<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Alexey Popov&apos;s Blog</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/" />
<modified>2007-09-07T19:26:11Z</modified>
<tagline></tagline>
<id>tag:weblogs.java.net,2008:/blog/alexeyp/369</id>
<generator url="http://www.movabletype.org/" version="3.01D">Movable Type</generator>
<copyright>Copyright (c) 2007, alexeyp</copyright>
<entry>
<title>What is new in JT harness 4</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2007/09/new_features_of.html" />
<modified>2007-09-07T19:26:11Z</modified>
<issued>2007-09-07T19:25:59Z</issued>
<id>tag:weblogs.java.net,2007:/blog/alexeyp/369.8202</id>
<created>2007-09-07T19:25:59Z</created>
<summary type="text/plain">Here you can find my classification of new features
available in the new major revision of the JT harness,
that we recently completed </summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Community: Java Tools</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[Here I tried to give my classification of &nbsp;new features
available in the new major revision of the <a
 href="http://jtharness.dev.java.net">JT harness</a>,
that we recently completed .<br>
<p>As I <a
 href="http://weblogs.java.net/blog/alexeyp/archive/2007/01/test_harness_fo.html">wrote</a>
once, &nbsp;development of this product is primarily driven by
using it as a test harness for Technology Compatibility Kits. The next
big step in the history of the product was its adoption&nbsp; in
the new area of Java ME quality test
suites, specifically JDTS, the Java Device Test Suite.&nbsp;JDTS2.0
went out December 2006, see its <a
 href="http://java.sun.com/j2me/docs/j2me_java_device_ts.pdf">DataSheet</a>
for more information.
Among lots of other minor and major changes, this was first JDTS
version based on JavaTest
<sup>TM</sup> Harness, version 4.0.</p>
<p>The initial launch of the<a
 href="http://jtharness.dev.java.net/"> JT harness</a>,
the Open Source
version of JavaTest Harness, &nbsp;was based on the current stable
version of the product, 3.2.2.&nbsp;
The version 4.0 was primarily driven and targeted to this release
of JDTS 2.0,&nbsp;due to tight time line it was developed
internally for some time and become available in open source only now
since version 4.1.1</p>
<h3>Major new JavaTest harness 4 Features
</h3>
<ul>
  <li><a
 href="https://jtharness.dev.java.net/jt_docs.html#tutorial">Tutorial</a>
is now available with the binary.<br>
  </li>
  <li>Backward compatibility with JavaTest harness 3.2.2<br>
  </li>
  <li>Customization features.<br>
    <br>
The requirement was to make JavaTest 4 a testing platform, that can be
supplied
with product-specific functionality and have customizable functions and
appearance.<br>
  </li>
  <ul>
    <li>Custom splash screen can be used to provide stronger
identification of the JavaTest-based testing product.</li>
  </ul>
  <ul>
    <li>Custom tool bars, menus, pop-up menus, preferences can be
used to associate functionality extensions with GUI</li>
    <li>Customizable GUI rendering of a test's result - e.g. show
a
graph of some data for a test. This is targeted for test categories,
that may result
in more then just pass/fail criteria, like performance tests.&nbsp;</li>
    <li>Plug-in report mechanism. It can be used
to fit the JavaTest-based test suite into the larger
testing/certification
system<br>
      <br>
    </li>
  </ul>
  <li>Configuration process improvements<br>
    <br>
Configuration process is known as one of the most complex steps in
usage of the
large test suites, that are targeting multiple environments.
JavaTest 4 made significant steps to improve usability in this area.
New
usage models,
specific to quality vs compatibility testing area, were also addressed.<br>
  </li>
  <ul>
    <li>Improved configuration templates mechanism to allow
different levels of
configuration tuning. <br>
    </li>
  </ul>
  <ul>
    <li>Added new configuration interview question types<br>
    </li>
  </ul>
  <ul>
    <li>Per-test configuration, accessible through test tree
context
menu. This allows development of the test suites, where user is
required to configure only those parameters, that are minimally
necessary for
execution of specific test or group of tests and not pass through
complete configuration process for the whole test suite.<br>
      <br>
    </li>
  </ul>
  <li>Management of test suite updates<br>
    <br>
Ability to dynamically apply updates using existing
installation of the configured testing product allows significant
decrease in cost of applying updates to
users, allowing more frequent updates and hence better product quality<br>
    <br>
  </li>
  <li>Reporting<br>
    <br>
  </li>
  <ul>
    <li>Merging report directories, generation of consolidated
report to improve support to multi-user environment.</li>
    <li>XML formatted reports to simplify post-processing of test
results using custom tools and integration into large testing/reporting
infrastructure.<br>
      <br>
    </li>
  </ul>
  <li>Other <br>
    <br>
Number of minor improvements, like: UI
enhancements, logging</li>
</ul>

<!-- Site Meter -->
<script type="text/javascript"
 src="http://s30.sitemeter.com/js/counter.js?site=s30alexeyp">
</script>
<noscript><a
href="http://s30.sitemeter.com/stats.asp?site=s30alexeyp"
target="_top">
<img src="http://s30.sitemeter.com/meter.asp?site=s30alexeyp"
alt="Site Meter" border="0"/></a>
</noscript>
<!-- Copyright (c)2006 Site Meter -->]]>

</content>
</entry>
<entry>
<title>BlackBox for the big Mobile</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2007/08/blackbox_for_th.html" />
<modified>2007-09-07T19:21:58Z</modified>
<issued>2007-08-13T13:00:07Z</issued>
<id>tag:weblogs.java.net,2007:/blog/alexeyp/369.8014</id>
<created>2007-08-13T13:00:07Z</created>
<summary type="text/plain">Big Mobile Operator is running Sun BlackBox system</summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Community: Mobile &amp; Embedded</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[Nice article in Russian: <a class="moz-txt-link-freetext"
 href="http://www.ixbt.com/cm/blackbox.shtml">http://www.ixbt.com/cm/blackbox.shtml</a>
<p>
Briefly: there are two Sun <a href="http://www.sun.com/emrkt/blackbox/index.jsp">BlackBox</a>
systems running in the world, one in Stanford, CA
by Linear Accelerator Center and another one in Moscow by <a
 href="http://www1.mtsgsm.com/profile/">Mobile TeleSystems</a>,
one of the
largest Russian mobile operators with 74+ mln subscribers<a
 href="http://www1.mtsgsm.com/profile/"></a>.</p>


]]>

</content>
</entry>
<entry>
<title>Mobile JUnit and absence of reflection.</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2007/07/mobile_junit_an.html" />
<modified>2007-08-13T13:00:19Z</modified>
<issued>2007-07-14T12:52:53Z</issued>
<id>tag:weblogs.java.net,2007:/blog/alexeyp/369.7858</id>
<created>2007-07-14T12:52:53Z</created>
<summary type="text/plain">CLDC/MIDP does not have reflection API, that is one of
problems to solve when adopting JUnit-like test frameworks to Java ME. Here you can find some comments on how we deal with this problem using ME Framework at Sun.

</summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Community: Mobile &amp; Embedded</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[<p>In classical JUnit you have multiple test methods in a single
class
that match some pattern, test framework iterates through these methods
using relection. CLDC/MIDP does not have reflection API, this is one of
problems that need to be solved when adopting JUnit-like test
frameworks to CLDC/MIDP.&nbsp;</p>
<p>There are not too many solutions to this problem, well
described in <a
 href="http://blog.emptyway.com/2007/04/05/comparison-of-java-me-unit-testing-frameworks/">Vladimir's
blog</a>. I would like to add few words and will describe how we
deal
with this problem using <a
 href="http://cqme.dev.java.net/framework.html">ME Framework</a>
at Sun.</p>
<p>I like the elegant solution implemented in <a
 href="http://developer.sonyericsson.com/site/global/newsandevents/latestnews/newsjuly06/p_mobile_juint1.0_javame_cldc.jsp"
 onclick="javascript:urchinTracker('/outbound/developer.sonyericsson.com/site/global/newsandevents/latestnews/newsjuly06/p_mobile_juint1.0_javame_cldc.jsp'); javascript:urchinTracker('/outbound/developer.sonyericsson.com/site/global/newsandevents/latestnews/newsjuly06/p_mobile_juint1.0_javame_cldc.jsp');">Sony
Ericsson Mobile JUnit 1.0</a>. Absence of
reflection in CLDC (client side) sometimes can be dealt with at server
side. In this case, when list of test methods to iterate through is
static and not calculated at runtime, you can analyse class files or
sources and generate this iterator-launcher method or class.</p>
<p>Another solution is to use preprocessors and code generation.</p>
<p>This is an approach that we use at Sun for compatibility test
development for Java ME and Java SE. Test
sources are described in a meta language that allows to combine <a
 href="http://www.w3.org/TR/test-metadata/">meta data</a>
and code. Documentation and .java sources of tests are generated from
this source file, as well as code for all calls to
individual test methods. Here is the example of a generated launcher
method for MultiTest API:</p>
<p style="background-color: rgb(224, 224, 224);"><code>&nbsp;&nbsp;&nbsp;
protected void runTestCases() {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (isSelected("Connector2002")) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
addStatus(Connector2002());<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (isSelected("Connector2003")) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
addStatus(Connector2003());<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }</code></p>
<p>As I <a
 href="http://weblogs.java.net/blog/alexeyp/archive/2007/03/test_harness_an.html">wrote</a>
once, MultiTest has slightly different API then JUnit but similar
principles. It's <a
 href="http://fisheye4.cenqua.com/browse/jtharness/trunk/code/src/com/sun/javatest/lib/MultiTest.java?r=195">version
for Java SE</a>, that is natively supported by <a
 href="http://jtharness.dev.java.net">JT harness</a>,
uses reflection. Its <a
 href="http://fisheye4.cenqua.com/browse/cqme/trunk/code/src/share/classes/com/sun/tck/cldc/lib/MultiTest.java?r=230">CLDC-compatible
variation</a>, supported by ME Framework, requires this abstract
'runTestCases' method to be defined, in our case it is generated.</p>
<p>There other bonuses of code generation, like sharing compatibility tests across TCKs for Java platform API. We can have Java ME and Java SE versions of tests for the class that exists in both platforms generated from a single source. </p>
<p></p>

]]>

</content>
</entry>
<entry>
<title>ME application testing - MIDlet instantiation</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2007/07/me_application.html" />
<modified>2007-07-14T12:52:21Z</modified>
<issued>2007-07-08T11:09:39Z</issued>
<id>tag:weblogs.java.net,2007:/blog/alexeyp/369.7811</id>
<created>2007-07-08T11:09:39Z</created>
<summary type="text/plain">Very often problem - people try to write unit tests for their MIDlets and find that when they try to call new MyMIDlet() they see SecurityException. Here we try to come up with an idea on how it can be possible to workaround this problem with some test frameworks.</summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Community: Mobile &amp; Embedded</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[<p><p>The very common problem people meet when trying to unit-test
their
MIDlets is that you generally can not do something like this:
</p>
<p style="background-color: rgb(204, 204, 204);">
<code> <span style="font-weight: bold;">public</span>
<span style="font-weight: bold;">class</span>&nbsp;MyTest
<span style="font-weight: bold;">extends</span>
TestCase {<br>
<br>
&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">public
void</span> test() {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
MyMIDletApplication myma = <span
 style="font-weight: bold; color: rgb(51, 51, 255);">new </span></code><code><span
 style="font-weight: bold; color: rgb(51, 51, 255);">MyMIDletApplication()</span>;</code><br>
<code>&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; assertEquals("Never get here", 7, 8);<br>
&nbsp;&nbsp;&nbsp; }<br>
}</code>
</p>
<p>MIDP spec prohibits calling MIDlet constructor from
application
code, for
security reasons MIDlet can be instantiated only by AMS, Application
Management
Software. All MIDP xUnit-like test frameworks, I am aware of, assume
that test execution is done by a special utility MIDlet, lets call it
MIDletTester, for example. Since it is not possible to get instance
of your application MIDlet class from the MIDletTester, unit
testing should be limited to library classes.</p>
<p>Here are couple of ideas, we consider implementing some of
them for
<a href="https://cqme.dev.java.net/framework.html">ME
Framework</a>.</p>
<h3>Provisioning server and instrumentation</h3>
<p>Ideally, testing should be done on the instance, that runs in
the
environment, that is closest to real. Though you have to test every
unit of the program in isolation, it would&nbsp;also
be useful to have possibility to execute some tests on the MIDP
application, that is packaged and instantiated in a regular way, not on
library classes, packaged with your test application.
</p>
<p>This can be done by adding hooks to the application, where you
can
embed your tests. This approach will require the control over the
application code, may
not always be possible. </p>
<p>If you supply minimalistic xUnit-like test framework with a
server,
responsible for &nbsp;packaging and provisioning of the test
application, you can implement a solution for this and for some other
MIDP-specific testing problem by using instrumentation of the compiled
application class files to embed whatever hooks you need. Check the
picture:</p>
<p>
<img alt="MIDletinstr1.PNG" src="http://weblogs.java.net/blog/alexeyp/archive/MIDletinstr1.PNG" width="571" height="280" />
</p>
<br>
You need to modify the MIDlet class of your application under test with:<br>
<ul>
  <li>one or many&nbsp;methods, that will run tests. For
example instantiate a test
class by a classname and call its methods. </li>
  <li>for each test to pass its classname, for example hardcode
to
the newly generated method or in a resource file</li>
  <li>add a mechanizm to call these methods.&nbsp;</li>
</ul>
Interesting question is where calling of a test method makes sense. I
think having a UI for it, a Command is not a good idea - after all we
do all this so that testers click mouse less. Placing it into
any specific place in startRun may not work well ... may be I want
this MIDlet instance after startRun was called by AMS.
<p>Potential approach here would be to rename all
MIDlet
methods that can be called by AMS and replace them with testing hook
methods. Allow to bypass them or call original MIDlet methods from
them. MIDlet.startUp method after instrumentation may look like:</p>
<p style="background-color: rgb(204, 204, 204);"><code>&nbsp;&nbsp;&nbsp;
<span style="font-weight: bold;">public final void</span>
startApp()
{&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
test_startUp_preconditions();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; _original_startUp();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
test_startUp_postconditions();&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp; }</code></p>
<p>Any comments will be appreciated.</p>

]]>

</content>
</entry>
<entry>
<title>Simplest Test Suite built on ME Framework</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2007/05/simplest_test_s_1.html" />
<modified>2007-07-08T11:07:57Z</modified>
<issued>2007-05-15T03:40:33Z</issued>
<id>tag:weblogs.java.net,2007:/blog/alexeyp/369.7401</id>
<created>2007-05-15T03:40:33Z</created>
<summary type="text/plain">Some changes in the ME Framework were made in response to the feedback from early adopters to simplify its use. The article discusses two problems: how to describe test meta data and how to specify what classes to package into the test MIDlet suite.</summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Community: Mobile &amp; Embedded</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[This article is about  some changes in the <a
 href="https://cqme.dev.java.net/framework.html">ME Framework</a>
that
were made in response to the feedback that we got from early adopters
and are available in the third development release of ME Framework 1.2
that <a href="http://blogs.sun.com/mgorshenev/">Mikhail</a>
just <a
 href="https://cqme.dev.java.net/servlets/NewsItemView?newsItemID=4991">announced</a>.
<p>It is targeted to people who use (or plan to
use) ME
Framework or <a href="https:/jtharness.dev.java.net">JT
harness</a> or work in the area of Java ME testing.
</p>
<h3>Foreword</h3>
<p>
Before the open source release, we were developing and using the ME
Framework internally for years, as long as Java ME exists. As it turned
out, to start using it outside of the internal SUN environment and
supporting infrastructure is not
a trivial task. Unlikely these problems are unique to our project.
</p>
<p>Some things&nbsp; became too natural for
internal users. Some approaches
that we
use internally when develop TCKs with ME Framework help to
optimize the work of the big production organization, responsible for
development and sustaining of a big number of products. It turns out
that people who need to do
a first step, like to
create a single test suite once, need more simple ways to do simple
things.
</p>
<h3>Simplest Test Suite</h3>
The <a
 href="https://cqme.dev.java.net/source/browse/cqme/trunk/samples/meframework/SimplestTestSuite/?rev=667#dirlist">Simplest
Test Suite</a>
example,
that Alexander (aka Skavas) has recently checked into
repository, is what its name means - simplest possible test suite, that
we found reasonable for this product. It consists from three files -
ant build script, test suite .jtt parameter file and a sample test, If
you follow the instructions from
the <a
 href="https://cqme.dev.java.net/source/browse/cqme/trunk/samples/meframework/SimplestTestSuite/readme.txt?rev=667&amp;view=markup">readme</a>
file, it will take 5 min
to build and launch it plus time to download.
<p>I would like to go into details of two issues, that were
addressed
in the ME Framework 1.2 3rd Development release and are demonstrated in
this
sample:
</p>
<ul>
  <li>Allowed alternative test formats, not limit to html test
description, that have to be created for each test.</li>
  <li>Allowed not to provide explicit&nbsp; information on
what class and
resource files are
associated with test. This is necessary for automated packaging of test
applications
(bundles) and works now for simple tests. </li>
</ul>
<h3>Simple way to describe tests</h3>
The ME Framework is a plugin to <a
 href="https://jtharness.dev.java.net">JT harness</a>
(aka JavaTest <sup>TM</sup> harness), that enables Java ME
test development and execution. This specific change was to correct
usage of JT harness features by ME Framework, specifically, TestFinder.
<p><a
 href="http://fisheye4.cenqua.com/browse/jtharness/trunk/code/src/com/sun/javatest/TestFinder.java?r=49">TestFinder</a>
in JT harness is
the class, responsible for providing array of <a
 href="http://fisheye4.cenqua.com/browse/jtharness/trunk/code/src/com/sun/javatest/TestDescription.java?r=49">TestDescription</a>
elements, that are representing test meta data in JT harness' model of
the test suite. Support of different formats of tests is done in JT
harness by plugging in corresponding extension of the TestFinder.
</p>
<p>In short, the first change in ME Framework was just enabling <a
 href="http://fisheye4.cenqua.com/browse/jtharness/trunk/code/src/com/sun/javatest/finder/TagTestFinder.java?r=49">TagTestFinder</a>
in the .jtt file.
TagTestFinder uses javadoc
tags to
identify test and describe its meta information and it is a TestFinder,
used in <a href="https://openjdk.dev.java.net/jtreg">JTReg</a>.&nbsp;<a
 href="http://fisheye4.cenqua.com/browse/jtharness/trunk/code/src/com/sun/javatest/finder/HtmlTestFinder.java?r=49">HTMLTestFinder</a>
is more familiar to TCK users,
it describes tests in specially formatted html table, check <a
 href="http://weblogs.java.net/blog/alexeyp/archive/2007/02/testing_command_1.html">here</a>
for an example.</p>
<p>Simplest Test Suite uses tags to describe tests - it allows to
decrease number of files, naturally supported by IDEs and somewhat
familiar to people with JUnit experience. Check how the <a
 href="http://fisheye4.cenqua.com/browse/cqme/trunk/samples/SimplestTestSuite/tests/example/SimpleTests.java?r=664">sample</a>
test looks like.</p>
<h4>
Other kinds of TestFinder</h4>
<p>Other then Tag and Html finders, the standard set of
TestFinder implementations, provided in JT harness, includes
<a
 href="http://fisheye4.cenqua.com/browse/jtharness/trunk/code/src/com/sun/javatest/finder/BinaryTestFinder.java?r=49">BinaryTestFinder</a>,
that reads information on tests to run from the
binary file. It is the one that is most often used in TCKs, where there
is a need to optimize
time to read huge test tree. BinaryTestFinder is most applicable to
cases, where test suite does not change after its development is done,
because any change in any test description requires regeneration of the
binary test data.. BinaryTestFinder is used in conjunction with
another&nbsp;&nbsp;TestFinder that
reads test descriptions from tags or html files during the build of the
test suite and stores them in the
serialized form.</p>
<p>It's just sort of "extension" on top of other Finders,
that"sits" on
top of them, and gets the Descriptions from other Finders and serialize
them to the binary data, and also allows to read the descriptions from
the serialized data. It can be used with any other TestFinders that
that
do the actual job of parsing the TestDescriptions from HTML, javadocs,
etc.</p>
<h3>How to find what content to put into the .jar of the test
application</h3>
<p>This topic is more complex and hence more entertaining one.</p>
<p>The problem in more details. ME Framework allows for a great
flexibility in how to turn huge pile of class and resource files of the
test suite into set of MIDP application packages for iterative
execution through <a
 href="http://weblogs.java.net/blog/alexeyp/archive/2006/11/testing_java_me_1.html#Autotest">autotest</a>.
Criteria that control
creation of packages can be</p>
<ul>
  <li>max size
of the jar file</li>
  <li>number of tests to package into the single jar</li>
  <li>tests
themselves may describe some conditions in their associated meta data
that
would regulate how these tests need to be packaged</li>
</ul>
<p>Tests are packaged
into .jar at runtime to allow the user to vary packaging parameters to
achieve different goals, primarily to optimize network traffic and test
execution time.</p>
<p>This all means - to form various application packages ME
Framework needs to know which class and resource files are associated
with each test.</p>
<p>These data can be calculated automatically using several
methods, I will talk about them later. What we did for this sample:
TestDescription in JT harness requires definition of the
'executeClass' parameter for every test. The value of this field is the
name of the class that is test
entry point, implementing one of supported interfaces.&nbsp; If
test
consists from the single .java source
file that defines single class - nothing to
calculate, right&nbsp; ? All class files of this test can be
described by /$executeClass.*/ expression. Note that inner classes are
OK here as well.</p>
<p>Other then this, nothing else happens in this sample
automatically - if there are multiple .java files, that constitute a
test, one need to
list them manually in the
'resources' field. &nbsp;Not that convenient as 'do nothing', but
simple to explain :) Other then 'resources' field, the standard
mechanism with
special file named&nbsp;testClasses.lst
still works, just generation of this file is not supported in the build
of the Simplest Test Suite.
The file testClasses.lst should be located in the special place in test
suite's directory hierarchy and containing testURL-test classes
pairs, check <a
 href="https://cqme.dev.java.net/source/browse/cqme/trunk/samples/meframework/SampleTestSuite/build/testclasses.lst?rev=333&amp;view=markup">how
it looks</a> like in another sample.</p>
<h4>Approaches to automatically calculate list of classes to
package</h4>
Content of the testClasses.lst is calculated statically during the
build of
the test suite.
<h5>Approach 1 - individual test compilation.</h5>
<p>One way to
do this is to put the load on the compiler. Compile tests individually,
set own target dir for each test, not give and test library classes on
the classpath but provide reference to their source directory instead.
All class files, that are needed by the test, will be in the target
directory of the compiler. The described approach is simple and
reliable one, we used it
for
some TCK releases. Weak places of it is that it is slow, at least in
our implementation where java compiler and preverifier were executed
through the command line for each test.&nbsp;</p>
<h5>Approach 2 - parsing class files for dependencies.</h5>
We do this with a simple tool based on JINI's <a
 href="http://java.sun.com/products/jini/2.0/doc/api/com/sun/jini/tool/ClassDep.html">ClassDep
API</a>.<br>
<br>
It does static class analysis and should calculate all dependencies
correctly except for cases like <code>Class.forName</code>
is used in the tests
(which is rarely
needed).
There are probably other tools which can do the same thing.
<br>
<br>
Here is the example of the command, that can be used in the test suite
build script:
<p style="background-color: rgb(204, 204, 204);"><code>&nbsp;&gt;
java -cp
jini2_1\lib\tools.jar;%JAVA_HOME%\lib\tools.jar
com.sun.jini.tool.ClassDep ^<br>
&nbsp;&nbsp;&nbsp; -cp &lt;ALL TEST AND FW
CLASSES&gt; &lt;executeClass&gt; ^<br>
&nbsp;&nbsp;&nbsp; -out com.sun.tck.cldc -out
com.sun.tck.j2me -out java -out sun -out
javax
</code></p>
<p>
In cases where all necessary classes can not be found through parsing
class files from the entry point, we used static, manually created
table, that is merged into the generated testClasses.lst. This can be
just a table with the same format, or, as mentioned above, just a
'resources' field of the TestDescription.</p>
<h3>Limitations</h3>
Build script &nbsp;for the sample will work only with simple
automated
tests for MIDP. Support of distributed, interactive, OTA or CDC tests
will require more sophisticated build procedure, that will take care of
compiling SE-side components, for example.
<h3>Yet more simplification</h3>
<p>Further simplifying of this test suite and test development
approach
is possible by making it close to JTReg and xUnit. This can be:</p>
<ul>
  <li>Minimizing set of mandatory meta data. For example, if a
test
consists from the single .java file, test entry point, that is now
specified in the mandatory 'executeClass' parameter. is known.</li>
  <li>If this suite is used in the scenario, where tests are
actively
and constantly changing, it may be possible to eliminate 'build' stage,
as it is done in JTReg,&nbsp; implement test source
compilation/preverification as a step in the test execution
process.&nbsp;</li>
</ul>
<h3>Acknowledgment</h3>
<p>I would like to express my appreciation to the <a
 href="http://www.cenqua.com/fisheye"><img
 src="http://www.cenqua.com/images/fisheyed.gif"
 alt="Project Supported by FishEye" border="0" height="33"
 width="89"></a> hosting provided by <a
 href="http://www.cenqua.com/"><img
 src="http://www.cenqua.com/images/cenquad.gif"
 alt="Supported by Cenqua" border="0" height="33"
 width="89"></a> that allows to link sources
for&nbsp;java.net projects from this blog a nice way that you can
see above.</p>
<p></p>

]]>

</content>
</entry>
<entry>
<title>Interactive Tests for Java ME</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2007/05/interactive_tes.html" />
<modified>2007-05-15T03:39:49Z</modified>
<issued>2007-05-03T13:46:00Z</issued>
<id>tag:weblogs.java.net,2007:/blog/alexeyp/369.7212</id>
<created>2007-05-03T13:46:00Z</created>
<summary type="text/plain">This article describes types of interactive tests that are being developed for Java Technology Compatibility Kits, testing of what functionality requires user interaction. What Java ME limitations cause problems for development of tests, that require user interaction and how these limitations can be worked out.</summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Community: Mobile &amp; Embedded</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[This article is about interactive testing for Java <sup>TM</sup>
and its ME
specifics. It describes types of interactive tests that are
being
developed for Java Technology Compatibility Kits, testing of
what functionality requires user interaction. What Java ME limitations
cause problems for development of
tests, that require user interaction and how these limitations can be
worked out.
<p>Most of definitions and examples are given using the
terminology of <a href="http://jtharness.dev.java.net/">JT
harness</a> and <a
 href="https://cqme.dev.java.net/framework.html">ME
Framework</a>, but should be generic enough for the area.
For details on what is TCK, JT harness and ME Framework refer
to previous articles. Skip
the background section if you are familiar with the subject.
</p>
<h2>Background<br>
</h2>
<h4>Why not everything is automated</h4>
Interactive tests are needed to test API that produces output,
that in general case can be only verified by human or requires human or
require human input. That is API that draws something on the screen,
plays sound, or reacts to key pressing or mouse dragging.
<p>For every specific implementation, testing of this
functionality can be automated as well with different external tools or
specific APIs. But first, not always - compatibility tests, for
example, can not rely on any specifics because have to be correct for
any compatible implementation, and second, this is a separate big
topic, to be covered in another article.
</p>
<h4>What is meant by interactive tests</h4>
From point of view of the test harness, all tests, automated and
interactive, are
discovered and executed in the same automated way. Interactive tests
are those that show a dialog with some instructions and wait for user
doing something.
These tests are usually grouped together to be executed in a single
session, separately from the rest. The rest are completely automated
tests, you can run them nightly for regression testing. Execution of
interactive tests takes hours of someones expensive time.<br>
<h3>Requirements</h3>
<p>Speaking from point of view of TCK
development, the most important
requirement is to make the test suite easiest for use. This means the
less interactive tests it has, the better. If we have to have
interactive tests, it is
important to make their execution simple.</p>
<p>To achieve this we limited number of test types that we use in
TCKs to very few. As a result, some features, that are not best suited
to be tested by these test types, require multiple test cases to be
written where we would write one 'custom' test case. The benefit is
that
TCK user has uniform interactive model, uniform interface to browse
test instructions etc. This also allows for simpler external automation
system development.</p>
<h4>Types of TCK interactive tests</h4>
As mentioned before, such tests may require input from the user or
require some output to be evaluated, or both. Test status may be
calculated automatically or require user judgment. The interactive
test library, that is included into ME Framework, provides 

<a href="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/DoneKeys." onclick="window.open('http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/DoneKeys.','popup','width=640,height=480,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><b>Done</b></a>

and 

<a href="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/Yes_No_double_press_Test." onclick="window.open('http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/Yes_No_double_press_Test.','popup','width=750,height=650,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><b>Yes/No</b></a>


interfaces to enable these two types of user interaction. There is also
<b>Info Only </b>interface , that can be used if the end
of test is known beforehand (event sequence is predefined).&nbsp;
<p>Note that these tests are not just set of user instructions
'do this - verify that', they include test code that can do most of
work.</p>
<h2>Java ME Specifics and Solutions</h2>
<h4>PJava story - first TCK alt bundle</h4>
<p>Interactive tests created for Java SE TCKs are usually
interactive applications, that run on the platform under test and show
user instructions and test panel in a single window. This approach does
not always work for Java ME for many reasons. First time we started
doing interactive tests in the world of consumer devices, that was
Personal Java, we found that tests we created can not be
passed on PJava devices with single Frame limitation and small screen -
test instructions and test panel were placed in the container without
scrolling capabilities, these 'Done' and 'Yes/No' buttons may not
appear on screen in some circumstances. To address this we issued first
'alternative TCK test bundle' that just enabled scrolling. After that
passing of interactive tests became possible, though not convenient.
Check how 

<a href="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/TruffleToolkit." onclick="window.open('http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/TruffleToolkit.','popup','width=648,height=514,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">AgentFrame</a>

interface looks like on
PJava
with Truffle toolkit. The scheme of these interactive tests is the one
that is still used in Java SE TCKs, can be described as follows:</p>
<p style="text-align: center;"><img
 style="width: 252px; height: 212px;"
 alt="Siple interactive test"
 src="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/SimpleITestLogic.jpg"></p>
<p style="text-align: center;"><span
 style="font-weight: bold;">Figure I. Simple Interactive Test.</span></p>
<script>i=1; j=1</script>
<img title="Click to see next test screen"
 style="float: right;"
 onclick='src="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/midp10-"+i+".JPG";i++;i=i%6'
 alt="MIDP10 test" src="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/midp10-0.JPG"
 hspace="40">
<h4>MIDP TCK 1.0 interactive tests</h4>
<p>Interactive tests for MIDP TCK 1.0 were executed using the
same
<a
 href="http://weblogs.java.net/blog/alexeyp/archive/2006/11/testing_java_me_1.html#Autotest">Autotest</a>
mechanism as regular
automated tests, the difference was that interactive tests expected
some user actions and were grouped together for convenience. These
tests were developed using
brand-new MIDP API and same approach that was used in JCK and PJCK.
Instructions, test panel, all user interface components
of these tests were displayed on the micro screen of MIDP 1.0 micro
devices. Given big number of interactive tests, that were necessary to
verify MIDP 1.0 GUI API, running MIDP 1.0 TCK on a regular
basis during the development process, was a headache.</p>
<p>You can see the screen shot of the MIDP 1.0 emulator to the
right. Click
on it to see the sequence of screens that constituted the
MIDP TCK 1.0 interactive test. As you can see, there is a big
number of
interactions, that are not related to execution of the test but for
scrolling, switching controls etc.</p>
<p><img style="float: right;" alt="click here"
 src="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/clickhere.JPG"></p>
<h3>Distributed Interactive test framework<br>
</h3>
<h4>MIDP TCK 2.x interactive tests</h4>
<p>To address this problem of inconvenience of interactive tests
on MIDP devices with small screen, the solution was very simple and
usability improvement was huge. Briefly, these tests were rewritten to
using Distributed Test library to have minimal functionality on the
device and have user instructions and controls, related to the test
logic, on the server part. Now to run tests on the device one need to
stare to the desktop monitor, read instructions, press some
buttons on the desktop, for example, to initiate tested process on the
device, do some interaction with the device as necessary, state
pass/fail result on the desktop if needed.</p>
<p>The important feature of Distributed Test framework, that lies
underneath new Interactive Test Framework is that there are java
components of the test, that reside on server and client sides and can
work together to calculate test result. One can use server side
technologies in the test, for example, for reference purpose to verify
that same technology works properly at Java ME side.</p>
<p>The scheme of distributed interactive test can be described as
follows</p>
<p style="text-align: center;">:<img
 style="width: 579px; height: 349px;"
 alt="Distributed interacrive test scheme"
 src="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/DistrITest1.JPG" align="middle"></p>
<p style="text-align: center;"><span
 style="font-weight: bold;">Figure II. Distributed
Interactive Test.</span></p>
<p>In the 

<a href="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/DoneSounds." onclick="window.open('http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/DoneSounds.','popup','width=640,height=610,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">example</a>

of the interactive test for sound, you can see all GUI of this test.
Device part of this specific test does not have GUI at all, all that
device does - produces sounds that are initiated from the server side,
pass/fail criteria is specified on the server side of the test as well.</p>
<h4>PBP TCK 1.0 interactive tests</h4>
<p>Same solution was used for interactive tests for Personal
Basis Profile TCK. Though PBP API is subset of J2SE API, reuse of JCK
tests was not possible there - as I mentioned, these tests combine in a
single application all instructions and controls, that were not
available. PBP does not have Panel, Button - no any UI widgets, only
Component, Container and Window Frame. To reproduce anything on the
device screen we would have to draw it using graphics primitives from
scratch and creating UI toolkit was not in the scope of the TCK.</p>
<p>Separating functionality and interaction between server and
client parts of the tests, that were created using Distributed Test
framework, worked well for PBP. In the <a
 href="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/PBP_KeyEvent_virtualkeyboard_fail."
 onclick="window.open('http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/PBP_KeyEvent_virtualkeyboard_fail.','popup','width=643,height=608,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">example</a>
of the keyboard test you can see the same situation as in already
referenced MIDP TCK 2.0 example,
all GUI is on desktop screen, device does not have any GUI, just
accepts key presses and pass them to the server side. </p>
<p><img title="Click to see next test screen"
 src="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/agui10-0.JPG"
 alt="AGUI interactive"
 onclick='src="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/agui10-"+j+".JPG";j++;j=j%4'
 style="width: 312px; height: 694px; float: left;" hspace="40"></p>
<h4>AGUI TCK 1.0 interactive tests</h4>
<p>Yet another special solution to workaround small device screen
was implemented for AGUI TCK 1.0.</p>
<p> AGUI stands for Advanced Graphics and User Interface, that
assumes lots of interactive tests. For AGUI the execution model for
interactive tests was also the same as for regular automated tests, all
tests were executed in the same Agent, interactive tests grouped
separately from automated. Read <a
 href="http://weblogs.java.net/blog/alexeyp/archive/2006/11/testing_java_me_1.html">here</a>
about MIDP and CDC execution modes of ME Framework.</p>
<p>As AGUI API is a subset of Java SE API, specifically, Swing,
our goal was to reuse
as much of JCK interactive tests for this API as possible. The reason
here is not only time saving, it is also an additional way to ensure
compatibility across different Java platforms.</p>
<p><img style="float: left;" alt="Click there"
 src="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/clickthere.JPG">What
we did is we again separated tests to different pieces that could be
displayed separately and organized test UI as Tabs. It was relatively
easy to do, since JCK interactive tests library assumed some
structuring, there was implementation of this library done with Swing
subset, that fit into AGUI API. Though it was still
necessary to do extra clicks to switch between different tabs and
sometimes scroll through the tab, the effect was a significant
usability improvement comparing to having everything in the same window
altogether.</p>
<p>You can see the screen shot of the AGUI 1.0 emulator to the
left. Click
on it to see the sequence of screens that constituted the AGUI TCK 1.0
interactive test.</p>
<p>It was a temporary solution, once we structured tests to
independent pieces, it was easy to execute these components on
distributed components. This was not a conversion of simple interactive
tests to distributed tests but a special execution framework, that
could execute simple interactive tests in the distributed way and gave
some other minor usability improvements. Overall, Interactive tests in
the AGUI TCK 1.0 when it was released looked exactly like all other
distributed interactive tests for Java ME.</p>
<h3>Tests with static image</h3>
This type of tests is very easy to create, execute and automate.
Basically, the scenario of these tests is to show reference image and
its verbal description somewhere, initiate drawing of the same image on
the device and ask user to validate the output.
<p>This approach is natural one, it can be used to test 80% of
functionality, related to user interaction. Some technologies use it as
the only approach for testing, for example <a
 href="http://www.w3.org/Graphics/SVG/Test/">W3C SVG test
suite</a>. It can be used to test low level graphics and
behavior of high-level user interface components.
</p>
<p>Even when these tests are too primitive and require multiple
test cases to be developed when few more sophisticated ones could be
enough, the simplicity of development and execution,
possibility to have consistency across many tests could be a reason to
use this approach even when it is not the most convenient.</p>
<h4>Static image tests with ME Framework</h4>
<p>To simplify test execution we display multiple images, related
to the same functionality, in a single window with test
instructions. Every reference image is accompanied with a Test button,
that initiates reproduction of this image on the device under test, ad
verbal description. Check the example, the screenshot of the 


<a href="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/StaticImageDialog." onclick="window.open('http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/StaticImageDialog.','popup','width=732,height=749,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">instructions dialog</a>

and 

<a href="http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/StaticImageDevice." onclick="window.open('http://weblogs.java.net/blog/alexeyp/archive/InteractiveImages/StaticImageDevice.','popup','width=364,height=674,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">device side</a>


for tests for Java Binding to Open GL ES API (JSR 239) .</p>
<p>Combining multiple related images that could be switched in
any sequence allows not only for comparison of the result on the screen
with reference, but also for checking of transition one image to
another on the device. This, as well as verbal description of the
scene, may be important when reference images were done on the
implementation, that is radically different with one under test and
comparing of test and reference image alone can not provide
confidence that tested functionality behaves correctly.</p>

]]>

</content>
</entry>
<entry>
<title>One of the First Java Applications</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2007/04/compatibility_t.html" />
<modified>2007-05-03T13:45:34Z</modified>
<issued>2007-04-10T07:58:06Z</issued>
<id>tag:weblogs.java.net,2007:/blog/alexeyp/369.7020</id>
<created>2007-04-10T07:58:06Z</created>
<summary type="text/plain">Curious how much Java is a test-driven technology ?</summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Community: Java Tools</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[Curious how much Java is a test-driven technology ?
<h4>Few words for a background.</h4>
<p>The Java <sup>TM</sup> Compatibility Kit (JCK) is
a test suite, used to
verify if the Java standard is correctly implemented. The first JCK
came out together with the first JDK from SUN, now this effort evolved
into the industry-wide <a href="http://www.jcp.org">Java
Community Process</a>.</p>
<p>The JavaTest <sup>TM</sup> harness is a test
monitor, used in first versions of JCK, then across multiple Java
Technology Compatibility Kits (TCK), now evolved into a general
purpose <a href="http://jtharness.dev.java.net">open
source test harness</a>.</p>
<h4>How it started</h4>
<p>With permission of <a href="http://blogs.sun.com/jjg">Jonathan
Gibbons</a>, who was
around when Java was born, here is his story of the JavaTest childhood:</p>
<blockquote type="cite">
  <p>JavaTest started round about JDK 1.0.2, JCK 1.0.2a was
applet-based and did not use JavaTest;&nbsp; JavaTest was
introduced in JCK 1.0.2b. </p>
  <p>It definitely was not the first application written in Java,
but it is true that testing was important to Java from the beginning.
JavaTest is sufficiently old that we had to develop many GUI widgets
ourselves, and one of the early JavaTest developers (<a
 href="http://research.sun.com/people/prinzing/">Tim Prinzing</a>)
went
on to become a significant member in the Swing team. It is probably
reasonable to say that Tim pioneered light-weight components.</p>
</blockquote>
<p>Curious how it looked like back then at early JDK times ?
Check <a
 href="http://blogs.sun.com/jjg/resource/jtpics/jt1-main.png">here</a>.</p>
<p>You can see that testing is one of keys that
brought Java platform to where it is now.
Java's way of compatibility testing, that is having high quality
TCK required to pass to get Java logo,&nbsp; is how Write Once Run
Anywhere is
achieved,&nbsp; it is the cost of application portability and
platform
standardization.</p>
<h4>On the road</h4>
<p>Inspired by the conversation at <a
 href="http://weblogs.java.net/blog/robogeek/archive/2007/02/an_open_quality.html">David
Herron's Blog</a>, I was
looking for&nbsp;analogy to illustrate the value
of compatibility testing
in the Java ecosystem, here it is - Java is
a <a href="http://blogs.sun.com/jag/">road</a>,
compatibility testing is its <span style="font-weight: bold;">pavement</span>.
Applications
are vehicles and the hard cover on the road makes it
possible to drive
fast.&nbsp;
</p>
<p>For Java ME platform, its&nbsp;<a
 href="https://meapplicationdevelopers.dev.java.net/fragmentation.html">fragmentation</a>
is&nbsp;a freedom to
choose
number of wheels,&nbsp;engine, use a bicycle or a truck. Another
part, the 'dark side', is where the road cover has holes, caused by
bugs in specification and implementations, test coverage problems.
Services are built
around the road to take care of vehicles and holes, like&nbsp;<a
 href="http://java.sun.com/products/javadevice/index.jsp">JDTS</a>
and <a href="http://javaverified.com">Java Verified</a>,
while the road has its pavement (TCKs),
differentiating it from deserts, forests and swamps.</p>


]]>

</content>
</entry>
<entry>
<title>Testing session at Java ME track at SUN TechDays, Saint Petersburg</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2007/03/sun_techdays_an.html" />
<modified>2007-04-10T08:01:44Z</modified>
<issued>2007-04-01T07:37:45Z</issued>
<id>tag:weblogs.java.net,2007:/blog/alexeyp/369.6965</id>
<created>2007-04-01T07:37:45Z</created>
<summary type="text/plain">We will do a session on testing JavaME applications, do overview of available tools and demo on how to use ME Framework for this purpose. If you speak Russian, check the agenda. 
</summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Community: Java Tools</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[If you speak Russian, check the <a
 href="http://ru.sun.com/techdays/agenda.html">agenda</a>
and <a href="http://ru.sun.com/techdays/themes/javame.html">descriptions</a>
of Java ME sessions. 'Java ME Testing' session description is in the
end of the list, it concludes the Java ME track and Day 2.
<p>Slides and description for it were first created in the native
language
of Internet and IT, that we use at work and call English by inertia. I
did a first pass of translation to Russian and found that for many
notions I do not have adequate words. For example, does <b>open
source</b> mean the same as <b>открытый код</b> ?
From the other side - with mother tongue you can make your speech so
alive !</p>
<p>Check blogs of my colleagues who are speakers at the
Java ME
track: <a href="http://weblogs.java.net/blog/danila">Danila</a>
(CLDC), <a href="http://weblogs.java.net/blog/peterp">Petr</a>
(CDC), <a href="http://blogs.sun.com/trustme/">Alexander</a>
(Testing). Presentations in English, like one of <a
 href="http://blogs.sun.com/simonri/">Simon Ritter</a>
about ME Gaming, will be translated online.</p>
<p>I will also be there at the Java ME POD. See you at SUN
TechDays in Saint Petersburg !
</p>
]]>

</content>
</entry>
<entry>
<title>Test Harness and Test Format</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2007/03/test_harness_an.html" />
<modified>2007-04-01T07:38:36Z</modified>
<issued>2007-03-26T18:58:49Z</issued>
<id>tag:weblogs.java.net,2007:/blog/alexeyp/369.6921</id>
<created>2007-03-26T18:58:49Z</created>
<summary type="text/plain">Compare JavaTest harness and JUnit, or Why new test formats appear ?</summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Community: Java Tools</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[It is true that the most popular test format supported by
many Java <sup>TM</sup> IDEs is <a
 href="http://www.junit.org">JUnit</a> and its
variations like <a href="http://www.testng.org">TestNG</a>
or <a href="http://sourceforge.net/projects/j2meunit/">J2MEUnit</a>.
Interested to compare <a href="http://jtharness.dev.java.net">JavaTest</a>
<sup>TM</sup>
harness and JUnit ?
<p>JavaTest is a test harness, JUnit is a test format. JavaTest
is created to manage <a
 href="http://weblogs.java.net/blog/alexeyp/archive/2007/01/test_harness_fo.html">test
suites</a> written in many different formats, JUnit is a specific
format and API for test development. The comparison is invalid, it would be more appropriate to compare JUnit API with one of test APIs, included into JavaTest's core libraries or its extensions.</p>
<p>Test format that is traditionally associated with this
harness is the
one that is used in most of Java&nbsp;Technology Compatibility
Kits (TCK),
based on test meta data provided in html form and Test/MultiTest API.
Check the <a
 href="http://weblogs.java.net/blog/alexeyp/archive/2007/02/testing_command_1.html">previous
article</a> for example of how JavaTest's Test Description looks
like in .html.
Comparing to JUnit, the java code of the TCK test may look like this:</p>
<table style="text-align: left; width: 100%;" border="1"
 cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td>public void testadd() <span
 style="color: rgb(0, 153, 0);">throws
AssertionFailedException</span>
{<br>
&nbsp;&nbsp;&nbsp; <span style="color: rgb(51, 204, 0);">System.out.</span>println("add");<br>
&nbsp;&nbsp;&nbsp; math.Arithmetic instance =
Arithmetic.getInstance();<br>
&nbsp;&nbsp;&nbsp; for (int a=0;a&lt;=10;a++)<br>
&nbsp;&nbsp;&nbsp; for (int b=0;b&lt;=10;b++) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int expectedResult = a+b;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int result = instance.add(a,b);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
 style="color: rgb(51, 204, 0);">assertEquals(expectedResult,
result)</span>;<br>
&nbsp;&nbsp;&nbsp; }<br>
}</td>
      <td>public <span style="color: rgb(51, 204, 0);">Status</span>
testadd() {<br>
&nbsp;&nbsp;&nbsp; <span style="color: rgb(51, 204, 0);">log.</span>println("add");<br>
&nbsp;&nbsp;&nbsp; math.Arithmetic instance =
Arithmetic.getInstance();<br>
&nbsp;&nbsp;&nbsp; for (int a=0;a&lt;=10;a++)<br>
&nbsp;&nbsp;&nbsp; for (int b=0;b&lt;=10;b++) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int expectedResult = a+b;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int result = instance.add(a,b);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
 style="color: rgb(51, 204, 0);">if (expectedResult !=
result) <br>
      </span><span style="color: rgb(51, 204, 0);"></span><span
 style="color: rgb(51, 204, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return Status.failed(</span><span
 style="color: rgb(51, 204, 0);">"Expected: "+</span><span
 style="color: rgb(51, 204, 0);">expectedResult</span><span
 style="color: rgb(51, 204, 0);">+<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;</span><span
 style="color: rgb(51, 204, 0);">" Received: "+ result</span><span
 style="color: rgb(51, 204, 0);"></span><span
 style="color: rgb(51, 204, 0);">);</span><br>
&nbsp;&nbsp;&nbsp; }<br>
      <span style="color: rgb(51, 204, 0);">&nbsp;&nbsp;&nbsp;
return Status.passed("OK");</span><br>
}<br>
      </td>
    </tr>
  </tbody>
</table>
<p>The choice of the test API with explicit return for both
positive and negative test conditions was driven by its use in TCKs,
test suites, that are used for certification. One reason is requirement
to be able to provide maximum to evaluate test failures offline without
access to the implementation, where test failure is reproduced. Because
of this there 'log' API is used instead of 'System.out', there is a
special class Status that holds additional information other then
pass/fail indication. Another reason is that TCK tests verify specific
assertions of the specification and action of qualifying test as Passed
need to be concise.</p>
<p>The <a href="https://openjdk.dev.java.net/jtreg/">JTReg</a>
is
a JavaTest with set of
plugins tuned for JDK regression testing. As opposite to the primary
JavaTest use as a test harness for certification test suites, like TCK,
where
main requirements come from the test suite end user, JTReg is targeted
to JDK developers. Main goals here are easiness to write and execute a
test, support for major test types, possibility to execute shell
scripts, adoption to the JDK development process. As you can <a
 href="https://openjdk.dev.java.net/jtreg/faq.html#question2.1">see</a>,
there API for JDK regression tests is even simpler. See also JTReg FAQ
for
<a href="https://openjdk.dev.java.net/jtreg/faq.html#question1.13">comments
about JUnit support</a> in JavaTest and JTReg.</p>
<a href="http://java.sun.com/products/javadevice/index.jsp">JDTS</a>
Framework is a set of JavaTest harness plugins,
that provide support for their own format, that is specially focused at
functional and quality testing for Java ME.
<p>Overall, different needs and different uses result in
different test formats, that can be supported with single test harness.</p>
]]>

</content>
</entry>
<entry>
<title>Debugging II - Hangups at Device Side</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2007/03/debugging_ii_ha_1.html" />
<modified>2007-03-26T18:54:28Z</modified>
<issued>2007-03-01T19:06:49Z</issued>
<id>tag:weblogs.java.net,2007:/blog/alexeyp/369.6716</id>
<created>2007-03-01T19:06:49Z</created>
<summary type="text/plain">New feature of ME Framework 1.2 solves some of problems related to the debugging of Java ME test suites.</summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Community: Mobile &amp; Embedded</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[As a follow up to the <a href="http://weblogs.java.net/blog/alexeyp/archive/2007/02/java_me_testing_1.html">past article</a> about Debugging with ME Framework, here is the the guest post from Alexander Alexeev (aka Skavas) on the new feature
he has integrated into the <a href="https://cqme.dev.java.net/framework.html">ME Framework</a>,
the Interactive MIDlet agent. The feature addresses some usability
issues of executing large test suites on mobile devices, provides
on-screen indication of the testing progress and allows to perform some
operations with test results on the device.<br>


<h2>Background</h2>


<p>The <a href="http://weblogs.java.net/blog/alexeyp/archive/2006/11/testing_java_me_1.html">Introduction</a>
article described the approaches, used for execution of large test
suites for Java <sup>TM</sup> ME implementations as well as some of techniques,
allowing to optimize test execution time.&nbsp;To restate the main
points, relevant to this debugging topic:</p>


<ul>


  <li>test execution is managed at the server side</li>


  <li> the test execution process consists of sequential
downloads of test MIDlet suites to the device</li>


  <li>during this process AMS and&nbsp; MIDlet suites
exchange control messages with test harness</li>


  <li>one of optimizations, allowing to minimize network traffic
and number of downloads/installations/runs/removals, is to package
multiple tests into a single bundle.</li>


</ul>


<p>The diagram describing this <a href="http://weblogs.java.net/blog/alexeyp/archive/2006/11/testing_java_me_1.html#Autotest">autotest</a>
cycle can be seen&nbsp;<a href="http://weblogs.java.net/blog/alexeyp/archive/texec.PNG" onclick="window.open('http://weblogs.java.net/blog/alexeyp/archive/texec.PNG','popup','width=555,height=406,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">here</a>.</p>


<p>The 'autotest' &nbsp;approach allows to achieve the
sufficient level of automation, that is one of high priority&nbsp;<a href="http://weblogs.java.net/blog/alexeyp/archive/2007/01/test_harness_fo.html">requirements</a>
for test suites we develop with <a href="http://jtharness.dev.java.net/">JT harness</a>
and ME Framework.&nbsp;</p>


<p>User interactivity here still may be desired in few situations:</p>


<ul>


  <li>'sendTestResult' may not be executed for some reason. For
example, because of the VM exit or test/VM hang up. Since this
operation is executed at the Test level, and Test may consist of
multiple test cases, all information from actually executed test cases
may be lost. It will be unknown which test case caused the problem.</li>


  <li>when the device is slow and optimization is used (multiple
tests in bundle), the whole test cycle will be shorter, but every
individual test bundle will take time to execute. Without visual
indication it may be hard to distinguish if tests are being executed
that slow, or it is just device&nbsp; stopped responding an hour
ago.</li>


  <li>if test hung, it should be possible to cancel it
with&nbsp; minimal impact on the&nbsp; execution process,
without stop/restart the whole test run.</li>


</ul>


<p>One solution for these debugging problems is using the <a href="http://weblogs.java.net/blog/alexeyp/archive/2007/02/java_me_testing_1.html#Test_export">Test
Export</a> feature
to
run tests isolated from the test harness environment. Test results
from standalone execution are not sent to the JT harness, they are
displayed
on the device console, if there is such available. </p>


<h2>Interactivity for Automated Tests</h2>


The proposed solution for all above problems is to introduce
interactivity at the device side. We added an option to use Interactive
MIDlet Agent for test execution, that provides the following features:
<ul>


  <li>shows the current status on the device display</li>


  <li>continuously saves
the current status of the RMS </li>


  <li>provides a control for saving the current status of
the RMS </li>


  <li>allows viewing results stored in the RMS </li>


  <li>provides a control for canceling the
current test/test bundle and starting the next test/test bundle</li>


</ul>


<p> These interactive features are also available in the Test Export mode.</p>


<h3>User Interface</h3>


Additional set of standard configuration questions were added to the ME
Framework Configuration Editor. To make ME Framework to use this
on screen tracing functionality, see the <a href="http://weblogs.java.net/blog/alexeyp/archive/GUIAgent/interview." onclick="window.open('http://weblogs.java.net/blog/alexeyp/archive/GUIAgent/interview.','popup','width=988,height=394,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">screenshot</a>
.
<br clear="left">


<p>When the JT harness executes tests with these configuration
settings,
the user interface on the device side displays the following
information and commands:</p>


<ul>


  <li>Information string with a common count of tests done, a
count of failed tests, and a count of passed tests</li>


  <li> Information about the current test running </li>


  <li>Commands to cancel
the test/test bundle and to save the results to the RMS</li>


</ul>


As you can see <a href="http://weblogs.java.net/blog/alexeyp/archive/GUIAgent/agent." onclick="window.open('http://weblogs.java.net/blog/alexeyp/archive/GUIAgent/agent.','popup','width=366,height=729,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">here</a>
,
this new interface resembles the interface of device-side harnesses,
that are available for execution of <a href="http://www.devx.com/wireless/Article/32540">mobile
variations of JUnit</a>.&nbsp;
<p>To view results stored in the RMS, use the
RMSReader MIDlet application. It has a simple interface that uses
a Command to change the display either to "view log" or to "view ref"
output.</p>


<h3>Open Issues</h3>


<p>There should be better solutions then one that we chosen for canceling a hanging test. </p>


<p>The 'cancel test' functionality requires each test to be run in a
separate thread. Since Connected Limited Device Configuration has no
method to interrupt threads in order to break test execution and
proceed to the next test, a special flag is used to mark the test
thread as canceled. The canceled thread is set to minimum priority and
the agent starts to execute the next test.
</p>


]]>

</content>
</entry>
<entry>
<title>Java ME Testing - Debugging Test Failures</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2007/02/java_me_testing_1.html" />
<modified>2007-03-01T19:10:24Z</modified>
<issued>2007-02-23T07:44:26Z</issued>
<id>tag:weblogs.java.net,2007:/blog/alexeyp/369.6674</id>
<created>2007-02-23T07:44:26Z</created>
<summary type="text/plain">This article offers some suggestions for debugging test failures when testing Java ME Implementation - with a special focus on the JT harness and new ME Framework features that support debugging.</summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Community: Mobile &amp; Embedded</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[<p>What to do when
tests of Java<sup>TM </sup>ME implementation test suite
fail ?</p>
<p>This article offers some suggestions for debugging test
failures - with
a special focus on the <a href="http://jtharness.dev.java.net/">JT
harness</a> and <a href="http://cqme.dev.java.net/">ME
Framework</a> features that support debugging. My initial
motivation for writing this article was to announce improvements in the
<a href="#Test_export">Test
Export</a> feature, however the topic is just so entertaining that
I couldn't stop there. :-)</p>
<p><a href="http://en.wikipedia.org/wiki/Debugging">Debugging</a>
in
Java Micro Edition (ME) has number of challenges. Issues related to
debugging problems in Java ME implementation can include any of the
following items:<br>
</p>
<ul>
  <li>The problem can reside at the Java layer or in the native
code.</li>
  <li>Mobile device is usually a component of a larger
system rather then isolated system. <br>
For example, this may be
connectivity of
different kinds, integration of mobile application with server-side
components.</li>
  <li>Multiple technologies and standards are involved. <br>
For
example,
the CLDC/MIDP implementation may communicate with
javacard using <a href="http://www.jcp.org/en/jsr/detail?id=177">SATSA</a>
and with Java SE/EE using RPC API of <a
 href="http://www.jcp.org/en/jsr/detail?id=172">jsr172</a></li>
  <li>The device might not provide access to the Java console or
support of debugging protocols.</li>
</ul>
In addition, automated test suites do not automatically simplify the
problem of debugging, but
instead add their own set of unique complexities. The fact that some
tests fail might&nbsp;not
provide enough information to help you identify the problem. Often it
can take time and&nbsp;require a certain certain amount of
effort to determine what is wrong.&nbsp;
<p>Problems, specific to automated Java ME test suites, have the
following roots:<br>
</p>
<ul>
  <li>Automated test execution on CLDC/MIDP requires special
AMS mode, autotest. <br>
CDC/PBP execution mechanisms may be complex as
well. Basic information on this topic can be found in the first
article:&nbsp;<a
 href="http://weblogs.java.net/blog/alexeyp/archive/2006/11/testing_java_me_1.html">Introduction
to Java ME Testing Tools</a>.</li>
  <li>The distributed test execution mechanism. <br>
This includes
execution of a test with test harness (JT harness) running on the
desktop and the test
agent is running on the device. In addition the distributed tests
themselves consist of multiple components (such as SE and ME
components).</li>
  <li>A complex <a
 href="http://weblogs.java.net/blog/alexeyp/#Configurable">configuration</a>
mechanism. <br>
Before starting to run
tests you need to configure test harness according to the environment
and implementation under test. This complicates the debugging by making
the whole system more integrated. Tighter integration makes it
difficult to identify the problem by isolating the piece of the test
code from the test harness.</li>
  <ul>
  </ul>
</ul>
<h2>Debugging Tips</h2>
The goal of this section is
to provide you with a list of practical steps that could be taken by
the ME
Framework and JT harness user in the process of analyzing test
failures. These debugging tips range from know-how to very natural and
evident.&nbsp;<br>
<h3>Tip 1 - Browse the code, test specification, test output.</h3>
If tests are written well, atomic, documented, provided with good
trace information, if type of failure allows this trace to be viewed at
the
console or in the test result, stored by the test harness. If all these
'ifs' are there, it is enough to look at test spec, sources and output
to identify the
problem.
It is not rare case, btw. <a href="http://weblogs.java.net/blog/alexeyp/archive/sample.jtr.txt">Example</a>
of JT harness test result file contains all information, that test
harness could provide to help with debugging,&nbsp;has sections for:<br>
<ul>
  <li>recognized parameters of Test Description</li>
  <li>values of environment variables</li>
  <li>version</li>
  <li>time stamp</li>
  <li>exact command used for test execution</li>
  <li>test output itself</li>
  <li>lots of other stuff, useful and not</li>
</ul>
As I can see, other then standard, old-style <span
 style="font-style: italic;">.jtr</span> files and
reports,<span style="font-style: italic;"></span>
most of teams working actively with JavaTest <sup>TM</sup>
harness-based test suites use reports, customized for their needs and
type of work they are doing.<br>
<h3>Tip 2 - Turn on logging<br>
</h3>
In the ME Framework, you can configure the logging level in the
following places:
<ul>
  <li>Logger API used by the ME Framework implementation classes.</li>
  <li>'Debug output' options for ME Framework components</li>
</ul>
<h4>Turn on Logger</h4>
This type of tracing is available for the server side of the ME
Framework.&nbsp;It is more useful when identifying problems with
the ME Framework than
when debugging problems with tests. To identify problems with the
framework, you need to understand what is going on
with the internals, what test filters are used, etc. It can also be
useful when debugging problems with types of tests that use some
service run
by the test harness.
<p>To turn this type of
logging on you need to specify the config file through java system
property when starting JavaTest harness, like this:
</p>
<p style="background-color: rgb(204, 204, 204); color: rgb(0, 0, 0);"><code>java^<br>
&nbsp;&nbsp;&nbsp;
-Djava.util.logging.config.file=D:/exec/0-configs/j2me-fw-log.properties^<br>
&nbsp;&nbsp;&nbsp; -jar javatest.jar</code></p>
With the following <a href="http://weblogs.java.net/blog/alexeyp/archive/j2me-fw-log.properties.txt">example</a>
of a log config file,
you will have <a href="http://weblogs.java.net/blog/alexeyp/archive/log.txt">this</a> type of
content on your console.<br>
<h4>ME Framework Tracing Capabilities</h4>
As previously mentioned, one of problems here is that the entire system
is distributed. Each major piece of functionality is provided by
several
components, working on both the harness and the device sides. To be
able to
track process steps, it is possible to turn on logging of debug
information to console for every subsystem. These subsystems are listed
below. Each of them has nice illustration in the <a
 href="http://java.sun.com/javame/meframework/docs/meframework_devguide.pdf">ME
Framework
Developer's Guide</a> (1.5Mb) and in the following text I have
referred to the corresponding
pages in that
document.
<ul>
  <li><span style="font-weight: bold;">Test
execution subsystem (CLDC/MIDP), Figure 3-4 at page 27. </span><br>
The trace lists control messages between the harness and the device
that
correspond to <a
 href="http://weblogs.java.net/blog/alexeyp/archive/2006/11/testing_java_me_1.html#Autotest">Autotest</a>
execution flow. This may be&nbsp;useful if test execution is very
slow, like when
there are multiple tests packaged per test bundle, to make sure that
there is a progress, to find which exactly test crashed the VM, to see
exact test parameters and test result outside of the harness. The
real-time trace can be observed on the device console, if the console
is
available. See a <a href="http://weblogs.java.net/blog/alexeyp/archive/Channel_Options1." onclick="window.open('http://weblogs.java.net/blog/alexeyp/archive/Channel_Options1.','popup','width=990,height=395,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">snapshot</a>

from the Configuration Editor that shows which Interview questions are
responsible for this option. Check <a href="http://weblogs.java.net/blog/alexeyp/archive/verbose.log">server</a>
and <a href="http://weblogs.java.net/blog/alexeyp/archive/device.log">device</a>-side examples
of trace output.<br>
  </li>
  <li><span style="font-weight: bold;">Distributed
test framework,&nbsp;</span><span
 style="font-weight: bold;">Figure 3-5 at page 29.</span><br>
Here you can see all messages exchanged by this framework, who sends
what. Needless to say, it is one of the important features used to
investigate failures of
distributed tests. Simple interactive test with 3 static images sends <a
 href="http://weblogs.java.net/blog/alexeyp/archive/distributed.log">that many</a> messages to
pass.<br>
  </li>
  <li><span style="font-weight: bold;">Agent
(CDC/PBP).</span><br>
Passing '-trace' option to agent displays everything going inside of it
at
the console (if available). This is a standard feature of the JT
harness
Agent. The <a href="http://weblogs.java.net/blog/alexeyp/archive/cdc.log">example</a> of the
Agent trace can serve as a good illustration to <a
 href="http://weblogs.java.net/blog/alexeyp/archive/2006/11/testing_java_me_1.html#CDC">CDC-specific
approaches</a> to address test suite scalability. Note the data
exchanges and test classes instantiations for every test. </li>
</ul>
When JT harness or a ME Framework-based test suite is used as a part of
automated regression testing subsystem for nightly/weekly test
execution, we turn all debugging options
on by default, to have more data ready for offline failure analysis, if
required.<br>
<h3>Tip 3 - Execute the test standalone</h3>
The natural step of isolating the problem is isolating failing test
from the test harness environment by executing it standalone. It may be
possible in some situations to modify original test source, recompile
it, and execute in the debugger.
<p>Each individual test usually has an application entry point,
allowing to
execute it outside of the test harness. This is usually static main()
taking
an array of
parameters (the same parameters as those passed to the test by the test
harness). You
can put test classes in the classpath and call the test by the class
name.
</p>
<p>To get values of test parameters
you may
need to dig into test environment. To execute standalone test
corresponding to the following sample test description:</p>
<table style="text-align: left;" border="0"
 cellpadding="0" cellspacing="0">
  <tbody>
    <tr>
      <td style="background-color: rgb(192, 192, 192);">
      <table style="background-color: rgb(204, 204, 204);"
 summary="Javatest Test Description" class="TestDescription"
 border="1">
        <thead><tr>
          <th scope="col">Item</th>
          <th scope="col">Value</th>
        </tr>
        </thead><tbody>
          <tr>
            <td scope="row"> <b>title</b> </td>
            <td> java.security.KeyFactory generatePublic() Tests </td>
          </tr>
          <tr>
            <td scope="row"> <b>source</b> </td>
            <td> generatePublicTests.java </td>
          </tr>
          <tr>
            <td scope="row"> <b>executeClass</b>
            </td>
            <td>com.sun.tck.satsa.tests.api.java.security.KeyFactory.generatePublicTests
            </td>
          </tr>
          <tr>
            <td scope="row"> <b>keywords</b> </td>
            <td> runtime positive distributed </td>
          </tr>
          <tr>
            <td scope="row"> <b>executeArgs</b>
            </td>
            <td> -envValue $sampleValue </td>
          </tr>
        </tbody>
      </table>
      </td>
    </tr>
  </tbody>
</table>
<p>you must execute the following command:</p>
<p style="background-color: rgb(204, 204, 204); color: rgb(0, 0, 0);"><code>
export sampleValue=&lt;find
'sampleValue' variable in the test environment&gt;<br>
java -classpath $TEST_HOME/classes^<br>
&nbsp;&nbsp;&nbsp;
com.sun.tck.satsa.tests.api.java.security.KeyFactory.generatePublicTests^<br>
&nbsp;&nbsp;&nbsp; -envValue $sampleValue</code></p>
<p>Or even simpler - JT harness result file contains the exact
command
and values of parameters that must be executed. See
section&nbsp;<span style="font-style: italic;">messages:(1/693)</span>
in the <a href="http://weblogs.java.net/blog/alexeyp/archive/sample.jtr.txt">example</a>.</p>
<p>Unfortunately this works well only in CDC and Java SE
execution
modes. This approach will not work for&nbsp;CLDC/MIDP, where you
need the application to be packaged and deployed before you can execute
it.<br>
</p>
<h3>Tip 4 - store for offline analysis</h3>
In CLDC/MIDP execution &nbsp;mode, instead of using autotest
feature, one can download individual test applications manually for
offline analysis, using web browser, for example. This can help
identify problems related to interpreting the application descriptor
and
manifest.<br>
<h3>Tip N - use common sense</h3>
The list is not and can not be complete, yet more tips from the top of
the head:<br>
<ul>
  <li>Vary configuration parameters</li>
  <li>Add trace printing into test itself or into tested code</li>
  <li>Execute the test on the another implementation to verify
its correctness</li>
  <li>...</li>
</ul>
We try many different debugging techniques all the time and very often
they work. &nbsp;But the most effective solution, that is supposed
to help with digging out
the most complex problems is ... Test Export.
<h2>Test Export</h2>
<p>The ME Framework is a quite complex set of interacting
components involved in test execution. When a test is
reported as failed by the <a href="https://jtharness.dev.java.net/">JT
Harness</a> it's not always evident where the bug is and how to
track
it down.&nbsp;Most often, when users are trying to track down a
bug, they want to run the failed test standalone on
the device under test. This is where the&nbsp;<span
 style="font-weight: bold;">Test Export</span> feature
can help. Test Export converts an individual test into a small
standalone Java ME application containing the test, which can be
executed, debugged, or used in any way convenient for the user.</p>
<h3>Getting Test Export as a side-effect of Autotest execution</h3>
<p>A very simple, partial implementation of the test export was
available
in the ME Framework from the beginning. It was a hack of a standard
CLDC/MIDP execution mechanism., described by the following scheme.</p>
<p>
</p>
<p style="text-align: center;"><img alt="texec.PNG" src="http://weblogs.java.net/blog/alexeyp/archive/texec.PNG" width="555" height="406" /></p>
<p style="text-align: center;"><span
 style="font-weight: bold;">FIGURE X. Autotest mode.</span></p>
<p>In order to turn test into CLDC/MIDP application that executes
separately
from the harness, one must replace all these arrows, representing
some message exchanges, with static data.</p>
<p>For the initial ME Framework implementation of the test
export feature, test packages where
supplied with all information necessary for test execution (that
replaced links&nbsp;3 and 4). The execution server was packaging
test bundles
without waiting for any requests from AMS (links 1 and 2). For the test
harness, test
status indicated success of packaging and not actual test execution
(link&nbsp;5). When executed, tests did not send result to the
execution
server but just printed them on the console (link&nbsp;5). Tests
were packaged with all test data but not automatically downloaded to
the device and test packages not removed after execution cycle
completed.</p>
<p>
Even this simple and limited approach allowed to solve some
troubleshooting-related tasks. For example, a QA engineer responsible
for TCK execution on the development build of the implementation could
use these exported test packages as attachments to bug reports. A
development engineer&nbsp;not familiar with TCK execution
could use it to reproduce the problem and verify the fix.</p>
<h3><a name="Test_export"></a>Test Export in
ME Framework 1.2</h3>
<p>The previous implementation of the Test Export was not
complete.&nbsp;Evident limitations were that only simple
non-distributed&nbsp;tests were
exported and not test sources. For the user, this meant that a created
application could not be modified and rebuilt. The previous
implementation also exported only .jar files and not .jad files.</p>
<p>Implementing the full Test Export feature for all types of
tests is a challenging task requiring very accurate tracking of all
test dependencies. The following are examples of such dependencies: </p>
<ul>
  <li>Custom jad/manifest entries</li>
  <li>Test specific security conditions</li>
  <li>Code and resource dependencies of test and test suite level</li>
</ul>
<p>Identifying all test sources associated with a distributed
network test is not a simple task. To make this feature really
user-friendly, one should provide parts of the test execution
infrastructure, such as the provisioning server for MIDP.</p>
Many of these problems are addressed in the new Test Export
implementation that was recently integrated into the ME Framework by
Dmitry Trounine.
<p>To initiate Test Export for a ME Framework 1.2-based test
suite, the
user should first open the Configuration Editor and, in the interview,
set test export mode on. Then the user should specify the export
directory (the location where exported test will be saved) and maybe
some additional parameters, such as the '<i>Prefix of URLs to JAR
files</i>' parameter specific for the MIDP platform. See the
following <a href="http://weblogs.java.net/blog/alexeyp/archive/Export." onclick="window.open('http://weblogs.java.net/blog/alexeyp/archive/Export.','popup','width=781,height=653,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">screen-shot</a> of the JT harness Configuration Editor:
Configuring Test Export.
</p>
<p>Finally, the user should select the test or tests to export
and run them just as in a regular test run. In test export mode,
instead of executing tests on a device, the selected test or tests are
saved in the specified test export directory.
</p>
<h4>What
you get with test export?</h4>
<p>When the test export is
done, the following
content is created in the export directory:</p>
<ul>
  <li> Java ME applications in JAR files named test1.jar,
test2.jar, etc. containing the exported tests. </li>
</ul>
<blockquote>
  <p>Just as with any other Java application, these applications
can be uploaded on any suitable device and launched. The exported tests
are executed in the same way that they are executed by ME Framework but
in standalone mode, printing the diagnostics and test result on the
device screen.</p>
</blockquote>
<ul>
  <li> In MIDP mode, Java application descriptors (JAD files) are
generated: test1.jad, test2.jad, etc. </li>
</ul>
<blockquote>
  <p>These descriptors are properly configured: </p>
  <ul>
    <li>They contain the same attributes as in regular test runs.
    </li>
    <li>They are signed and include certificates if the test
suite was configured for trusted MIDP security mode. </li>
    <li>They contain proper links to the exported JAR files.</li>
  </ul>
  <p>You can use the generated JAD files for OTA provisioning of
exported tests by putting them on any suitable HTTP server or by using
the <i>special provisioning server</i> included with the
ME Framework.</p>
</blockquote>
<ul>
  <li> Java sources of exported tests in src subdirectory. </li>
</ul>
<blockquote>
  <p>These source files can be used for debugging or rebuilding
the exported tests.</p>
</blockquote>
<ul>
  <li>
    <p>Class files in classes subdirectory.</p>
  </li>
  <li> Ant build script in build.xml file. </li>
</ul>
<blockquote>
  <p>Yeah! Users can change the exported tests by modifying its
sources and rebuilding them with this build script. It contains all
necessary targets for compiling sources, updating JAR files from
classes, and signing JAD files. In addition, build.properties is also
generated in the export directory. It defines properties used by the
build script and can be used to configure the build. For example,
property <i>trusted, </i>if defined, triggers signing JAD
files when updating exported tests.</p>
</blockquote>
<ul>
  <li> Additional libraries and tools in lib subdirectories. </li>
</ul>
<blockquote>
  <p>These are not part of exported tests and are not required
for using them, but can be also helpful. For example, <i>exportSigner.jar
  </i>is a tool for updating signatures and certificates of
MIDlet suites with tests in those cases where the tests contained in it
have been modified and its JAR file has changed.</p>
</blockquote>
<ul>
</ul>
<p>Let's look at this new feature from the point of view of a Sun
Java Wireless Toolkit (Wireless Toolkit) user. Before the test export
feature was introduced, users could execute tests on the emulator by
using its autotest mode:</p>
<p style="background-color: rgb(204, 204, 204);"><code><br>
$WTK_HOME/bin/emulator -Xautotest
http://localhost:8080/test/getNextApp.jad<br>
</code></p>
<p>This command launches the emulator and specifies an URL at
which the emulator should look for tests to download. At this URL
resides the execution server of ME Framework. The execution server
responds to 'getNextApp.jad' requests by sending new and new tests from
a large test suite. The emulator fails in a loop repeating three steps
(install, execute, remove) for each downloaded test until the execution
server has no more tests to send. There was no way to get just one test
(corresponding JAD and JAR files) for standalone execution. In
addition, users of the Wireless Toolkit know that autotest mode doesn't
allow debugging!</p>
<p>Now, with the test export feature, a user can select the test
to debug and export it to any appropriate location. JAR and JAD files
are generated and can be executed on emulator. The following is a
typical command for launching the exported test on the Wireless Toolkit
emulator:</p>
<p style="background-color: rgb(204, 204, 204);"><code><br>
$WTK_HOME/bin/emulator -Xdescriptor $EXPORT_DIR/test3.jad<br>
</code></p>
<p>During its execution, the test prints the output to stdout.
Click <a href="http://weblogs.java.net/blog/alexeyp/archive/exportlog.txt">here</a> to view an
example.</p>
<p>This time, debugging the test during its execution is easy.
Just add the <code>-Xdebug</code> argument to last command
with all necessary parameters. You can then use your preferred debugger
with the IDE of your choice to debug the test with its sources which
are also exported. </p>
<h3>Future Plans</h3>
<p>The next planned improvement for debugging support will come
from the integration of &nbsp;Skavas's GUI Agent. This will allow
you to use GUI and RMS in addition to console output for execution of
exported tests. Watch for more information about this in the future -
it's a topic for another post.</p>
<p>The Test Export feature is under development right now and you
can improve it by posting on ME Framework <a
 href="http://forums.java.net/jive/category.jspa?categoryID=57">forums</a>.
Propose your improvement or new feature and you may see it in one of
the next releases.</p>
]]>

</content>
</entry>
<entry>
<title>Testing Command-Line Applications using Golden-File approach</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2007/02/testing_command_1.html" />
<modified>2007-02-23T08:04:49Z</modified>
<issued>2007-02-17T20:39:12Z</issued>
<id>tag:weblogs.java.net,2007:/blog/alexeyp/369.6565</id>
<created>2007-02-17T20:39:12Z</created>
<summary type="text/plain">The story describes our experience of using JavaTest TM harness in a quality test suite.
</summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Testing</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[This article is addressed to those interested in JavaTest <sup>TM</sup>
harness and its open source version <a
 href="http://jtharness.dev.java.net">JT harness</a>.
Its goal is to serve as an example of using JavaTest harness outside of
the world of <a
 href="http://weblogs.java.net/blog/alexeyp/archive/2007/01/test_harness_fo.html">productized
test suites</a>.&nbsp;
<p>The story describes our experience of using JavaTest-style
test format
and JavaTest itself as a test harness for functional and regression
tests. The tested item is a command-line application.
</p>
<h3>Background</h3>
The specific command-line application being tested is ApiCover, one of
the components provided to JCP members in the <a
 href="http://www.jcp.org/en/resources/tdk">JCTT</a>
package. Briefly, it takes a description of Java <sup>TM</sup>
API to test
and pointer to the test
classes and calculates estimation of the test coverage. The tool
supports multiple
options.
<p>The most frequently observed approach to functional test
development for such simple cases is
to have a set of shell scripts placed into a directory hierarchy. Each
of these scripts performs one simple check and reports results to the
console. Tests are run by a trivial test harness, usually another shell
script, that performs test iteration and joint status reporting. Test
specifications usually come separately from tests.</p>
<h3>How it was done here</h3>
In case of ApiCover the test suite was JavaTest-based. The choice was
quite natural, given the long history of using JavaTest for testing of
command-line tools, like Java compiler or
CLDC preverifier.
<p>Every individual
test description in this test suite contains information on how to
launch the
tool and how its output should be verified. All tests in this test
suite are written using the "golden-file" approach. The golden data is:
</p>
<ul>
  <li>application output streams both stderr and stdout</li>
  <li>exit code</li>
  <li>set of output files</li>
</ul>
The test suite execution is done using JavaTest harness and set of
trivial scripts, responsible for launching the application under test,
capturing and storing its output and
comparing the results with stored data. The main idea is to make it
simple to launch ApiCover in multiple modes and verify the result.
Result verification may be textual diff or xml validation, data storing
is optional.
<p>The test development scenario for the new test is as follows:
</p>
<ul>
  <li>Create test description, including:</li>
  <ul>
    <li>test case specification (textual, optional)</li>
    <li>parameters, comparison procedure to use</li>
  </ul>
  <li>Run test in the 'setup' mode</li>
  <li>Validate output and mark it as 'golden file'</li>
</ul>
When application is changed and test starts to&nbsp;fail, validate
the new output and mark it as 'golden file' if appropriate.
<p>Test Description example:<br>
<table style="text-align: left;">
  <tbody>
    <tr>
      <td style="background-color: rgb(192, 192, 192);">
      <h4>Description</h4>
      <p>This test verifies that tool includes all
public/protected class
members into the basic report if -detail option specified by '4' value
and -format value is 'xml'. </p>
      <h4>Test Descriptions</h4>
      <p>Test cases included:<br>
report000 </p>
      <p>
      <table class="TestDescription" border="1">
        <tbody>
          <tr>
            <td> <b>title</b> </td>
            <td> report000 </td>
          </tr>
          <tr>
            <td> <b>executeArgs</b> </td>
            <td> -apiinclude testapi -tck tcks/all/classes -api
apis/all/all.sig
-detail 4 -format xml </td>
          </tr>
          <tr>
            <td> <b>keywords</b> </td>
            <td> runtime </td>
          </tr>
          <tr>
            <td> <b>executeClass</b> </td>
            <td> diff </td>
          </tr>
        </tbody>
      </table>
      </p>
      </td>
    </tr>
  </tbody>
</table>
<br>
What it means:<br>
</p>
<ul>
  <li><span style="font-weight: bold;">Description</span>
- Contains verbal Test Case Specification</li>
  <li>The <span style="font-weight: bold;">table</span>
describes actual test cases that will
be executed. Description is done in the language of JavaTest's <code>HTMLTestFinder</code>.
Below you can see how these specific descriptions are interpreted by
the execution <code>Script</code>, which used for this
test suite:<br>
    <br>
    <table class="TestDescription" border="1">
      <tbody>
        <tr>
          <td> <b>title</b> </td>
          <td>Unique ID of the test case </td>
        </tr>
        <tr>
          <td> <b>executeArgs</b> </td>
          <td>Command-line arguments&nbsp;to pass to the
tool. </td>
        </tr>
        <tr>
          <td> <b>keywords</b> </td>
          <td> This field is used by main test filtering engine
of JavaTest harness. Not used in this test suite. </td>
        </tr>
        <tr>
          <td> <b>executeClass</b> </td>
          <td> Which of predefined golden file comparators to use
for this test</td>
        </tr>
      </tbody>
    </table>
  </li>
</ul>
<h3>Pros and Cons&nbsp;</h3>
<p><span style="font-weight: bold;">Pros:</span></p>
<ul>
  <li>All traditional prerequisites come from using a
specialized test harness, like test execution and test result
management, test specification, source, and test result browsing,
parallel test execution, test exclusion and filtering, multiple
environments support (JDK version, for example)
etc etc.&nbsp;</li>
  <li>We got highly automated and maintainable test suite,
preserved high consistency through all tests</li>
  <li>Test development is fast and simple</li>
  <li>Application can be tested at multiple platforms by
design.&nbsp;When testing Java applications
that need to be verified in multiple environments, it is critical to
avoid a dependency on a specific scripting language used for test
development.</li>
  <li>We avoided information duplication. The test code is linked
to the&nbsp; test
specification and a test report</li>
</ul>
<span style="font-weight: bold;">Cons:</span>
<ul>
  <li>Good test harness is a complex tool that takes time to
study. Infrastructure may need to be adjusted for it.</li>
  <li>The "golden file" approach is naturally limited, can not be
enough to cover everything</li>
  <li>When output is unstable, this approach may not work or may
require
sophisticated comparators. The most obvious example is in processing
timestamps.</li>
</ul>
As usual, almost all of pros have drawbacks in some situations,
one size
never fits all.<br>
]]>

</content>
</entry>
<entry>
<title>Test Harness for Product-Quality Test Suites</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2007/01/test_harness_fo.html" />
<modified>2007-02-26T19:08:46Z</modified>
<issued>2007-01-28T21:07:42Z</issued>
<id>tag:weblogs.java.net,2007:/blog/alexeyp/369.6427</id>
<created>2007-01-28T21:07:42Z</created>
<summary type="text/plain">This article provides some criteria that can be used when choosing a test harness for certain types of test suites. It describes requirements that are treated as most important for JT harness, the open source version of the JavaTest TM harness, and ME Framework.</summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Community: Java Tools</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[This article is oriented to developers of test suites of any kind.
It provides some criteria that can be
used when choosing a test harness for certain types
of test suites. It describes
requirements that are treated as most important for <a
 href="https://jtharness.dev.java.net/">JT
harness</a>, the open source version of the JavaTest <sup>TM</sup>
harness. The <a href="https://cqme.dev.java.net/framework.html">ME
Framework</a> is a JT harness plug-in for Java<sup>TM</sup>
Micro Edition (ME), driven by the same principles.
<p>The requirements for the quality of test suites vary depending
on the
engineer's goal, the product being tested, how many and what kind of
people will be using the test suite, how often and for how long, and
how the test suite will be maintained. These factors may vary depending
on whether you write unit tests for yourself or your project, or if, as
a member of the SQEgroup on a large
project, you are developing a test suite that will be executed by the
SQA group.&nbsp;</p>
<p>Sun Microsystems has a long successful story of
development
large
test suites of various types.
The development of the JavaTest&nbsp; harness
was highly
influenced by
its adoption in Java <sup>TM </sup>Technology
Compatibility Kits (TCK).&nbsp;The majority, if not all of Sun's
TCKs are built on the JavaTest harness. The key consequences of
this:
</p>
<ul>
  <li>these test suites (TCKs) are <span
 style="font-style: italic;">products</span>,
developed by one group to be
used outside of it on a constant basis for significant
period of time.</li>
  <li>'<span style="font-style: italic;">used in all
TCKs from SUN</span>' means that test suites built on JavaTest
harness were run on all Java-compatible implementations in the world -
just
because implementations become Java-compatible after passing the TCK.
It means a
lot !</li>
  <li>though it is not the only area where JavaTest harness is
used,
the main focus is on testing of Java platform, not applications.</li>
</ul>
These test suites and a test harness have satisfy the requirements,
listed below:<br>
<ul>
  <li><a href="#Highly_automated">Highly automated</a></li>
  <li><a href="#Documented">Documented</a></li>
  <li><a href="#Scalable">Scalable</a></li>
  <li><a href="#Reliable">Reliable</a></li>
  <li><a href="#Easy_to_debug">Easy to debug</a></li>
  <li><a href="#Configurable">Configurable</a></li>
</ul>
<h3><a name="Highly_automated"></a>Highly
automated</h3>
Test suites based on JT harness and ME Framework in Java ME
case, are
supposed to be
executed on a continuous basis through the whole development cycle. In
the case
of TCKs, this means regression testing through development cycle and
certification of the completed product. The more we can automate the
better.&nbsp;The requirement for automation includes both providing
a complete
command line interface to the test harness and automation of the test
frameworks..<br>
<h3><a name="Documented"></a>Documented</h3>
<h4>Test harness and framework documentation</h4>
The importance of having good user documentation for tools like JT
harness should
be understood. In this case 'users' means users of the final test
products,
based on these tools.
<h4>Test documentation</h4>
Productized test suites are supposed to consists of well-documented
tests, where all necessary information on each test can be
obtained not just from the test code but from the test
documentation.&nbsp;It is up to developers to decide whether to
provide such kind of
documentation for the test suite. The JT harness provides a
mechanism to combine both formal test descriptions and user
documentation in the same HTML document.
<h3><a name="Scalable"></a>Scalable</h3>
Some test suites, that are built on JavaTest harness, are large.
Ideally, the
only impact from increasing the size of the test suite should be linear
dependency on resources - either time or number of devices - that are
being used for testing. There are multiple ways used to achieve this,
some were
described in the <a
 href="http://weblogs.java.net/blog/alexeyp/archive/2006/11/testing_java_me_1.html">previous
article</a>.
<h3><a name="Reliable"></a>Reliable</h3>
Each test suite must run to completion, which means not only that the
framework code must run without errors but the test failures, if any,
must not interrupt the process. Running test suites without
interruption is an important quality criterion by itself but for large
test suites it becomes a critical requirement. Execution of a really
large test suite may take weeks, tests may run overnight. The
test engineer must be provided with as many comprehensive results after
the execution completes as possible.
<p>Any resource
leaks or synchronization problems in the framework code are very high
priority issues.<br>
</p>
<h3><a name="Easy_to_debug"></a>Easy to debug</h3>
While the process of test execution is sometimes demanding, the bigger
challenge is when tests fail. There are many features intended to
simplify
failure debugging, both in the JT harness and in the ME Framework.
<p>Debugging-related features range from providing test sources
linked to html test
descriptions and browsable from JT harness, logging capabilities,
possibility to execute tests standalone without a harness.&nbsp;The
ME Framework provides the features that are most critical for Java
ME, such as exporting each test to a standalone Java ME application.</p>
<h3><a name="Configurable"></a>Configurable</h3>
A&nbsp;complex test suite, that is built to test multiple products
in
multiple environments, may have <span style="font-style: italic;">hundreds</span>
of configuration options.&nbsp; The configurability here is not
just providing a way to set values for these options but a
user-friendly mechanism, allowing optimization of the process and
providing documentation for your test suite settings, sufficient to
give a conscious answer to every
configuration question.
<p>The list is evidently not complete. Comments and additions are
welcome.</p>
<p>


]]>

</content>
</entry>
<entry>
<title>Testing Java ME Implementations - AMS</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2006/12/testing_java_me_2.html" />
<modified>2006-12-22T14:14:57Z</modified>
<issued>2006-12-18T18:57:53Z</issued>
<id>tag:weblogs.java.net,2006:/blog/alexeyp/369.6189</id>
<created>2006-12-18T18:57:53Z</created>
<summary type="text/plain">This article discusses different approaches, that are used to test AMS-related functionality of the Java ME implementation</summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Community: Mobile &amp; Embedded</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[<h2>API testing vs AMS testing</h2>
The <a
 href="http://weblogs.java.net/blog/alexeyp/archive/2006/11/testing_java_me_1.html">previous
article</a> described the primary test execution mechanisms,
used in the world of Java ME implementation test suites:<br>
<ul>
  <li>'Server/Agent' approach, used for CDC implementations,
where test code is downloaded by Agent application from the Server</li>
  <li>'autotest' approach, where tests are packaged into sequence
of applications, that are repeatedly downloaded/executed/removed.</li>
</ul>
Please make sure to familiarize yourself with these concepts, I will be
referring to them later.
<p>Today I would like to focus on limitations of
these approaches, what
types of functionality can not be tested this way and describe several
solutions. Some of these ideas are
implemented in <a href="https://cqme.dev.java.net/framework.html">ME
Framework</a>,
there are variations,
implemented in other Java ME testing products.
</p>
<p>Talking about limitations, the main point is that using these
mechanisms one can verify what is going <span
 style="font-style: italic;">inside</span> of a <span
 style="font-style: italic;">single</span> application
when it is <span style="font-style: italic;">running</span>.
These mechanisms do not allow application restarts and crashes, assume
fixed scenario and only single application running at any given time. <br>
Note, that this is usually all that is needed to test&nbsp; of Java
API behavior. Just it (API) is not the only focus of standards and
testing in the Java
ME world.</p>
<p>Examples of Java ME standards, that can not be tested with
the above mentioned approaches, are as follows:</p>
<ul>
  <li><a
 href="http://developers.sun.com/techtopics/mobility/midp/articles/ota/">MIDP
OTA</a> specification, among other things, describes
criteria, that result in an application installation failure. Tests
for these requirements need to meet these criteria and verify that <span
 style="font-style: italic;">installation
fails</span>. API testing mechanisms work only
if install&amp;run steps pass successfully.</li>
  <li><a
 href="http://developers.sun.com/techtopics/mobility/midp/articles/pushreg/">MIDP
PushRegistry</a> specification talks about <span
 style="font-style: italic;">static registration</span>
of the Push event handlers. If application is provided with special
attributes, it gets registered in the PushRegistry to handle incoming
WMA messages, for example. Testing of this functionality assumes
the following steps are present in the test procedure:<br>
- an application with Push registration is
installed<br>
-the push event is initiated<br>
- application is launched to handle
the event<br>
The scenario does not fit into the Server/Agent scheme, because it
requires
an application installation to happen as part of the test, and does not
fit into the autotest scheme,
because it does not have automatic 'run/remove' steps, that are
mandatory parts of the 'autotest' cycle.</li>
  <li><a
 href="http://developers.sun.com/techtopics/mobility/midp/ttips/chapi/index.html">CHAPI</a>
spec talks about communications between <span
 style="font-style: italic;">two applications</span>,
the ContentHandler and Invoker.</li>
</ul>
Overall, there is a considerable number of JCP and non-JCP standards
that focus not only on API but on applications. Testing of these
standards requires non-standard techniques.
<p> The cases above are usually
associated with the platform
component, named JAM (Java Application Manager) or AMS
(Application Management Software), therefore the testing
techniques that involve AMS operations (install/update/run/remove) or
application life cycle (start/pause/stop/destroy) will be referred to
as 'AMS testing'.<br>
</p>
<h2>OTA Testing Framework</h2>
<h3>Absolute Weapon</h3>
OTA Testing Framework is an established terminology for the technique,
that was first
time used to test the OTA specification. Below is the description of
this
specific case first, followed by some analysis and
discussion of potential
alternatives.
<p>Typically, the OTA Testing Framework consists of the following
components:</p>
<ul>
  <li>OTA test - the test scenario, that includes
standard and custom AMS operations. It operates with applications
associated with this test. It is executed on the server side of the
system,
main communication point responsible for reporting the whole test
status.<br>
    <img alt="AMS test components - high level"
 title="AMS test components"
 src="http://weblogs.java.net/blog/alexeyp/archive/figure_ts.png"></li>
  <li>Test application(s) - zero or more pre-packaged
applications that may contain part of the test code that needs to be
executed on the device. They may communicate with the main test
scenario -
OTA test</li>
</ul>
OTA test is executed in this framework on the test harness side and
uses OTA server to publish applications:<br>
<img alt="OTA test and test applications"
 title="OTA test and test applications"
 src="http://weblogs.java.net/blog/alexeyp/archive/figure_ams.png">
<p>There is also an important component called OTA Server. In
MIDP
case it is HTTP server controlled by OTA
test and responsible for provisioning of test applications. Nice
artistic
picture of the
OTA Testing Framework in provided in the
<a href="https://cqme.dev.java.net/framework.html">ME
Framework</a> Developer's Guide (<a
 href="http://java.sun.com/javame/meframework/docs/meframework_devguide.pdf">link
to PDF version</a>), check Figure 3-7.
</p>
<p>The approach described above is universal and powerful. It can
be used to test the most exotic cases. At least, so far it stays as a
last
absolute weapon used if no other technique works.</p>
<h3>Last Thing to Use</h3>
<p>The only disadvantage of OTA Testing Framework is that it is
terribly interactive. During the certification run TCKs do not allow to
use any automation, every AMS operation must be performed manually.
With a simple install/run/remove cycle, where one needs to read
instructions, enter url, wait for download/launch/execution
complete/remove, it takes 1 minute minimum for a test case.</p>
<p>Now imagine yourself a QA engineer, who has to run
CHAPI TCK,
that contains ~40 OTA tests, as a regression test suite on a regular
basis during the whole development cycle without any automation.</p>
<p>Lets consider a variation to the above
approach, that can be used when it is OK to narrow the scope of covered
possibilities and simplify the usage.</p>
<h2>XletManager</h2>
This is the approach, used initially in PBP &amp; TV TCKs to verify
parts of the specifications, related to an application life cycle. In
PBP
case it was also for testing Ixc - Inter Xlet Communication.
<p>The idea is to specify the Java interface to the AMS that
will allow
one application to perform the life cycle operations on
another application. It was created for PBP/TV, where testing is
based on the Server/Agent model. The scheme works in the following way:</p>
<ul>
  <li>An implementation developer provides an implementation
of XletManager interface, that would allow a test application, executed
on the device to invoke the AMS operations through the Java API. In
the
general case, if Java interface to AMS is not available, the
XletManager implementation may be interactive.</li>
  <li>Test Suite user manually downloads and installs on the
device the Agent application and a set of Xlet applications that will
be
used in tests</li>
  <li>Tests that are executed within the Agent instantiate
XletManager and operate with additional pre-installed test applications.</li>
</ul>
<img alt="XletManager and test applications"
 title="XletManager and test applications"
 src="http://weblogs.java.net/blog/alexeyp/archive/figure_xlet.png">
<p>While in the PBP TCK this approach is used to initiate only
life cycle
operations from the test, executed on the device, it also can be
extended to any AMS operations like install/update/run/remove.</p>
<h3>Comparing with OTA Test Framework<br>
</h3>
<p>Main benefit of XletManager-like approach is that it allows to
use a
single Server/Agent test execution model for the whole test suite.</p>
<p>With this specific approach, there is no dynamic application
installation/removal, no application provisioning component, test
applications are preinstalled before test execution begins.</p>
<p>There may be restrictions, that will complicate the
use of this model or just make it impossible, like:</p>
<ul>
  <li>interactive implementation of XletManager may be
complicated for devices with small screen</li>
  <li>platform may not allow more than one application to run
simultaneously.</li>
</ul>
<h2>Variations</h2>
There are several active components involved into execution
of
the test, there may be several places where to put the main scenario
responsible for execution of AMS operations. It may be server (OTA Test
Framework) or client side (XletManager-like) of the distributed test.
It can be AMS itself - 'autotest' mode, that AMS is supposed to provide
for an automated
execution of test suites on CLDC/MIDP,
is also a scenario of AMS operations, that can be used for test
purpose.
<p>Interface to the AMS may be implemented through plugins, that
may be provided by implementation developers. These plugins may be
interactive in general case or automated. Automated testing may be used
for QA/regression testing or even for certification in some cases.</p>
<p>There are interesting possibilities of using standard Java ME
APIs in order to communicate with AMS, for example CHAPI. As a minimum,
it can
be used to have the test code distributed across multiple MIDlets or
MIDlet-suites that are registered as ContentHandler-s and invoked from
the
main test scenario.</p>
<h2>Summary</h2>
<p>Over time, the number and complexity of Java ME implementation
tests dealing with AMS have increased. I believe this is a natural
consequence of consistent focus on standards in the area of application
management for consumer devices.</p>
<p>The interesting and important problem, that comes together
with number of appearing and evolving AMS-testing frameworks
that are often interactive is automation, it deserves separate
article.</p>
<h2>Merry Christmas and&nbsp;Happy New Year !</h2>
]]>

</content>
</entry>
<entry>
<title>Introduction to Java ME Testing Tools</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/alexeyp/archive/2006/11/testing_java_me_1.html" />
<modified>2007-02-20T18:58:32Z</modified>
<issued>2006-11-27T09:21:56Z</issued>
<id>tag:weblogs.java.net,2006:/blog/alexeyp/369.6028</id>
<created>2006-11-27T09:21:56Z</created>
<summary type="text/plain">Java ME conformance and quality are verified by testsuites that consist from thousands of tests. The article is gives some tips and tricks on how to run large test suite on micro device.</summary>
<author>
<name>alexeyp</name>

<email>Alexey.Popov@Sun.COM</email>
</author>
<dc:subject>Community: Mobile &amp; Embedded</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/alexeyp/">
<![CDATA[This blog is based on and is about&nbsp;my and my colleagues'
experience in Java<sup>TM</sup> ME testing tools and test
suite development.
It is inspired by SUN open-sourcing <a
 href="https://phoneme.dev.java.net/">Java ME software stack</a>&nbsp;and
<a href="https://cqme.dev.java.net/">Java testing tools</a>.
<br>
<h3>Implementation Testing vs. Application Testing</h3>
<p>Java ME developers perform their
application testing
routinely with unit tests written as part of their
development cycle.
<a href="http://sourceforge.net/projects/j2meunit/">J2MEUnit</a>
and <a href="http://sourceforge.net/projects/jmunit/">JMUnit</a>
work well for this: all you need to do is
to package the test framework and all your tests with your application
and
provide an entry point to start test execution. These frameworks run
your tests in a single MIDlet run and display results on the device
screen.
This is all what the most of the application developers need.</p>
<p>Things change when the object of your testing is a Java ME
implementation on a mobile device (that is the entire Java ME software
stack). We will talk below about the specific challenges that
complicate the testing process.
Some of these are specific to Java ME platform, others steam from the
size and complexity of the technology.</p>
<h3>Implementation Testing Tools</h3>
<p>A number of tools were developed over the years to address
the implementation testing needs. Some URLs:</p>
<ul>
  <li><a href="http://www.jcp.org/en/resources/tdk">JCP
TCK tools</a></li>
  <li><a href="https://jtharness.dev.java.net/"> JT
harness</a> (an open source test harness)</li>
  <li><a href="https://cqme.dev.java.net/framework.html">ME
Framework</a> (JT harness-based open source testing framework
for Java ME platform)</li>
  <li><a href="http://java.sun.com/products/javadevice/">Java
Device Test Suite</a> (device quality test suite)</li>
</ul>
<h3>Dealing with Large Test Suites</h3>
<p>The first issue to deal with is the test suite scalability.
Due to the variety and complexity of Java ME technologies,
the number of tests is large. </p>
<p>Let's say we wrote 10000 tests for the CLDC VM specification.
If we tried to execute them in a JUnit-like test framework,
we would quickly find out that</p>
<ul>
  <li> 10000 tests do not fit into a single application, you have
to split them in smaller chunks.</li>
  <li> some tests crash the VM. If we tried to execute all tests
in a single MIDlet.startApp call, we would never see the result of any
test (even those which don't crash). You need to be able to detect VM
exits and catch any unexpected exceptions.</li>
  <li> some tests crash the VM on purpose. These are negative
tests which verify that VM handles certain conditions properly (e.g.
throws VerifyError).</li>
  <li> device runs out of memory because all class files of the
test suite do not fit into it (garbage collector frees unused data from
the memory, but doesn't free classes: these are garbage-collected only
together with their class loader).</li>
  <li> tests running in the same VM interfere with each other
causing failures which are hard to explain or debug. Or tests misbehave
and lock up the VM (this is where you learn that shared resources and
race conditions are a big deal in the testing world).</li>
  <li> you need an accurate report once the test run is complete:
if 100 tests out of 10000 failed, you need detailed information on
every failure and you don't want it displayed on the device screen.
There should be a way to load test results from the device onto your
server or desktop machine. In a perfect world test results for every
test cycle are stored in an easily accessible database.</li>
</ul>
<p>Since tests are typically run on a device with unstable
software
stack, execution of a large test suite there is an additional
challenge. This is equally true for much more capable platforms like
Java SE. One should expect all sorts of things to go wrong:</p>
<ul>
  <li> Implementation bugs causing failures and crashes.</li>
  <li> Resource leaks resulting in memory overflow, unavailable
file handlers and sockets.</li>
  <li> Incomplete implementation lacking networking or user
interface support.</li>
</ul>
<p>There are many other problems to be solved.
For example, how do you automate testing of your Java-enabled Blu-ray
player?</p>
<p>Let's talk about these and other problems on specific examples.</p>
<a name="CDC"></a><h3>CDC and Java SE Testing Solutions</h3>
<p>Java SE platform is where Java technology originated. Not
surprisingly, this is where the testing solutions were initially worked
out.
CDC + Foundation Profile is a platform similar in many ways to Java SE
(but without the myriad of recent extensions and features), the
approach, described below, came from Java SE and works for CDC+FP.</p>
<p>CDC platform is richer compared with CLDC. The most important
benefits we have is reflection APIs and user-defined class loaders.
This makes many testing tasks easier.</p>
<p>The most robust testing set-up proved to be a client-server
model
for the test harness: the main harness application runs in a stable
Java SE environment and a small agent is deployed on the device under
test.
The main harness application manages test suite configuration and
execution,
as well as the test result collection and storage.
The agent connects to the harness application over the network. All the
agent does is repeatedly download and execute tests (a separate class
loader instance is created for each test download) as well
as send test results back to the main application.</p>
<p>This effectively solves most of the problems outlined above:</p>
<ul>
  <li> Small memory requirements. All you need is enough memory
to hold the agent application and the largest test. Test classes are
garbage-collected each time test class loader is garbage-collected, so
you are not limited by the size of a test suite.</li>
  <li> Test interference is minimized. Since tests are loaded
one-by-one, they do not affect each other and their resources are freed
once execution is complete.</li>
  <li> No multiple application downloads during the test cycle.
There is only one small
agent application to download. The rest is handled automatically.</li>
  <li> No test results on device. You are not dependent on file
system, you don't do detective work if the device dies. By the way,
file system independence has the added benefit of nicely handling the
security-constrained environments such as an applet.</li>
</ul>
<p>There are several critical dependencies in this model: you
need a (stable) network, class loader and a few extra security
permissions. These may not be available everywhere by default, but this
is topic for different discussion.</p>
<h3>CLDC and MIDP Testing Solutions</h3>
<p>Things get more difficult on a CLDC/MIDP stack.
There is no class loader to rely on (and no reflection either).
The only universal way to load test code on the device is via
application download. While AMS (Application Management System) does
not support automation
by default, a very simple extension called "autotest" satisfies
most testing needs.</p>
<a name="Autotest"></a><p>The <b>autotest</b> feature is a special AMS mode which iteratively
downloads, installs, runs and removes applications from a specified
URL. Test harness makes new test applications available at this URL
and the AMS picks them up.</p>
<p>10000 tests will be packaged into a number of test
applications.
Each application will include a small execution agent (to report test
result back to the test harness) and the test classes.
In a trivial case we will have 10000 different applications.</p>
<h4>Shortening the Test Cycle</h4>
<p>Test applications are downloaded over the network.
The good news for MIDP is that all devices support HTTP download.
The bad news is that some of these connections are as slow
as 9 kbit/s. It will take 2.5 hours to download 10 MB of test classes.</p>
<p>And there are many other things which will affect the test run
time.
Even though execution agent is small, it is bundled with every
application, wasting a lot of network traffic!
Each test bundle download requires new a network connection; these will
slow down the execution.
Test data and test results are sent back and forth between the harness
and the test application; extra network bandwidth is consumed.
Each test needs time to execute: some tests do extensive computations
and will take a few minutes to run.</p>
Since the system is distributed, one must be minimally taking care of
proper task scheduling. For example, test applications must&nbsp;
already be packaged and signed when request for the next application
comes - if you start packaging task&nbsp;only on getting request
for
the next&nbsp;test application download, it may have surprisingly
sad
effect on execution time.<br>
<p>In the early days of CLDC TCK 1.0 (test suite, used for
certification of implementations of CLDC 1.0 specification) test
execution was taking up to 2
weeks in some environments!
With a few improvements, one can pass CLDC TCK in a few hours:</p>
<ul>
  <li> Pre-install shared agent code on the device (romize
classes of the test agent).</li>
  <li> Package several tests per downloaded application to reduce
the number of network connections and AMS operations. Each device has a
different maximum application size so the total number of applications
will vary.</li>
  <li> Use multiple devices in parallel. Let the harness assemble
and sort test results.</li>
</ul>
<h3>What else?</h3>
Described test execution models have certain restrictions. As example:
using Java ME application to run tests does not allow to test AMS
behaviour, that is primary focus for some Java ME specs. This specific
problem has more then one solution already, as well as there are
solutions that allow to run interactive, distributed tests for Java ME.
<p>Comments are welcome.</p>
]]>

</content>
</entry>

</feed>