locked
Integration Tests Pass in Test Explorer but fail from command line RRS feed

  • Question

  • So I have some integration tests that I have written for my API controllers (ASP.NET) using an HttpServer. The APIs are secured using Facebook Login and have the [Authorize] attribute applied to the ApiController class Here is how I am setting up the HttpServer...

    var config = new HttpConfiguration();
    
    config.Routes.MapHttpRoute("Default","api/{controller}/{action}/{id}",new { id = RouteParameter.Optional });
    
    HttpServer server = new HttpServer(config);
    
    var client =  new HttpClient(server);

    I then use the client to send HTTP requests into my API for integration testing. This all works fine from within Visual Studio (2013 Ultimate) using Test Explorer. None of the OWIN pipeline and auth handlers seems to get called and my tests all pass.

    However when I run the tests from the command line using vstest.console.exe the tests all fail. The call into the HTTP server returns a 404 Unauthorized. What am I missing? What is returning the unauthorized response? I have not wired up any OWIN middleware, although that was going to be my next step to test the login cases.

    Monday, May 18, 2015 6:46 PM

Answers

  • Hi bdyer64,

    As you said that you could run the integration tests from the Test explorer in the VS IDE, but it could not work in the vstest.comsole.exe in command line.

    Could you please tell me how to execute the command to run the integration tests using vstest.comsole.exe in command line?

    However, from the error message, I assume that the issue is related to the HttpServer authenticates.

    >>when I run the integration tests inside visual studio the HttpServer authenticates me with Windows Credentials. This seems dumb, how can I disable that?

    Generally, I know that we could right-click the unit test project->Properties->Services tab->check if you enable the client application services and select the Use Windows Credentials option.

    If the Use Windows Credentials option is enabled, I suggest you could un-check the to disable the client application services option and then check this issue.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Tina-Shi Tuesday, May 26, 2015 7:17 AM
    • Marked as answer by Tina-Shi Tuesday, May 26, 2015 7:18 AM
    Wednesday, May 20, 2015 5:32 AM

All replies

  • So after a little research and some debugging code I determined that for some reason when I run the integration tests inside visual studio the HttpServer authenticates me with Windows Credentials. This seems dumb, how can I disable that?
    Monday, May 18, 2015 8:19 PM
  • Hi bdyer64,

    As you said that you could run the integration tests from the Test explorer in the VS IDE, but it could not work in the vstest.comsole.exe in command line.

    Could you please tell me how to execute the command to run the integration tests using vstest.comsole.exe in command line?

    However, from the error message, I assume that the issue is related to the HttpServer authenticates.

    >>when I run the integration tests inside visual studio the HttpServer authenticates me with Windows Credentials. This seems dumb, how can I disable that?

    Generally, I know that we could right-click the unit test project->Properties->Services tab->check if you enable the client application services and select the Use Windows Credentials option.

    If the Use Windows Credentials option is enabled, I suggest you could un-check the to disable the client application services option and then check this issue.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Tina-Shi Tuesday, May 26, 2015 7:17 AM
    • Marked as answer by Tina-Shi Tuesday, May 26, 2015 7:18 AM
    Wednesday, May 20, 2015 5:32 AM