Creating Test Data: How to call Python Function from Java
For my testing purposes, I need to create an e-mail before running automated test cases so that it should used it for new registration and a new one for sending invitation to unregistered e-mail and there are some other test cases which use new e-mail for testing. I have create Python function which produce a new e-mail address in this format: firstname.lastname@example.org and next run it will create email@example.com and for every run, it creates a new one just increasing the last used e-mail number. You can use this file for your testing too. Just create numberRun.txt file in you directory.
What you need is that you must install Jython which is Java-Python interpreter from here and then import the PythonInterpreter and just execute test_data.py with
the result should be return as Python object so you need to change it to Java string. Then you can use it.