Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Developer
sadanala
Posts: 59
Registered: 03-10-2009

How to do unit testing my Blackberry Application

Hi, Can you please tell me how to do unit testing my Blackberry application, is there any specific tool?
Please use plain text.
Developer
simon_hain
Posts: 10,780
Registered: 07-29-2008
My Carrier: O2 Germany

Re: How to do unit testing my Blackberry Application

there is http://j2meunit.sourceforge.net/, i have never tested it though.
personally i use standard junit on classes that do not contain j2me/blackberry specific code, like webservice processing etc.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

peter_strange wrote:
"This process should happen traumatically for you in both JDE and Eclipse."
Please use plain text.
Developer
dpreussler
Posts: 212
Registered: 07-18-2008

Re: How to do unit testing my Blackberry Application

I'm also using normal junit tests and try to split my BlackBerry code from pure java code.

 

There a lot of simulator based frameworks around. An alternative to j2meunit would be B-Unit: http://sourceforge.net/projects/b-unittesting/ which is based on RIM CLDC application.

If your problem was solved, please mark answer as "Accepted solution"
If your want to thank, click the "kudo" symbol
___________
visit me: http://mobilejavadevelopment.blogspot.com/
visit the Berlin BlackBerry Developer Group: http://berlinblackberrydevelopers.blogspot.com/
Please use plain text.
New Developer
sadanala
Posts: 59
Registered: 03-10-2009

Re: How to do unit testing my Blackberry Application

Hi,

 

Thank you very much for quick reply.

 

Can you please tell me how to work with bunit?

Please use plain text.
Developer
dpreussler
Posts: 212
Registered: 07-18-2008

Re: How to do unit testing my Blackberry Application

There was a session at last years BlackBerry developer conference about it.

 

 

Here are some of the points from the slide about bunit:

 

  • Extend from “jmunit.framework.cldc11.TestCase”
  • Return number of tests in constructor to parent
  • Build a method  to call your tests


example:


public void test(int testNumber) throws Throwable
{
      switch (testNumber)
      {
        case 0:
          testDoSomethingThatShouldBeTested();
          break;
      }
}

 

 

Just use normal assert methods in your tests: 

see link

 

assertEquals("feetToMeters", 7.62F, result);

 

This is calling ‘assertEquals’ in our unit-test library, we pass the name of the test, the correct expected answer and the result of the function we’re testing.

 

 


 


 

 

 

If your problem was solved, please mark answer as "Accepted solution"
If your want to thank, click the "kudo" symbol
___________
visit me: http://mobilejavadevelopment.blogspot.com/
visit the Berlin BlackBerry Developer Group: http://berlinblackberrydevelopers.blogspot.com/
Please use plain text.
Developer
simon_hain
Posts: 10,780
Registered: 07-29-2008
My Carrier: O2 Germany

Re: How to do unit testing my Blackberry Application

the b-unittesting seems an interesting project, but not very active. 139 days ago the last activity, looks a bit suspect.
on our last test we were not very successful in using it.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

peter_strange wrote:
"This process should happen traumatically for you in both JDE and Eclipse."
Please use plain text.
Developer
bneeman
Posts: 132
Registered: 02-11-2009

Re: How to do unit testing my Blackberry Application

[ Edited ]

+1 to using regular junit and separating as much code as possible into a pure java module.

 

 BlackBerry platform lacks reflection. Leaving the responsibility for enlisting tests to the developer. This is a lot of over-head and can lead to a stituation where tests don't get executed on "run all".

 

Compared to a desktop computer, the BlackBerry platform is slow. In XML parsing, the simulator can be 2 times or even 3 times faster than a Bold device. However, this is still slow compared to a desktop computer which is over 10 times faster than a Bold device in XML parsing.

 

On the desktop it's possible to write test harnesses using latest JAVA language syntax, and a much bigger API.

 

As an added bonus -which may or may not be important in a specific project- the pure java code is portable to other phones, webapp, desktop app, etc.

 

Cheers, Barak.

 

 

Message Edited by bneeman on 07-21-2009 12:54 PM
Please use plain text.
New Developer
sadanala
Posts: 59
Registered: 03-10-2009

Re: How to do unit testing my Blackberry Application

 

I want to test blackberry application and its completely RIM specific api.

Please use plain text.
New Developer
sadanala
Posts: 59
Registered: 03-10-2009

Re: How to do unit testing my Blackberry Application

 

Hi,

 

If not bunit means is there any other tool which i can do unit testing my blackberry application(Using RIM API)?

 

Please update me soon, as it is very urgent. 

Please use plain text.
Developer
dpreussler
Posts: 212
Registered: 07-18-2008

Re: How to do unit testing my Blackberry Application

We used BUnit for specific test and had no problems.

That the project is not active isn't much a problem, it was build on a different unit-testing framework (jmunit) which still exists.

 

Give it a try.

If your problem was solved, please mark answer as "Accepted solution"
If your want to thank, click the "kudo" symbol
___________
visit me: http://mobilejavadevelopment.blogspot.com/
visit the Berlin BlackBerry Developer Group: http://berlinblackberrydevelopers.blogspot.com/
Please use plain text.