Visual Studio 2012 Coded UI Testing of Web Application - Code coverage - unit-testing

I have a web application. I am using VS 2012 Coded UI for testing the web application. I have recorded the test and running it, and it works fine. But the code coverage window gives code coverage of the test project only, it doesnt give code coverage of the website project and other dll project which is referred in the web project.
I have added the testsetting file in the solution and selected the same.
Any clue?

Couple of things to verify
a) Have you added all these assemblies into the code coverage configuration's list of assemblies via the testsettings?
b) Is your deployment of the web app happening as a part of your test run? If so then you should ideally have the "instrument in place" option selected

Related

How to unit test UWP App with Azure Mobile App?

Consider a Visual Studio 2017 solution with 3 projects:
UWPApp - Universal Windows App
UWPAppTest - Universal Windows App Test (NuGet package: Microsoft.Azure.Mobile.Client)
MobileApp - Azure Mobile App web service (NuGet package: Microsoft.Azure.Mobile.Server)
I'd like to create a unit test in my UWPAppTest project, that calls my web service, running locally in my MobleApp web service project.
This requires me to somehow configure Visual Studio to launch the MobileApp project (selecting "don't open a page"). And at the same time, click "Debug Selected Test" in my test explorer. Or, somehow automatically launch the MobileApp in debug mode, when I debug a unit test.
This doesn't look like a supported scenario, and if not, what would be the next best workaround to be able to run a UWP test project, with tests calling a local web service?
Thanks
-John
This is something that Azure Mobile Apps has had to deal with as well. We use end-to-end test scenarios with a mobile backend hosted in the cloud. The test run will clear the contents of the database prior to each run, thus ensuring the appropriate unit testing. The biggest thing here is dealing with state.
In a local debug version, you will want to set the URI passed into the MobileServicesClient to your localhost, but things should not be any different. Just ensure you are fixing the starting point and ending point of your database for each test.

Debugging API and unit test from same solution

I have a WebAPI project and a test project for API in same solution as shown below.
The code of controller is shown below. As you notice I have a breakpoint setup on the Get method
The API is working fine such as via postman or browser as shown below.
One of the unit test is just calling the same Get API via HttpClient class.
Problem is I want to setup both projects (API and test) so that I can debug code from a single solution. For that I have setup both of these projects as start up
If I hit F5 key to start debugging, I get following warning which makes sense
In order to debug the unit test and choose “Debug Tests” option as shown below
With that I get following exception that A connection with the server could not be established.
In summary
1. The API is working fine as I can test it via PostMan
2. If I move the unit test project in a separate solution, then I can debug API fine. The breakpoint get hit and everything is fine
My question is how to debug this when I have both projects in the same solution?

How do you debug unit tests?

I'm running some nunit tests in xamarin studio. They run fine but there does not seem to be an option for running them in debug mode. I've even looked through the keybindings in xamarin to see if it's an option (which is hidden from the menus but can be activated by a custom shortcut)... no luck.
If I want to debug a test, I have to copy and paste the code from the test method into a console application which is hooked up to the same references as my test project.
Any ideas?

How can I make Visual Studio automatically attach its debugger to both a web application and web service?

I'm working on a Visual Studio project. I'm using Visual Studio 2010. The project has an ASP.NET application project and a separate ASMX web service project. The web application project is set as the start-up project.
When I tell Visual Studio to start debugging, it correctly starts both the web application and web service. However, it only attaches the debugger to the web application and not the web service. This problem seems to occur regardless of which web server I use for either project (IIS, IIS Express, Visual Studio Development Web Server).
In order to debug both simultaneously, I need to manually attach the debugger to the web service during the debugging session.
How can I make Visual Studio automatically attach to both projects when I tell it start debugging?
I found that this works if I set both the web service and application to start-up projects. Do this by right-clicking the solution file and choosing something like Set Start-up Projects....
One of the options is to open two instances of Visual Studio and debug the projects separately, however it is pretty much the same inconvenience as attaching the debugger manualy.
By the way, do you have ASP.NET debugger allowed in both projects (project properties > web tab > debuggers section)?

Pocket PC 2003 application with webservice

I am working on a Pocket PC 2003 application that is referencing a Webservice.
I was figuring out ways to debug the Webmethods but not successful.
-I checked the URL property of the Service in WebReferences and made sure it is correct.
-I started debugging the PocketPC application, then built the Webservice as start without debugging, after that went to Debuh> Attach process and attached devenv-"Pocket PC app"
-I also tried attaching to the aspwp.exe process but couldn't seem to hit the break points in Web Methods.
-The webservice is deployed to IIS virtual directory.
-I copy pasted the entire webservice folder in the virtual directory. Then I am opening the solution file in Visual Studio. Start without debugging, when the webmethods show in browser, click on it, then click Invoke
Can someone guide me the proper way to debug a Webservice of this type? Thanks in advance.
If you're using Visual Studio 2005 or higher, instead of IIS, use the toy Web service that comes with Visual Studio. In the properties of your ASP.NET project with the Web services, under "Web", check the "Use Visual Stuidio Development server". In order to make the toy server start, you have so start the ASP.NET project from Visual Studio.
Then you attach to the process called Webdev.Webserver.exe using Managed code debugging.