无法使用Karate和Cucumber插件执行API脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法使用Karate和Cucumber插件执行API脚本相关的知识,希望对你有一定的参考价值。
我是这个空手道和黄瓜脚本的新手。我编写了以下功能文件,该文件应该运行并打印货币转换器Web服务的响应。
@featureTest功能:测试货币转换器
背景:* url'http://www.webservicex.net/CurrencyConvertor.asmx?wsdl'
@Scenario 1场景:soap 1.1给出请求
“”AFA或ALL或DZD或ARS或AWG或AUD或BSD或BHD或BDT或BBD或BZD或BMD或BTN或BOB或BWP或BRL或GBP或BND或BIF或XOF或XAF或KHR或CAD或CVE或KYD或CLP或CNY或COP或KMF或CRC或HRK或CUP或CYP或CZK或DKK或DJF或DOP或XCD或EGP或SVC或EEK或ETB或EUR或FKP或GMD或GHC或GIP或XAU或GTQ或GNF或GYD或HTG或HNL或HKD或HUF或ISK或INR或IDR或IQD或ILS或JMD或JPY或JOD或KZT或KES或KRW或KWD或LAK或LVL或LBP或LSL或LRD或LYD或LTL或MOP或MKD或MGF或MWK或MYR或MVR或MTL或MRO或MUR或MXN或MDL或MNT或MAD或MZM或MMK或NAD或NPR或ANG或NZD或NIO或NGN或KPW或NOK或OMR或XPF或PKR或XPD或PAB或PGK或PYG或PEN或php或XPT或PLN或QAR或ROL或RUB或WST或STD或SAR或SCR或SLL或XAG或SGD或SKK或SIT或SBD或SOS或ZAR或LKR或SHP或SDD或SRG或SZL或SEK或CHF或SYP或TWD或TZS或THB或TOP或TTD或TND或TRL或USD或AED或UGX或UAH或UY U或VUV或VEB或VND或YER或YUM或ZMK或ZWD或TRY AFA或ALL或DZD或ARS或AWG或AUD或BSD或BHD或BDT或BBD或BZD或BMD或BTN或BOB或BWP或BRL或GBP或BND或BIF或XOF或XAF或KHR或CAD或CVE或KYD或CLP或CNY或COP或KMF或CRC或HRK或CUP或CYP或CZK或DKK或DJF或DOP或XCD或EGP或SVC或EEK或ETB或EUR或FKP或GMD或GHC或GIP或XAU或GTQ或GNF或GYD或HTG或HNL或HKD或HUF或ISK或INR或IDR或IQD或ILS或JMD或JPY或JOD或KZT或KES或KRW或KWD或LAK或LVL或LBP或LSL或LRD或LYD或LTL或MOP或MKD或MGF或MWK或MYR或MVR或MTL或MRO或MUR或MXN或MDL或MNT或MAD或MZM或MMK或NAD或NPR或ANG或NZD或NIO或NGN或KPW或NOK或OMR或XPF或PKR或XPD或PAB或PGK或PYG或PEN或PHP或XPT或PLN或QAR或ROL或RUB或WST或STD或SAR或SCR或SLL或XAG或SGD或SKK或SIT或SBD或SOS或ZAR或LKR或SHP或SDD或SRG或SZL或SEK或CHF或SYP或TWD或TZS或THB或TOP或TTD或TND或TRL或USD或AED或UGX或UAH或UYU或VUV或VEB或VND或YER或YUM或ZMK或ZWD或TRY“”“
当肥皂动作'http://tempuri.org/CurrencyConverter'那么状态200和匹配/信封/身体/ ConversionRateResponse / ConversionRateResult == -1并打印'响应:',响应
当我执行此脚本时,我收到以下错误消息。
Exception in thread "main" cucumber.runtime.CucumberException: Error parsing feature file D:/Workspace/WebservicesTest/src/test/java/feature/soap.feature
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:133)
at cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:104)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:54)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:239)
at cucumber.runtime.Runtime.run(Runtime.java:111)
at cucumber.api.cli.Main.run(Main.java:36)
at cucumber.api.cli.Main.main(Main.java:18)
Caused by: gherkin.lexer.LexingError: Lexing error on line 26: '@Scenario 1
Scenario: soap 1.1
Given request
"""
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ConversionRate xmlns="http://www.webserviceX.NET/">
<FromCurrency>AFA or ALL or DZD or ARS or AWG or AUD or BSD or BHD or BDT or BBD or BZD or BMD or BTN or BOB or BWP or BRL or GBP or BND or BIF or XOF or XAF or KHR or CAD or CVE or KYD or CLP or CNY or COP or KMF or CRC or HRK or CUP or CYP or CZK or DKK or DJF or DOP or XCD or EGP or SVC or EEK or ETB or EUR or FKP or GMD or GHC or GIP or XAU or GTQ or GNF or GYD or HTG or HNL or HKD or HUF or ISK or INR or IDR or IQD or ILS or JMD or JPY or JOD or KZT or KES or KRW or KWD or LAK or LVL or LBP or LSL or LRD or LYD or LTL or MOP or MKD or MGF or MWK or MYR or MVR or MTL or MRO or MUR or MXN or MDL or MNT or MAD or MZM or MMK or NAD or NPR or ANG or NZD or NIO or NGN or KPW or NOK or OMR or XPF or PKR or XPD or PAB or PGK or PYG or PEN or PHP or XPT or PLN or QAR or ROL or RUB or WST or STD or SAR or SCR or SLL or XAG or SGD or SKK or SIT or SBD or SOS or ZAR or LKR or SHP or SDD or SRG or SZL or SEK or CHF or SYP or TWD or TZS or THB or TOP or TTD or TND or TRL or USD or AED or UGX or UAH or UYU or VUV or VEB or VND or YER or YUM or ZMK or ZWD or TRY</FromCurrency>
<ToCurrency>AFA or ALL or DZD or ARS or AWG or AUD or BSD or BHD or BDT or BBD or BZD or BMD or BTN or BOB or BWP or BRL or GBP or BND or BIF or XOF or XAF or KHR or CAD or CVE or KYD or CLP or CNY or COP or KMF or CRC or HRK or CUP or CYP or CZK or DKK or DJF or DOP or XCD or EGP or SVC or EEK or ETB or EUR or FKP or GMD or GHC or GIP or XAU or GTQ or GNF or GYD or HTG or HNL or HKD or HUF or ISK or INR or IDR or IQD or ILS or JMD or JPY or JOD or KZT or KES or KRW or KWD or LAK or LVL or LBP or LSL or LRD or LYD or LTL or MOP or MKD or MGF or MWK or MYR or MVR or MTL or MRO or MUR or MXN or MDL or MNT or MAD or MZM or MMK or NAD or NPR or ANG or NZD or NIO or NGN or KPW or NOK or OMR or XPF or PKR or XPD or PAB or PGK or PYG or PEN or PHP or XPT or PLN or QAR or ROL or RUB or WST or STD or SAR or SCR or SLL or XAG or SGD or SKK or SIT or SBD or SOS or ZAR or LKR or SHP or SDD or SRG or SZL or SEK or CHF or SYP or TWD or TZS or THB or TOP or TTD or TND or TRL or USD or AED or UGX or UAH or UYU or VUV or VEB or VND or YER or YUM or ZMK or ZWD or TRY</ToCurrency>
</ConversionRate>
</soap:Body>
</soap:Envelope>
"""
When soap action 'http://tempuri.org/CurrencyConverter'
THEN status 200
And match /Envelope/Body/ConversionRateResponse/ConversionRateResult == -1
And print 'response: ', response
%_FEATURE_END_%'. See http://wiki.github.com/cucumber/gherkin/lexingerror for more information.
at gherkin.lexer.En.scan(En.java:872)
at gherkin.lexer.I18nLexer.scan(I18nLexer.java:36)
at gherkin.parser.Parser.parse(Parser.java:62)
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:131)
... 7 more
请帮助成功执行
谢谢
错误消息很明确:Lexing error on line 26: '@Scenario
所以删除@
或整个单词,然后再试一次。
如果您参考此示例,您应该能够进行一个简单的测试,然后它应该很容易:soap.feature
karate-demo还有许多其他例子。
以上是关于无法使用Karate和Cucumber插件执行API脚本的主要内容,如果未能解决你的问题,请参考以下文章
无法使用 testng.xml 执行 Cucumber 功能文件
Cucumber-java rerun fail 只执行失败的测试
无法运行 cucumber 'npm test' 命令不起作用