本文介绍了是否有功能将多个项目中的karate-config.js文件合并到karate中的单个文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有两个具有结构测试的项目->项目1-> karate-config.js并测试-> project2-> karate-config.js.理想情况下,我想在测试文件夹级别(例如test-> karate-config.js(project1 + project2))将配置组合到单个配置文件中.除了API端点URL之外,这两个项目在配置文件中都使用类似的结构.在此先感谢!

We have two projects with the structure test -> project1 -> karate-config.js and test ->project2 ->karate-config.js. Ideally i would like to combine the configs into a single config file at the test folder level like test ->karate-config.js ( project1 + project2). Both projects use a similar structure in the config file except for the the API endpoint URL's. Thanks in Advance !

推荐答案

您可以随时读取任何JS函数并对其进行评估.如果返回JSON,则可以使用karate.merge()将其添加到配置中.这样就为您提供了许多可能性.

You can read any JS function at any time and evaluate it. If it returns a JSON, you can use karate.merge() to add it to the config. So that gives you many possibilities.

var fun = read('classpath:some.js');
config = karate.merge(config, fun());

这表示请注意,有一个karate-base.js概念-因此,请阅读文档: https://github.com/intuit/karate#karate-basejs

That said please be aware that there is a concept of karate-base.js - so please read the docs: https://github.com/intuit/karate#karate-basejs

这篇关于是否有功能将多个项目中的karate-config.js文件合并到karate中的单个文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 07:03