1

I have written a test case that injects and fetches data into and from the system via APIs. So far the journey is good.

In today's date, my test case is acting as a client where it depends on a server.

Can we make our test case listen for user inputs, so that I will write a web client where the user will initiate the data and our Katalon test case should listen for the inputs from UI/client? And based on the user parameters our test case will be triggered.

So my question here is can we write Groovy server code inside our Katalon test case and let it act as an HTTP server listening on a port, where any client can put the request and wait for the test results.

This way we can let our Katalon test running on a reserved machine which will act as a server and we can simply supply client web app to intended users, which will be used for preparing the test data and submit onto the server. Wait for the test results.

Can someone please suggest to me how to make this possible?

Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
Sunil Yerra
  • 53
  • 1
  • 7
  • 1
    It's possible to do anything in groovy. But better to take for example Jenkins that already has ui, able to prompt parameters, run tests, display results. – daggett Oct 04 '20 at 02:47
  • Keeping that in mind, i have wrote a small server code which should simply listen on 8080 port. My intention was if it really listens on that port then slowly enhance the code to accept requests from clients and based on the inputs from client my server should call appropriate test case. But unfortunately below code is not listening, it simply exits after printing the logs on console. Below is the code I have wrote in side the test case – Sunil Yerra Oct 04 '20 at 17:32
  • @Grab(group='org.eclipse.jetty.aggregate', module='jetty-all', version='7.6.15.v20140411') def startJetty() { def server = new Server(8080) def handler = new ServletContextHandler(ServletContextHandler.SESSIONS) handler.contextPath = '/' handler.resourceBase = '.' handler.welcomeFiles = ['index.html'] handler.addServlet(GroovyServlet, '/scripts/*') def filesHolder = handler.addServlet(DefaultServlet, '/') filesHolder.setInitParameter('resourceBase', './public') server.handler = handler server.start() } println "Starting Jetty, press Ctrl+C to stop." startJetty() – Sunil Yerra Oct 04 '20 at 17:35
  • I have removed the import statements in above code, i have got that sample code @https://gist.github.com/renatoathaydes/8ad276cedd515f8ff5fc – Sunil Yerra Oct 04 '20 at 17:36
  • 1
    use `server.join()` after `server.start()`. this will hold current thread until server shutdown. – daggett Oct 04 '20 at 20:28
  • Sorry for delay in response, yes server.join() worked for me. – Sunil Yerra Mar 07 '21 at 06:13

0 Answers0