线程如何与场景中对其他功能的内部调用一起运行?

时间:2019-03-21 23:23:57

标签: dsl karate

我正在运行一些测试,在这些测试中,我需要调用其他功能进行验证,然后返回到方案中并进一步执行。

示例:

Given url Admin

And def name = '1-' + now()

And json myReq = read('Swagger-AuthThrottling.json')

And set myReq.swagger.info.title = title

And def basepath = 'country' + now()

And set myReq.swagger.basePath = basepath

And request myReq

When method post

Then status 200

And def APPIDFromPublisher = call read('classpath:examples/Services/GetAPIIDFromPublisher.feature') {'title': '#(title)'  }

And def APIIDPub = APPIDFromPublisher.APIIDPub

And def utils = Java.type('examples.Publisher.AddAdvancedThrottlingPolicy')
And def result = utils.main(title)


And def APPIDFromStore = call read('classpath:examples/Services/GetAPIIDFromStore.feature') {'title': '#(title)'  }

And def APIIDStr = APPIDFromStore.APIIDStr

And print 'APPIDFromStore for Qantas Gateway API: ' , APPIDFromStore.APIIDStr

我正在使用5个线程的这种结构运行许多测试。

现在,我不确定运行此类测试时线程如何工作。

我的理解是,当我开始执行时,应该选择5个测试用例,并且单个线程在完成之前不应离开测试,因此理想情况下,我应该看到5个测试并行运行,并且当这5个测试完成时然后应该接下5个。

但是真正发生的是,5个线程拾取了5个测试用例,但是显然将测试留在了中间(怀疑它离开了我在测试中间调用另一个功能的位置)并拾取了另一个新测试从下一个插槽开始,然后是其他一些线程,或者可能是同一线程再次拾取完成的一半测试。

因此,总而言之,在并行5个线程的情况下,我理想地只希望看到5个测试从头到尾开始和完成,只有在此之后才应选择下五个。 但是实际上,我看到执行开始时有5个测试正在运行,但随后逐渐堆积了很多测试,然后随机完成了所有测试的执行。

尽管由于线程的随机选择和测试的完成,完整的执行不会失败,但是它为我的商店加载了很多API(我的测试主要是在Store中注册API),这阻碍了性能商店。

很高兴听到更多有关线程功能的信息,并为此找到解决方案。

1 个答案:

答案 0 :(得分:0)

您在使用Parallel Runner吗?如果不是,我无法理解此问题,请遵循以下过程,简单明了:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue