Escaping the Context Parameter format in a Visual Studio Web Test

浪子不回头ぞ 提交于 2019-12-02 04:33:46

问题


I am trying to work out how to pass a particular piece of data in a POST via a Visual Studio Web Test, without it being recognized and treated as a Context Parameter.

The POST contains a (string) body that is a json document. Part of the body includes something like the following:

"My Attribute":"Some test surrounding this {{SomeValue}} other stuff"

The issue is that the Web Test is trying to match {{SomeValue}} to a Context Parameter (which doesn't exist) and so this request fails.

The value is legitimate, and needs to be sent with the request as is.

I've done some Googling and can't find any documentation that talks about, for example, escaping this string so that the value will be passed correct, and won't be treated as a Context Parameter.

I guess I could write a Web Test plugin to intercept this particular request, and do some token replacement, but that feels like a sledgehammer approach.

Any other ideas?


回答1:


You could create the context parameter SomeValue and set its value to {{SomeValue}}.

You could create the two context parameters OpenDoubleCurly and CloseDoubleCurly set to the values {{ and }} respectively. Then modify the POST text to be:

"My Attribute":"Some test surrounding this {{OpenDoubleCurly}}SomeValue{{CloseDoubleCurly}} other stuff"

Normally web tests only do one level of context parameter expansion. You need to use (or for this question avoid using) plugins that do multiple expansion passes.



来源:https://stackoverflow.com/questions/34935527/escaping-the-context-parameter-format-in-a-visual-studio-web-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!