多次调用对象时不会生成新的动态ID

问题描述 投票:0回答:1

我有测试用例,可以使用动态ID插入测试数据

下面是调用POST API对象5次的代码,每次间隔8秒。

但是动态ID在第二次执行时是相同的。

如何使动态ID总是在每次执行时生成?

//Actual Kafka Topic Name
def incomingDOTopic = 'incoming-dispense-order'

//test data using dynamic Id
NewId = CustomKeywords.'swisslog.dynamicId.getUniqueId'()
println(NewId)

GlobalVariable.DynamicId = NewId

//store the dynamic ID to file
def file = new File("C:/Data Files/DynamicId.txt")
file.newWriter().withWriter { it << NewId }
println file.text

//test data with dynamic ID
def incomingDOInfo = '{"Operation":"Add","Msg":{"id":"'+GlobalVariable.DynamicId+'","locationId":"locationid"}'

for (int i = 0 ; i < 5 ; i++) {
WebUI.delay(8)
WS.sendRequest(findTestObject('Kafka/post_message', [('topic_name') : incomingDOTopic, ('message') : incomingDOInfo, ('KafkaRestName') : GlobalVariable.KafkaRestName, ('KafkaRestPort'): GlobalVariable.KafkaRestPort]))
}
katalon-studio
1个回答
0
投票

发现的katalon具有调用测试用例功能,我实现了循环并设法多次发布测试数据。

	for (int i = 0; i < 3; i++) {
		
	WebUI.callTestCase(findTestCase('ServiceTest/Incoming'), [:], FailureHandling.STOP_ON_FAILURE)
	}
© www.soinside.com 2019 - 2024. All rights reserved.