나는 읽었다 : https://stackoverflow.com/search?q=%5Bkarate%5Dcannot+convert+to+map 및 https://github.com/intuit/karate/issues/544
나는 karate-0.8.0을 사용하고 있습니다.
A 디렉토리에서 재사용되는 기능이 하나 있습니다. 내용은 다음과 같습니다.
@ignore
Feature:
Background:
* url baseUrl
* def Sign = Java.type('cruiser.token.Sign')
* configure afterScenario =
"""
function() {
if (karate.info.errorMessage != null) {
karate.log(karate.info.errorMessage);
}
}
"""
Scenario:
* def ck = Sign.execute('#(uid)')
* path '/rest/n/rt/upload'
* cookies ck
* multipart fields '#(fo)'
* multipart file rt = { read: 'classpath:cruiser/http/rt/A/123.mp3', filename: '123.mp3', contentType: 'audio/mp3' }
* method post
* status 200
* match response contains { result: 1 }
그리고 B 디렉토리에 다음과 같은 다른 기능 파일이 있습니다.
Feature:
Background:
Scenario:
* def fo =
"""
{
'title': '你好!',
'description': '很好听哦'
}
"""
* def x = call read('classpath:cruiser/http/rt/A/upload-base.feature') { uid: 33, fo: '#(fo)' }
* match x.response contains { result: 1 }
* print x.response.feed.id
러너 이름은 XRunner.java입니다.
때 mvn test -Dtest=XRunner
, 오류 정보 :
Running cruiser.http.rt.B.XRunner
11:25:33.138 [main] INFO com.intuit.karate.junit4.Karate - Karate version: 0.8.0
11:25:33.896 [main] ERROR com.intuit.karate - feature call failed: classpath:cruiser/http/rt/A/upload-base.feature
arg: {uid=33, fo={title=你好!, description=很好听哦}}
cannot convert to map: '#(fo)'
Failed scenarios:
cruiser/http/rt/B/x.feature:3 # Scenario:
이 두 줄은 모두 잘못되었습니다.
* def ck = Sign.execute('#(uid)')
* multipart fields '#(fo)'
이것을 읽으십시오 : https://github.com/intuit/karate#rules-for-embedded-expressions
가라테에서 표현은 기본적으로 순수 JS입니다. 그러니 이렇게하십시오 :
* def ck = Sign.execute(uid)
* multipart fields fo
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다