我想在Gradle脚本中运行多个SOAPUI项目xmls [英] I want to run multiple SOAPUI project xmls in Gradle script

查看:139
本文介绍了我想在Gradle脚本中运行多个SOAPUI项目xmls的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Gradle脚本中运行多个soapui项目。 SOAPUI项目文件保存在以下位置:
d:/soapui/projects/path/a.xml,b.xml等

将有任何Gradle脚本,它将进入上述位置并使用testrunner.bat逐个执行每个项目

由于@RaGe您可以使用 gradle SOAPUI插件 。但是,如果您正在寻找更自定义的方式,您可以按照以下步骤操作。



您可以在 Gradle 上生成任务以执行 testrunner 运行您的 SOAPUI 项目。然后,您可以为目录路径中的每个项目动态创建一个任务,并使用 .depends ,您可以调用所有这些动态生成的任务
$ b 您的 build.gradle 可能类似于:

  //执行testrunner的任务$ b $ class SoapUITask extends Exec {
String soapUIExecutable ='/SOAPUI_HOME/bin/testrunner.bat'
String soapUIArgs =''

public SoapUITask(){
super()
this.setExecutable(soapUIExecutable)
}

public void setSoapUIArgs(String soapUIArgs){
this.args =$ soapUIArgs.trim()。split()as List
}
}

/ /空任务,取决于执行
// ohter任务
任务executeSOAPUI(){
}

//获取项目的路径
def projectsDir = new File(project.prop erties ['soapuiProjectsPath'])

//为每个项目文件动态创建任务
projectsDir.eachFile {file - >
if(file.name.contains('。xml')){
//创建任务
任务executeSOAPUI $ {file.name}(类型:SoapUITask){
printlnexecute project $ {file.name}
soapUIArgs =''+ file.getAbsolutePath()+''
}

// make the depends以避免逐一调用每个任务
executeSOAPUI.dependsOnexecuteSOAPUI $ {file.name}
}
}

要调用它,可以使用下面的命令:/ b>

gradle executeSOAPUI -PsoapuiProjectsPath = d:/ soapui / projects / path /



注意 -P 是用于为项目目录传递参数。



最近,我写了一个关于如何编写 gradle task 来运行 SOAPUI ,如果您想要查看更多详细信息,也可以使用。



希望这会有所帮助,


I want to run multiple soapui projects in Gradle script. The SOAPUI project files are kept is following location: d:/soapui/projects/path/a.xml, b.xml etc

Will be there any Gradle script that it will enter into the above mentioned location and execute the each project one by one using testrunner.bat

解决方案

As @RaGe comments you can use the gradle SOAPUI plugin. However if you're looking for a more custom way you can proceed as follows.

You can generate a task on Gradle to execute testrunner to run your SOAPUI projects. Then you can create dynamically one task for each project you've in a directory path, and using .depends you can make that all these dynamic generated tasks are called when you call the specific task.

Your build.gradle could be something like:

// task to execute testrunner
class SoapUITask extends Exec {
    String soapUIExecutable = '/SOAPUI_HOME/bin/testrunner.bat' 
    String soapUIArgs = ''

    public SoapUITask(){
        super()
        this.setExecutable(soapUIExecutable)
    }

    public void setSoapUIArgs(String soapUIArgs) {
        this.args = "$soapUIArgs".trim().split(" ") as List
    }
}

// empty task wich has depends to execute the
// ohter tasks
task executeSOAPUI(){
}   

// get the path where are your projects
def projectsDir = new File(project.properties['soapuiProjectsPath'])

// create tasks dynamically for each project file
projectsDir.eachFile{ file ->
    if(file.name.contains('.xml')){
        // create the tasks
        task "executeSOAPUI${file.name}"(type: SoapUITask){
            println "execute project ${file.name}"
            soapUIArgs = ' "' +  file.getAbsolutePath() +'"'
        }

        // make the depends to avoid invoke each task one by one
        executeSOAPUI.dependsOn "executeSOAPUI${file.name}"
    }   
}

To invoke this you can do it using the follow command:

gradle executeSOAPUI -PsoapuiProjectsPath=d:/soapui/projects/path/

Note that -P is used to pass the parameter for projects dir.

Recently I wrote an answer on how to write gradle task to run SOAPUI which can be also util, if you want check more details here.

Hope this helps,

这篇关于我想在Gradle脚本中运行多个SOAPUI项目xmls的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆