j2me unit testing
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Don_Quixote
Posted On:   Tuesday, February 26, 2002 04:18 PM

Please help-- I cannot do unit testing with j2me, together with Ant and Junit. It didn't work at all with Junit; I couldn't even compile the tests. So I downloaded J2ME Unit from a link on the Junit website and now I can compile, but I receive an error when I try to test. Here's my output when I run the build file: J2MEUNIT: compile: [javac] Compiling 1 source file to E:projectsHelloWorld uild mpclasses preverify: [preverify] Preverifying classes to E:projectsHelloWorld uildclasses jar: [jar] Warning: com anksixHelloWorld.class modified in the future. [jar] Building jar: E:projectsHelloWorld uildlibHelloWorldProject.jar compiletests   More>>

Please help-- I cannot do unit testing with j2me, together with Ant and Junit. It didn't work at all with Junit; I couldn't even compile the tests. So I downloaded J2ME Unit from a link on the Junit website and now I can compile, but I receive an error when I try to test.



Here's my output when I run the build file:


			
J2MEUNIT:

compile:
[javac] Compiling 1 source file to E:projectsHelloWorld uild mpclasses

preverify:
[preverify] Preverifying classes to E:projectsHelloWorld uildclasses

jar:
[jar] Warning: com
anksixHelloWorld.class modified in the future.
[jar] Building jar: E:projectsHelloWorld uildlibHelloWorldProject.jar

compiletests:
[javac] Compiling 1 source file to E:projectsHelloWorld uild estcases

runtests:
[j2meunit] TestRunner.main()
[j2meunit] .E
[j2meunit] Time: 50ms
[j2meunit]
[j2meunit] FAILURES!!!
[j2meunit] Test Results:
[j2meunit] Run: 1 Failures: 0 Errors: 1
[j2meunit] There was 1 error:
[j2meunit] 1) testNotNull(test.com.ranksix.HelloWorldTest)
[j2meunit] javax/microedition/midlet/MIDlet
[j2meunit]

BUILD FAILED


My code is appended at the end of this message.



I suspect this problem is occurring since Ant is running Java.exe and Java.exe is not equipped with the KVM. I tried using the KToolbar program buy that didn't seem to work either-- and I want to be able to run an _automated_ build and testing process so running J2ME Unit on an emulator is undesirable.



My %classpath% is hardcoded at c:j2meunit and the rest of the classpath stuff is set in the Ant build file.



I'm using the Stampysoft Ant Tasks for the preverification process. That involves putting the StampysoftAntTask.jar in the %Ant_home%lib directory.



My OS is Windows 2000.



Thanks in advance for your help.





dq


Here's my code:


Build.xml:

			
<?xml version="1.0"?>











${j2mewtk.home}WTKLIBKVEM.jar" />



























basedir="${build.dir}" includes="com/**"/>
















taskname="j2meunit" failonerror="true" >




















HelloWorld.java:

			
//:HelloWorld.java

package com.ranksix;

/** This class simply outputs the string: "Hello World!".
*
*/
import javax.microedition.midlet.MIDlet;

public class HelloWorld extends MIDlet
{

public HelloWorld()
{
String aString = "Hello World!";
}

public void startApp()
{
}

public void pauseApp()
{
}

public void destroyApp(boolean unconditional)
{
}
}

// End of HelloWorld.java


HelloWorldTest.java:

			
//:HelloWorldTest.java

package test.com.ranksix;

/** Test cases for the HelloWorld Midlet
*
*/
import com.ranksix.HelloWorld;
import j2meunit.framework.TestCase;
import j2meunit.framework.AssertionFailedError;
import j2meunit.framework.TestSuite;
import j2meunit.framework.Test;
import j2meunit.framework.TestResult;

public class HelloWorldTest extends TestCase
{
private HelloWorld hiWorld;

public void setUp()
{
hiWorld = new HelloWorld();
}

public void tearDown()
{
hiWorld = null;
}

protected void runTest() throws java.lang.Throwable {
if(getTestMethodName().equals("testNotNull"))
{
testNotNull();
}
}

public HelloWorldTest() // default constructor
{
super("null");
}

public HelloWorldTest(String name)
{
super(name);
}

public static void main(String[] args)
{
String[] runnerArgs = new String[] {"HelloWorldTest"};
j2meunit.textui.TestRunner.main(runnerArgs);
}


public Test suite()
{
return new TestSuite(new HelloWorldTest().getClass(),new String[] {"testNotNull"});
}

public void testNotNull()
{
assertNotNull(hiWorld);
}
}
// End of HelloWorldTest.java
   <<Less
About | Sitemap | Contact