简体   繁体   English

restFixture-我想声明一个简单的文本响应

[英]restFixture - I'd like a assert a simple text response

This should be a pretty simple thing, but for some reason I am struggling to find an example anywhere. 这应该是一件非常简单的事情,但是由于某些原因,我努力在任何地方都找不到示例。

I have been using the awesome restFixture for some time, and all my assertions are on json content that is returned. 我已经使用了真棒的restFixture一段时间了,我所有的断言都在返回的json内容上。

We now have a microservice that is returning a pure text response (so not json, it's actually a csv). 现在,我们有一个微服务正在返回纯文本响应(因此不是json,它实际上是一个csv)。 I am struggling to find out how to assert the pure text response! 我正在努力寻找如何断言纯文本响应!

I've used this before my GET request: 在GET请求之前,我已经使用了这个:

|Table:smartrics.rest.fitnesse.fixture.RestFixtureConfig|
|restfixture.content.handlers.map    |text/plain=TEXT   |

...but I am not sure how to assert the response. ...但是我不确定如何确定响应。

The message I get back is: 我收到的消息是:

java.lang.IllegalArgumentException: Cannot evaluate 'TOKEN,CARD_LOGO,TRANSACTION_DATE' in TOKEN,CARD_LOGO,TRANSACTION_DATE java.lang.IllegalArgumentException:无法在TOKEN,CARD_LOGO,TRANSACTION_DATE中评估“ TOKEN,CARD_LOGO,TRANSACTION_DATE”

My table looks like this: 我的桌子看起来像这样:

!3 GET Report
|Table:smartrics.rest.fitnesse.fixture.RestFixture|${ReportServiceEndPoint}     |
|setHeader                                        |${ReportServiceHeader}            |                              |
|GET                                              |?transactionDateFrom=${myTransactionDateFrom}&transactionDateTo=${myTransactionDateTo}&requestorId=${myRequestorId} |${myResponseCode}||${myExpectedResultThatOnlyChecksHeaders}|     

Any help would be greatly appreciated, as I will soon have to do more complex assertions on this text response. 任何帮助将不胜感激,因为我很快将不得不对此文本回复进行更复杂的断言。

I don't know how/whether it can be done by restFixture, but my HttpTest fixture allows you to capture any response (and perform a check on the full content, possibly using Slim's regular expression support ). 我不知道restFixture如何/是否可以做到这一点,但是我的HttpTest固定装置允许您捕获任何响应(并可能使用Slim的正则表达式支持来执行对全部内容的检查)。 Alternatively you can place the response in a Slim variable and then do assertions by applying regular expressions using StringFixture . 或者,您可以将响应放入Slim变量中,然后使用StringFixture应用正则表达式进行断言。

I suppose restFixture also allows access to the 'raw' response. 我想restFixture也允许访问“原始”响应。 So this should be possible there also. 因此,那里也应该有可能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM