Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

testing a java application that is started via a batch file

 
Jordan Thompson
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a GUI application that has quite a few junit tests that unit test components (both GUI as well as business) of this app.
The app is delivered as several jars and launched with a batch file (also part of the delivery.) Our jars, configuration files, 3rd party jars, etc are all delivered in a single zip file. We have had issues in the past where the delivered jar or zip file becomes broken and we don't discover this until weeks after the error occurred (most of the developers run the application from the IDE until we approach FAT time.)
In an attempt to reduce this problem, I have written another junit test that extracts the contents of the zip file and starts the application via the batch file. Unfortunately, this requires someone to observe that the app is running correctly and click the file->exit button to end this test (and allow junit to continue with the other tests in the suite.

Is there anyway that junit can access any of the class hierarchy of this application that was started by a separate batch file but is running in the jvm? This would allow the junit to look at the real-time log (that is only recorded in the log window of the app) to ensure it is started correctly and it would allow the junit to access the exit button to also shut down the application.

Thanks for any help anyone may be able to provide.

Jordan
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that's going to work using Junit.
You could just implement a flag in your application main class that starts a headless version for testing purposes. This flag would indicate to run the bootstrapping logic followed by application's shutdown routine if everything checks out. The exit code returned, either implicitly or explicitly, will indicate if all went according to plan or something went horribly wrong. That way you could use Ant to test the deployment of your application distributable generated by the buildsystem, after succesful completion of unit testing and packaging. Simply use Ant to unzip the distributable and the <exec> task with failonerror set to call the batch file and provide a flag it forwards to the java.exe invocation of the main class, which start the headless version of the application.
 
Jordan Thompson
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jelle Klap wrote:
This flag would indicate to run the bootstrapping logic followed by application's shutdown routine if everything checks out. The exit code returned, either implicitly or explicitly, will indicate if all went according to plan or something went horribly wrong.


Works for me! great idea. Thanks very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic