2

I am using this default project of asp.net web API . Now I want to create a BDD style End User testing .

I want to consume my web API as my real user will do in BDD way using specflow . I searched almost 30 hours on google but didn't find any solution . So need any type of help for this purpose .

Thanks in advance .

1 Answer 1

1

There is no special tool for writing Web API BDD tests as simply using HttpClient along with SpecFlow is more than easy. Just create a new instance of HttpClient per test and exercise your API as in:

  HttpClient client = new HttpClient();

  HttpResponseMessage response = await client.GetAsync("http://www.contoso.com/api/resource");
  response.EnsureSuccessStatusCode();
  string responseBody = await response.Content.ReadAsStringAsync();

You can always wrap this in a reusable function with URI as the parameter and use it in your BDD descriptions. It's very much up to you on how you go on from here.

1
  • 1
    I just saw your answer and i did exactky in the sane way . Thanjs alot Commented Jul 20, 2013 at 21:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.