Forcing loading of Asp.net development server with DEBUG for testing wcf service (nunit)? - visual-studio

can anyone help?
I have a solution in vs 2010 which contains a WCF Service application and a class library which has a number of Nunit test.
The nunit tests the service. Problem is that there is no Asp.net Development server running - is it possible to force it to run under debug mode..
I can press F5 but then i can't run my tests.
Maybe i am doing this all wrong, should i host them under IIS 7 ? rather than the built in development server.
That way the server is ALWAYS available rather then loading on demand

See http://www.codeproject.com/KB/aspnet/test-with-vs-devserver-2.aspx for a very lightweight and, in my biased opinion, elegant way to integrate webdev/cassini into your testing environment.
NOTE: the first example of controlling the .exe is for edutainment purposes only. Read through to the second, very brief, code sample for the money shot.
Update:
I use the technique listed above with nunit and most every unit test runner around, including continuous integration on servers that I do not control, extensively with great results.
When I need to simulate a real server with a host name and non-loopback ip address, which WebDev.WebServer and WebDev.WebHost cannot do,
I add the host name to my hosts file, e.g. localhost.skysanders.net 192.168.0.10
use the CassiniDev .dll in almost exactly the same way
it is so simple and bullet proof it should be illegal. ;-)
CassiniDev is also a perfect replacement for the WebDev.WebServer.exe for VS 2008/2010. It has integrated traffic monitoring and is quick a bit faster, both at startup and at processing.

I haven't tried this but since you haven't gotten any other responses:
http://xneuron.wordpress.com/2009/03/27/launch-cassini-using-command-line/
This looks like a command you could add as a pre-build step to your NUnit tests. Hopefully Resharper honors those commands and ensures they're run before doing its own test-specific builds.

I have a solution with exactly the same layout. I would much rather test them in IIS since that is where they will be deployed, and it's nice to know that the code definitely runs under the restricted IIS account rather than my domain account. I run the unit tests as follows:
Make sure IIS is running.
Right-click on the WCF Service project and Publish to IIS.
Fire up NUnit on the client test project and run the tests.
If all tests pass, then great, Otherwise...
Leaving NUnit open, switch back to Visual Studio, and attach the debugger to the IIS worker process (aspnet_wp.exe on my dev machine).
Switch back to NUnit and re-run the failed tests. Any exceptions and breakpoints will break into the debugger as normal.
Rinse and repeat as many times as you like.

Related

Is it possible to watch application insights locally

There is a web.api application with Application Insights plugged in. The AI works like a charm when it is published to Azure. Unfortunately sometimes it is necessary to launch the app in iis express for test purposes. Normally I do it from cmd like this: "c:\program files\iis express\iisexpress" /port:1337 /path:c:\tracker_pub.
Is it possible to watch AI statistics in such a case? In particular I would like to see exceptions that happen sometimes.
Please read this. You can use LinqPad to get all internal telemetry live. Also if you have VS 2015 Update 1 there is an Application Insights hub where you can find AI telemetry (same as in the VS output). You can read about it here. And also this.
Yes, as long as your application is receiving requests and your local machine has internet connection, so it can send events to AI data collection endpoint it should be recording activity when running in iis express. The recommended approach is to send this data to a different instrumentation key (after creating a new AI resource in AI portal), so that your local test traffic is not mixed up with your production data, this is also a great way to test new custom events you are about to add. If you are not seeing any data when running in iis express, the best way to debug would be to start your application in Visual Studio with F5, you will see every event that is about to be sent in your debug output window.

Automated integration testing of a client/server Windows desktop application

My team is developing a desktop application (mixed C++/Tcl) that is used in a client-server setup. Currently it is Windows-only, but soon we will need to port it to Linux. CruiseControl.NET builds it every night from the source code in SVN and packages it into NSIS installer, but we have no automated tests to run.
It is nearly impossible to add any unit tests, but integration testing of the application is easy, because it is already heavily script-based.
The main task is to install the app into 3 PCs, configure it (that involves copying some files around), run it, monitor a possible crash, wait till integration testing is done, collect a summary, send emails. It could be done with a bunch of custom PowerShell scripts, but
In future we will want to add more features and more testing, and
what used to be a simple script soon blows up (as usual), so I want
to minimize custom scripting, and if I need to script something, I
prefer bash/cygwin (I am not familiar with Python or Ruby).
I want a web dashboard that will report current progress, and if
something failed - show logs
I need some supervisor that will monitor the app under test and
report if it hangs or crashes
we will need to test it also on Linux
ideally I would like to orchestrate some test steps between the PCs
(e.g. run test X on PC1 and test Y on PC2 in parallel, wait till they
both finish, then run test Z on PC1, while monitoring that nothing
crashes on PC2 etc)
So, I am looking for a COTS tool/set of tools that will help me to do it and don't have a steep learning curve. Ideally, for free, but if it is really good and has fair pricing, my company may purchase a license.
The process should be triggered from CruiseControl.NET when the NSIS installer is ready, and then perform everything described above. Basically, it should allow at least remote installation of software, running custom scripts and have a web dashboard.
Apparently, SCCM tools like Chef could be used, but so far neither of them supports a Windows server, only nodes. I would like to avoid setting up a Linux VM just for that, although I can do it, if I have no other choice. Also, Chef seems to be a bit overkill - good for 10k machines, but I have only 3... maybe 5 in future. And I am particularly curious about chances to orchestrate a distributed test.
Most of the similar questions here on StackOverflow and in internets are about web apps, Java containers, Maven etc, and there are just so many tools and plugins for these tools to evaluate.
Thanks in advance.
Install ccnet on your test machines. Have those ccnet projects listen to a file that gets edited when a new installer is ready. Have the test machines install that new installer and run tests. There you go. ccnet sends emails so there's your basic reporting.
Have the test results get reported into a database via web services using gSOAP(that's what we did). For linux you can run java cruisecontrol if you must. Write a gSOAP enabled test controller program to report the test results from the test machines. A little c++ app will do. Then write a website(we use ASP.NET) to query the database(Postgresql) and show results. Have the test machines auto update themselves via SVN to get the latest changes to the configuration. Use Nant. Nant is far superior to just using ccnet to run tasks. Nant works through ccnet. Use XML, XSL and CSS with ccnet to make test emails have the information you want(new passes, new failures, SVN differences to code bases, etc...)
Our latest development is putting a big TV in the kitchen with a summary of test results so people can know more readily what they broke!
The first thing I'd get working is a test machine listening for the new installer, installing it, running some basic tests and emailing the results back. Put the ccnet and nant configuration in version control and get that auto updating on the test machine so you don't have to log into every test machine and do an update every time you make a change.
This is hugely broad and pretty close to opinion based. Chef can handle steps like deploying the application to the test machines but it isn't a GUI test framework so you would need something else to handle that. Jenkins supports distributing tests to windows hosts so that seems like a good choice on that side of things but it isn't that great at multi-node tests or orchestration between them. I suspect you'll need to write most of this yourself given the requirements.

Remote debug a Windows service using VS2012

I've tried to find an answer to this before posting this question. I've got a windows service running on another machine. I've written the service in C# and the directory from which the service executable runs holds both executable and debug files (.pdb). I'm attempting to remote debug the service for the first time using VS 2012 Remote debugging. I'm able to attach to the service process successfully. However, as this is my first time I'm not sure what I can do next. I've clicked the pause button and that pauses the service on the line ServiceBase.Run(ServicesToRun) which isnt much use to me. The service has a timer which sets off every 30 seconds and will run the code in the timer event.
My question is ... is there a way of stepping through the code using the debugger in such a scenario.
Do I need to have some debug specific code already in my codebase so that when a debugger attaches it will take me to a place in the code from where i can step through the code?
Thanks,
Andrew.
There are several ways to debug your developed remote application or windows service. If you were in your machine(local) that would be simple to debug.
System.Diagnostics.Debugger.Launch();
But as you are in different machine it depends how your both Machines are connected. Which means you have some limitations on debugging remote application/services.
A Quick search gave me the following result that seemed helpful to me for you,
You can use Remote Debugging Monitor that visual studio use for connecting to remote device and debugging. You can have a clear instruction here on How to: Run the Remote Debugging Monitor.
There's another tool which lets you debug remote application's after a proper setup. But it has some limitations or conditions that you must abide by.
Here is the tool named Remote Tool, you can find a detailed setup process from MSDN here on How to: Set Up Remote Debugging.
It has been clearly quoted there about the prerequisites for using this tool. But still I'm rephrasing those again for quick reviewers.
Prerequisites to use Remote Tool for Visual Studio
To debug on a remote device:
The remote device and the Visual Studio computer must be connected over a network or connected directly through an Ethernet cable. Debugging over the internet is not supported.
The remote device must be running the Remote Tools for Visual Studio 2012.
You must be an administrator to install the remote tools on the remote device. To communicate with the remote tools, you must have user access to the remote device.
Feel free to share if you get to a better and working solution.
Thanks for your response. It reminded me to post my solution here for others like me.
The solution is simple (It always is once you know it).
Ensure that you are running the same code on the target machine as you have open in Visual Studio. It has to be the same assembly and version else the debugger will not hit your breakpoints. Ensure you have your breakpoints setup where you want the debugger to break execution. Then attach to the target machine process and wait for the timer to kick in and run the process where you breakpoint is set.
Hope this helps.
Andrew.

Using continuous integration to deploy to a virtual machine to run integration tests

Has anyone any experience of setting up a CI server (team city for preference) to manage the creation of a virtual machine, deploying a package to the machine, getting the database to a known configuration then running integration tests. Tearing down the whole thing and reporting back to Team city the test status?
We do something like this, we have three types of tests. Unit tests which I am sure you are aware of but we also run a number of Acceptance Tests and Integration Tests and it is the latter to that are relevant.
In our integration tests we run a series of WatiN tests against our QA environment which is known to have an environment already running on it, these are usually run after TeamCity runs a deployment build to the QA environment. These tests do a full integration against all our external third parties.
What you might be more interested in is our Acceptance Tests but point to note we do not spin up a virtual environment (more on that later). We have a series of acceptance tests that spin up all the services in their own application domains and deploy database using visual studio database projects. Because these are acceptance tests all third party interfaces are mocked. Since the services are spun up in process the only thing to clean up at the end are the databases.
This works for us but I have been considering taking it to the next level with out integration tests and spinning up a virtual environment that looks exactly like our live environment down to domain names and IP addresses and this is entirely feasible but will be time consuming to do but will depend on the flavor of virtual environment you plan on using.
Here is an answered SO question on how to spin up Hyper-V servers using MSBuild but I am sure there are other examples using Ant/Nant/Rake for Hyper-V/VMWare etc.
How can I create virtual machines as part of a build process using MSBuild and MS Virtual Server and/or Hyper-V Server Virtualization?

Code, Build and Run on seperate Machines. Posssible?

I know that I can code on one machine and have it build on a different machine (ie. a build server). Now I have also heard that you can have visual studio run a build on a virtual machine (i think it requires Virtual PC). Now my question is if anyone has been able to code on machine A, have it compile on machine B and run a debugging sesion on machine C?
This is pretty common in enterprise development and just about the de facto standard way of doing things.
Typically, a dev works locally. Once s/he is happy with their changes, they'll check it into a source control system.
From that point there are a couple of options ranging from automated building to having someone push the button to cause the remote build.
Once the build is complete there are a host of options available for deploying the app to one or more other servers. And yet other options for kicking off automated test suites.
Concerning remote debugging, you can do that independently of whether you are using a build/deployment/automated testing. It's just a matter of getting the right stuff installed and configured (see ho1's answer for a link).
All of that said, I highly recommend you never enable remote debugging on a production server. Some people might disagree with me but I personally think it's dangerous for security reasons and can certainly lead to site outages.
Finally, the only reasons you would need a virtual machine is if the servers aren't available or if you just want to sandbox everything.
You can do remote debugging, so if you had an automated process to copy the compiled code from B to C, I suppose you could do what you're asking.
See this MSDN article for more details: How to: Set Up Remote Debugging

Resources