Testing JNI-ridden Java code using JUnit!

Testing JNI-ridden Java code using JUnit!

Post by A » Wed, 28 Aug 2002 02:15:20

The Problem:

  We have used JNI to give Java developers a chance to use our C++
messaging system.  However, these JNI methods are not available to us
at test-time, since we load our shared libraries dynamically.  When we
write JUnit tests, or even try to run the software outside of the
system, we get UnsatisfiedLinkErrors, because the JNI methods cannot
be found because they exist in shared libraries that have not been

Is there any tricks, short of overhauling the system, to get around
Perhaps maybe even a pre-processor directive like #define or #pragma
in C++?


AJ Mieskolainen


1. Code generation of JUnit test cases


I'd like to know the experiences of people with regard to automatic(?)
code generation of JUnit test cases. I'm refering to projects which do
not work the XP way, but still would like to have high % of unit
testing (meaning, unit test code is done towards the end of coding),
and to projects that need to deal with legacy code.

(a) What has been your experience with tools which auto-generate test
cases that give a good % of code coverage when tested with code
coverage tools, such as Clover?

I've worked with
- open source options mentioned in
http://www.junit.org/news/extension/testcase_generation/index.htm, but
these only generate the skeleton of the methods

- JTest, which generates pre-determined values for primitives, and
does nothing about Java value object classes, and expects the
programmer to add in the "other" test cases - which in effect turns
out to be a lot.

I guess what I'm looking for is a tool that "understands" the code and
generates unit test cases for all the branches and conditions in the
code, in order to achieve maximum code coverage. Is there any such
beast out there? :)

(a1) Has anyone worked with TogetherJ/XPTest
(http://www.extreme-java.de) for generating JUnit test cases? I didnt
see too much of high-lighting on the TogetherSoft site on this one...
What have been your experiences?

(a2) On a related note, does anyone know of XMI-compatible JUnit
generators, which would remove the dependency on the UML tool?

(b) What has been your experience with mock objects? Have they been
too cumbersome a process for the average project size (say, 100
classes, with 10 value object classes)?

(c) Building functional test cases: I've heard of JFunc; what are the
other options, and how do they compare?

Thank you very much,

2. Minor Shutdown Problem

3. testing main method using junit

4. LINK386: SEGMENTS statement and PUBLIC vs. PRIVATE segments

5. Testing private members using Junit

6. Where should security exist?

7. Unit tests for JUnit (Was: Unit tests for GUI programming?)

8. NextSiation question.

9. Java/JNI and Microsoft COM Memory Corruption

10. Java JNI Graphics

11. TAPI event handling to JAVA native interface (JNI) not working

12. Windows audio/java JNI -- contract help needed