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: and next run it will create 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.

For my recent project, I need to write my automated test cases in Java so I have learnt some Java but not as professional. For this project again I need to create new unregistered e-mail address for using almost the same scenarios. Therefore I needed to call Python function in my Java code, instead of writing it in Java. The following code is used for calling:

What you need is that you must install Jython which is Java-Python interpreter from here and then import the PythonInterpreter and just execute with 
the result should be return as Python object so you need to change it to Java string. Then you can use it. 


Popular posts from this blog

Testing WEB Sevices and Automating SOAP Services

Performance Testing on CI: Locust is running on Jenkins

Change Default Timeout and Wait Time of Capybara

Performance Testing on CI: Integration of Locust and Jenkins

Create an Alias for Interactive Console Work: Selenium and Capybara