The goal was to create a jar distribution with following properties:
- Standalone executable jar file, i.e. java -jar robotframework.jar mystest.txt would suffice to run tests.
- The exit code of the above command must be the same as if mytests.txt was executed with pybot.
- There would also be a programmatic API to start Robot Framework test execution from any Java program
First requirement is the Jython standalone jar, which can be created with the Jython installer. Following the instructions in the Jython Book, I created three Java classes and one Python for the interaction. These classes implement the one-to-one Jython object factory described in the Jython book. Source code of these classes is available in Robot Framework source repository.
The java classes had to (of course) be compiled before inserting them into the jar file. Additionally, a MANIFEST.MF file with correct main-class had to be created. Once these were done, the files could be inserted into the Jython jar:
- Robot Framework source code must be placed in Lib directory inside the jar
- The java code must be inserted starting from the root of the and according to package structure
- The MANIFEST.MF has be to in META-INF directory
This was resolved by unpacking the Jython jar and replacing the MANIFEST.MF with our own on the file system before repackaging. .
All the Python source files were compiled with Jython's compileall module before they were inserted into the jar file. This presumably increases performance slightly.
I will probably do another post about how we finally got the jar distribution uploaded to Maven central, since that's an interesting story too.
1 comment:
pretty cool! I'll try the standalone version right now.
Looks very useful for others that need to execute your tests in different machines.
Regards,
Rodrigo.
Post a Comment