ANT, Functional Test, Jenkins, JUnit, NetBeans RCP

NetBeans GUI tests on Jenkins + Windows


Running NetBeans application tests on Jenkins CI is quite easy. You just need to call the ‘test’ target in your NetBeans application’s build script (e.g. ANT build.xml) and Jenkins will do the rest. I initially setup Jenkins as a windows service to run my tests. This works fine for unit tests since they do not require a display to execute.

But recently I faced some issues when I wanted to run some functional (GUI) tests of a NetBeans platform app using a Jenkins job running on Windows. Since the Jenkins process could not access the windows display all the GUI tests were failing. On a linux box this issue is addressed by using X display such Xvnc (available as a Jenkins plugin), but of course I cannot use X display on windows!

After googling around I came across a possible solution which was to enable the option “Allow service to interact with desktop” for my Jenkins service. But as promising as it seemed it did not work, my GUI tests continued to fail 😦

Then I decided to stop and disable the Jenkins windows service and just ran it from the windows command prompt using the refreshingly simple command “java -jar jenkins.war”. Voila!!! It worked all my GUI tests were running without any problem and I can even see the GUIs opening and closing automagically on my windows desktop.

This solution was confirmed when I later stumbled upon the wiki here, which shows how to run GUI tests on ‘Hudson’ (Jenkins’ original name before Oracle knocked its head on a rock!) using a Tomcat container running on Windows. Although I didn’t use a servlet container such as Tomcat the solution applies to my situation as well.

So there you are, if you want to run GUI tests on Jenkins CI running on Windows do not configure it as a windows service instead run it from the command prompt or set it up as a scheduled task to run on windows logon using the command “java -jar jenkins.war”.

Advertisements

16 thoughts on “NetBeans GUI tests on Jenkins + Windows

    1. And there’s is where we started from:
      – Install and run vnc server on Windows headless VM
      – Connect to this VM with VNC viewer, before running GUI tests. (I’m connecting from the same machine.)
      – * Go and fix xvnc plugin to work with Windows… [optional]
      I used TightVNC. It has nice features, like java-applet, but tends to crash sometimes for me.

  1. Hi,

    I also facing the same problem. My UI Automation test script were failing when executed from jenkins. Can you please tell me how to confgure Jenkins CI job as scheduled task.

    Urgently waiting for your reply.
    Thanks,
    Madhav

  2. This saved me a lot work!!! Thanks for this! I also had problem with launching Jenkins using the command proposed by you (there was an exception) but I have found out such command : “java -jar jenkins.war –ajp13Port=-1 –httpPort=8082” and it worked like a charm

  3. It works in command line. However, I am facing another problem. When jenkins runs in the command line, I left it running over night, when I came back it just stops. Anybody seeing the same problem as me?

    1. You might want to check the error stack in the console, there could be many reasons for Jenkins to stop one most likely cause could be an OutOfMemory error.

      1. Thank you for your reply. I am having hard time to find the log file that Jenkins generated. The output of the commnad line is show below, I don’t see any error message:
        C:\jenkinTest>java -jar jenkins.war –logfile=C:\jenkinTest\log\test.log
        May 21, 2013 11:36:11 AM winstone.Logger logInternal
        INFO: Beginning extraction from war file
        May 21, 2013 11:36:13 AM winstone.Logger logInternal
        INFO: HTTP Listener started: port=8080
        May 21, 2013 11:36:13 AM winstone.Logger logInternal
        INFO: Winstone Servlet Engine v0.9.10 running: controlPort=disabled
        May 21, 2013 11:36:13 AM jenkins.InitReactorRunner$1 onAttained
        INFO: Started initialization
        May 21, 2013 11:36:14 AM jenkins.InitReactorRunner$1 onAttained
        INFO: Listed all plugins
        May 21, 2013 11:36:14 AM jenkins.InitReactorRunner$1 onAttained
        INFO: Prepared all plugins
        May 21, 2013 11:36:14 AM jenkins.InitReactorRunner$1 onAttained
        INFO: Started all plugins
        May 21, 2013 11:36:14 AM jenkins.InitReactorRunner$1 onAttained
        INFO: Augmented all extensions
        May 21, 2013 11:36:23 AM jenkins.InitReactorRunner$1 onAttained
        INFO: Loaded all jobs
        May 21, 2013 11:36:24 AM org.jenkinsci.main.modules.sshd.SSHD start
        INFO: Started SSHD at port 65227
        May 21, 2013 11:36:24 AM jenkins.InitReactorRunner$1 onAttained
        INFO: Completed initialization
        May 21, 2013 11:36:25 AM hudson.TcpSlaveAgentListener
        INFO: JNLP slave agent listener started on TCP port 65228
        May 21, 2013 11:36:25 AM hudson.WebAppMain$2 run
        INFO: Jenkins is fully up and running
        May 21, 2013 5:26:04 PM hudson.model.AsyncPeriodicWork$1 run
        INFO: Started Fingerprint cleanup
        May 21, 2013 5:26:04 PM hudson.model.FingerprintCleanupThread execute
        INFO: Cleaned up 0 records
        May 21, 2013 5:26:04 PM hudson.model.AsyncPeriodicWork$1 run
        INFO: Finished Fingerprint cleanup. 3 ms
        May 21, 2013 8:07:31 PM hudson.model.AsyncPeriodicWork$1 run
        INFO: Started Workspace clean-up
        May 21, 2013 8:07:31 PM hudson.model.AsyncPeriodicWork$1 run
        INFO: Finished Workspace clean-up. 7 ms

        That’s the last output, then it stopped when I check back on May 22 in the morning. So I am sure exactly at what time it stopped. This problem has been bug me for a long time. Really appreciate any help. :))

      2. When checking the next morning is the command window that you used to run Jenkins still open? If its not open could it be possible that your machine is restarting during the night?

      3. The command line window is still open. It quits jenkins and prompted me for new command.

        C:\jenkinTest>

        I try the running Jenkins on different computers but all windows 7. Same problem with all of them. any ideas? I files a bug in jenkins jira site. But I don’t know how long will it take for them to resolve this. The problem is I cannot run Jenkins anywhere else, it has to be ran in command line in order execute GUI functional test cases I created.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s