Running a Junit test remotely, as if it were running locally, using Eclipse

10,204

The easiest would be to invoke command line JUnit runner on remote mashine using the following command:

java -Xdebug -Xrunjdwp:transport=dt_socket,address=8998,server=y,suspend=y -cp ... org.junit.runner.JUnitCore <test class name>

So, it will wait til you attach remote debugger from Eclipse at port 8998.

You can also use Eclipse's Target Management tools to transfer files to remote system and launch remote commands. There is several tutorials on the project page.

Share:
10,204
Yon
Author by

Yon

Updated on August 21, 2022

Comments

  • Yon
    Yon over 1 year

    I've search around, read relevant questions on this site and others, but have failed to find a solution. It strikes me odd that one does not exist so let me detail my question here:

    I use Junit4 + Eclipse regularly to test my code. In some cases, certain tests can take a lot of CPU and/or memory, rendering my workstation unusable for the duration of the test. This is a pain I'm trying to solve.

    I'm looking to get the exact same behavior but through a remote server. I want:

    1. To still be able to set breakpoints and debug my app.
    2. To see how the tests progress using the Junit view in Eclipse.
    3. Click on a button have the tests started (build process and copying of files is allowed, but only if efficient).

    In my mind I envision something that rsyncs the files to the remote server, starts the java process there with the exact same arguments as it would on my local machine, makes the debug port available (not just localhost) and has eclipse hook up to it to have both debug and junit view working.

    How can I get this done?

    Several leading questions that may help us find a solution:

    1. How does Eclipse communicate with the java process when run locally (for both debug purposes AND the Junit view)?
    2. How can I involve myself in the process of spawning the java process for the JUnit testing so I can copy the required files over to a remote server?
    3. How can I make the process spawn remotely instead of locally?
    4. How can I have Eclipse hook up to the remote host instead of the localhost?