首页 > 解决方案 > Katalon/Groovy - 使用 newman 运行邮递员请求

问题描述

我正在尝试在我的 katalon 脚本中使用 newman 运行邮递员请求。

import java.util.*
import java.io.*

String path = RunConfiguration.getProjectDir() + '/Data Files'

String proj = '"PostmanCollection.json"'

String file= 'Book1.csv'

String Resquest1= '"Resquest1 Postman"'

String Resquest2= '"Resquest2 Postman"'

String Resquest3= '"Resquest3 Postman"'

println(path)

String cmd = 'cmd cd ' + path

println(cmd)

String createObj = 'cmd /c "newman run ' + proj + ' --folder ' + Resquest1 + ' --folder ' + Resquest2 + ' --folder ' + Resquest3 + ' -d ' + file + ' -n 1 > log.txt"'

println(createObj)

Runtime.getRuntime().exec(createObj, null, new File(path)).waitFor()

它为我生成了一个空文件,但是如果我直接在命令提示符下使用 groovy 在“createObj”中生成的 newman 命令,我可以让它工作并且生成文件就好了。

如果我改用它,该文件也创建得很好。但我需要同时运行另外两个请求。

String createObj = 'cmd /c "newman run ' + proj + ' --folder ' + Resquest1 + ' -d ' + file + ' -n 1 > log.txt"'

你看到那里有问题吗?

标签: groovykatalon-studionewmankatalon

解决方案


推荐阅读