Skip to content
abego edited this page Jun 28, 2017 · 5 revisions

Run Java2Script Unit Tests

Use j2slib with "junit"

To run Java2Script unit tests you must use a j2slib that contains "junit".

To build a j2slib with "junit" follow the description given in 'Building j2slib (The Runtime Library)' but when starting the Ant build make sure to set the Ant property j2s.lib.include.junit to true.

I.e. when starting Ant from the command line (in the 'net.sf.j2s.lib' directory)

  • run ant -Dj2s.lib.include.junit=true -f build/build.xml

When starting Ant from within Eclipse:

  • Right-click "build/build.xml" and select "Run As > Ant Build..."
  • (An 'Edit Configuration' dialog appears.)
  • In the 'Main' tab find the 'Arguments:' field and enter:
    • -Dj2s.lib.include.junit=true
  • Click 'Run'

(Make sure the just build j2slib is used when running Java2Script code. See 'Building j2slib (The Runtime Library)' for details.)

Run Tests

  • Right-click the (JUnit) test class
  • Select "Run as > Java2Script Unit Test"

While running the test output is written to the 'J2S Console' in Eclipse.

Click the button 'Run in External Browser' in the 'J2S Console' to re-run the test in an external browser. Especially when debugging JavaScript code using an external browser (and its 'Developer Tools') is the preferred way to go.

But also for "normal" test runs use the external browser because the output to the 'J2S console' is not always updated (see Issue #17).