jUnit test with leJOS

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: roger, 99jonathan, imaqine

jUnit test with leJOS

Postby sojkic » Wed Jul 18, 2012 12:38 pm

Hello,
please help me. I have leJOS NXT project in Eclipse and I want create jUnit test. When you start the project I get the error "Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/ClassLoader" Do you know what to do?

Thank you for you help.
sojkic
New User
 
Posts: 10
Joined: Fri Apr 06, 2012 5:32 pm

Re: jUnit test with leJOS

Postby skoehler » Wed Jul 18, 2012 12:49 pm

JUnit doesn't run on the NXT for obvious reasons: on the NXT, only a subset of the JDK API is implemented. And JUnit has been designed to run with a full fledged JDK.
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: jUnit test with leJOS

Postby sojkic » Wed Jul 18, 2012 1:08 pm

Can I create a test in another way or test for the NXT project is not?
sojkic
New User
 
Posts: 10
Joined: Fri Apr 06, 2012 5:32 pm

Re: jUnit test with leJOS

Postby skoehler » Wed Jul 18, 2012 1:11 pm

sojkic wrote:Can I create a test in another way or test for the NXT project is not?

Well, the services JUnit provides are merely: invoking setup/test*/teardown methods, collecting the test results.
You'll have to write that yourself.
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: jUnit test with leJOS

Postby sojkic » Wed Jul 18, 2012 1:21 pm

Do you think that must I create new class for example in package test and write test without use jUnit? How I get the result. I´m sorry I am beginner.
sojkic
New User
 
Posts: 10
Joined: Fri Apr 06, 2012 5:32 pm

Re: jUnit test with leJOS

Postby titiwu » Thu Aug 30, 2012 6:57 pm

I did write some tests with jUnit for my project.
However this will only work for the parts/classes of your program that don't use NXT specific library features (that use only features that are available in the standard java library)
Here how I did it:
- Create another (standard, not NXT!) Java-project in your workspace (I'm asuming you use eclipse ...)
- Create the tests for your classes in this project!
Remember: as soon as you use any nxt.* classes in the tested classes, it will fail!

Hope that is of some use!
User avatar
titiwu
New User
 
Posts: 3
Joined: Tue May 29, 2012 6:49 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 3 guests

more stuff