Search code examples
asp.netvisual-studioazure-api-appsintellitest

Visual Studio 2015 IntelliTest bug on Azure API Apps?


When running IntelliTest on a default/blank ASP.net application using the "Azure API App (Preview)" template, IntelliTest finds nothing to test. I am not sure if this is by design, a bug, or just not supported yet. Does anyone know a workaround?

The IntelliTest output window displays "monitored process exited with could not find any test to run (-1013 - 0xfffffc0b)". I have made sure the project targets x86.

If I use the "Web API" template, IntelliTest correctly produces test results (in step 4 below choose Web API instead of Azure API App). I have now verified the above behaviour on 2 machines.

To replicate:

  1. Open VS 2015 Enterprise
  2. File -> New Project
  3. Under Templates -> Visual C# -> Cloud, pick "ASP.net Web Application"
  4. Select Name location and click ok, at the below screen choose "Azure API App (Preview)" and click ok. Asp.net Project template selection
  5. When the project loads, navigate to the "ValuesController".
  6. Right click inside either of the default Get() methods and select "Run IntelliTest" as per below Run IntelliTest
  7. Open the output window and select "IntelliTest" from the "show output from" dropdown and observe message above (...could not find any test to run)

Solution

  • Eventually tracked this problem down to some incompatibility between Swashbuckle and intelliTest (Swasbuckle is used by api apps to generate Swagger doc for the API).

    To solve, open SwaggerConfig.cs in your App_Start folder of your API App project and remove the below class that inherits from IOperationFilter. The disadvantage of this is not having your params joined together in the swagger doc, something I do not like much anyway (the default model is much nicer to read a long list of params from).

    internal class IncludeParameterNamesInOperationIdFilter : IOperationFilter
    {
        public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
        {
            if (operation.parameters != null)
            {
                // Select the capitalized parameter names
                var parameters = operation.parameters.Select(
                    p => CultureInfo.InvariantCulture.TextInfo.ToTitleCase(p.name));
    
                // Set the operation id to match the format "OperationByParam1AndParam2"
                operation.operationId = $"{operation.operationId}By{string.Join("And", parameters)}";
            }
        }
    }