Escaping the Context Parameter format in a Visual

2019-02-27 11:54发布

问题:

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.