0

I am very new to j2objc and have a question about translating junit test classes.

I have a class (Foo.java) and a corresponding test class (FooTest.java). I am following steps from this link to translate the test class written in java. https://developers.google.com/j2objc/guides/translating-junit-tests

But how do I add a dependency on the actual class while translating. For all the usages of the actual class within the test class, it throws cannot find symbol error in the translation step. Thanks!

Example -

${J2OBJC_HOME}/j2objc -classpath ${J2OBJC_HOME}/lib/j2objc_junit.jar FooTest.java
FooTest.java:39: error: cannot find symbol
        Foo.setXYZ();
        ^
learner
  • 139
  • 1
  • 13
  • Please [edit] your question to include the full source code of your `FooTest.java` and `Foo.java` files. Also add where you have placed these files in your directory structure. – Progman May 16 '20 at 08:22

1 Answers1

0

The general answer to these sorts of questions is to first create a javac command that builds, then use the same arguments with j2objc. That's because j2objc uses javac as its front end, and passes the common arguments to it. (The "cannot find symbol" string is in javac's source, not j2objc's.)

The likely solution (since you didn't include source) is to define the classpath as .:${J2OBJC_HOME}/lib/j2objc_junit.jar. That's because javac has a default classpath of ".", but if you use a -classpath flag, it will only use those specified paths. Since paths are separated by ':', this string adds the default "." back.

tball
  • 1,984
  • 11
  • 21