简体   繁体   English

如何设置我的 groovy 类,以便我可以在其他 groovy 脚本中使用它的实例

[英]How to set up my groovy class so I can use it's instance in other groovy scripts

I am automation tester fighting this issue: on this project we are running automated tests from SoapUI tool, or via maven... so basically git testing repository includes just Soap's source XML, pom, some data and a bunch of support .groovy scripts(!!! these are not classes, they are just scripts doing some tasks, they are called from SoapUI tool to perform some action!!!).我是自动化测试人员解决这个问题:在这个项目中,我们正在从 SoapUI 工具或通过 maven 运行自动化测试......所以基本上 git 测试存储库只包括 Soap 的源 XML、pom、一些数据和一堆支持 .groovy 脚本( !!! 这些不是类,它们只是执行某些任务的脚本,它们是从 SoapUI 工具调用以执行某些操作!!!)。 In the scripts there are multiple code repetitions, and I would like to clean them = create standalone classes with methods to substitute and simplify unnecessary code.在脚本中有多个代码重复,我想清理它们=创建带有方法的独立类来替换和简化不必要的代码。

  1. For POC I've created few classes, compiled them with groovyc (I defined 'folderN' as a package - see the structure below), but I cannot import them from scripts - also I cannot edit them - they seem to be read only, but I want to modify them from time to time...(I am a newbie when it comes to the class compilation, creating packages etc.)对于 POC,我创建了几个类,用 groovyc 编译它们(我将 'folderN' 定义为一个包 - 请参阅下面的结构),但我无法从脚本中导入它们 - 我也无法编辑它们 - 它们似乎是只读的,但我想不时修改它们......(我是一个新手,在类编译、创建包等方面)

2.Repo structure: 2.回购结构:

-repo:
      -sourceSoapFile.xml
      -pom.xml
      -folderN-fewClasses.groovy
      -folderM-folder1-fewScripts.groovy
              |
              -folder2-fewScripts.groovy
              |
              ...
         
  1. What is my target: to be able to create instance of classes in scripts, the way that anyone downloading my repository can run scripts with class's instances without any further actions needed.我的目标是:能够在脚本中创建类的实例,任何下载我的存储库的人都可以使用类的实例运行脚本,而无需任何进一步的操作。

What am I doing wrong please?请问我做错了什么? Thank you谢谢

我没有将我的 FolderN 标记为源文件,因为它是 Maven 项目......现在工作正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Groovy为我的班级设置.each行为 - Groovy set .each behavior for my class Groovy / Grails - 如何从String获取类实例? - Groovy / Grails - How to get class instance from String? 为什么我不能从另一个 Groovy 类实例化一个 Groovy 类? - Why can't I instantiate a Groovy class from another Groovy class? 如何使用src / groovy类? - How to use src/groovy classes? 如何创建一个可共享的类,以便其他人可以在他们的网站上使用 - How to create a sharable class so other can use for their websites 如何将groovy脚本中定义的类导入另一个groovy - How to import a class defined in groovy script into another groovy Unity C#-如何做到这一点,以便可以通过一个类访问所有其他类,变量和方法? - Unity c# - How can I make it so that I can access all my other classes, variables and methods via a single class? 我有一个使用多个.groovy文件的大型Groovy应用程序(~2000行)。 我该如何处理生成的类文件? - I've got a large Groovy application (~2000 lines) using multiple .groovy files. How should I handle the generated class files? 如何将类对象用于其他对象? - How can I use a class object into other? 如何使用类方法创建自定义类实例? - How can I use a class method to create a custom class instance?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM