I want to load test an application having its own WCF service using Visual Studio 2012. I tried creating a web performance test and use it with load test but, web performance is not recording the intermediate request send to service which is very much required.
Using CodedUI with it not feasible since it does not put on that much load and and its interactive.
The application is on different server and service too.
Any suggestion to accomplish this in VS2012.
Use dedicated "Unit Tests" for this. VS Load Tests can execute Coded UI/Web Performance or Unit Test.
In your Unit Tests, simply use a standard WCF proxy, channelfactory or RestClient.
Just check that you dispose well a Web Service Proxy class
Related
I have REST web service which needs to be tested. I am using Mockito for mocking DAO classes and RestAssured for testing REST methods through URI. Is there any way to test REST service without running it separately with Tomcat? Or how to run application on Tomcat with mocked classes before test cases?
There is a tutorial that shows you how to use maven to start an embedded instance of tomcat and run tests against your service using RestAssured:
http://www.hascode.com/2011/09/rest-assured-vs-jersey-test-framework-testing-your-restful-web-services/
You start tomcat in one shell and run your tests in another.
However, I strongly recommend using the jersey test framework which transparently spins up an embedded container. In this case you wouldn't use RestAssured at all, but the jersey test client. Your tests will run more quickly and with less fuss. It's well documented here: https://jersey.github.io/documentation/latest/test-framework.html. The tutorial also demonstrates this approach, though it doesn't seem to me that the client is correctly constructed.
In the past I've also tested REST resources by calling the implementing class methods directly. Though this doesn't test the correct mapping of the http query parameters/body to java method parameters, it was often sufficient (especially when I'm also coding the client side code).
Just wanted to know whether we can have a Unit Test Project dedicated to a WCF Solution or not ? I know this might be a Generic question but I couldn't get specific answer to it even though I searched through various blogs and websites. Please suggest.
yes its possible to unit test WCF services. The options are:
create classes which do all of the work which are separate from the WCF service. Unit test these classes in isolation. Make your service a thin wrapper which calls these classes.
test directly with the WCF service class without it being hosted (a bit like this example)
Have the unit tests host the WCF service in process and then call the services via named pipes or similar (see the console example here for details of how to self-host). When you self host you should start the service in the test setup or the test fixture setup and then destroy it in the corresponding teardown.
I am working on some WCF services and they will be deployed to Azure, so I would like to try to accomplish as many unit tests as I can locally, in order to avoid useless roundtrips to the staging area while we run the integration tests.
The services use the CQRS pattern and I have layered everything in the following way:
- A bootstrapper to inject dependency into the WCF services
- A command for each service method
- A command handler to intercept the commands
So far I can fully unit test the commands, the handlers and the bootstrapper. What I still need to write is this type of test:
[TestMethod]
public void Client_ReceiveValidCommand_WillExecute()
{
var factory = new ChannelFactory<IDomainWriteService>("*");
var service = factory.CreateChannel();
var expectedCommand = BuildAddUsersCommand();
service.AddUsers(expectedCommand);
}
The problem is that this test pretends a valid endpoint in the configuration file.
Is there any way that I can start something like IIS express while my test fitness starts and then plug the channel factory into this instance of IIS?
I simply can't create a staging area where I can deploy my services and run my integration tests so I would prefer to follow the unit test way where possible.
I found an interesting article here: http://www.reimers.dk/jacob-reimers-blog/testing-your-web-application-with-iis-express-and-unit-tests which explains how to host your test in IIS express and of course run IIS express within your unit tests.
In this way I can simply create on fly a new instance of IIS express and host my WCF service, run the unit tests and finally destroy everything.
I have developed a WCF Web Service using C# that works and serves up the data I need to my mobile client using a COBOL VM that talks to my backend data. It works, but it is very unreliable. I think it has to do with the lifecycle of the web service and I just don't understand how it is breaking down. I believe the problem is the COOBL VM, which is a singleton, and the process of shutting it down each time. I've already tried
lock(myobject)
{
... run my code here
}
I want to move the COBOL VM to a server service where I can persist my COBOL VM and just make calls to it. I don't know how to persist the COBOL VM across all WCF Web Service calls. I'm looking for examples the show a wcf web service communicating with a server service so I can move my business layer code out of the service and just have it make calls to the server service for the data it needs. This way I can keep the COBOL VM running all the time rather than going through a load-up, execute, and then shutdown process as I'm doing in the Web Service.
Does anyone have any GOOD examples of a WCF Web Service communicating with a WCF Server Service?
keep the COBOL VM running all the time rather than going through a load-up, execute, and then shutdown process as I'm doing in the Web Service.
Then create a Windows service that hosts this VM client, so you only have to connect once and can keep it running. Then you can let that service also host a WCF service, which then queries the VM client.
You might be better off looking into a CORBA solution - CORBA is the only remoting technology that can give you access into an already running process.
I'm in the middle of performance testing a critical section of my project, when I notice a whole lot of extra threads being used to to perform WaitOrTimerCallback operations.
alt text http://lh4.ggpht.com/_p7-jVU64mGg/SZuWgUvTD7I/AAAAAAAAAEk/PUFrXrYvZh0/threads_thumb%5B1%5D.jpg?imgmax=800
On closer inspection I can see that these are being spawned by my ASMX client proxy class for operations on a remote server.
I was under the impression that these were using IO completion ports like all of my other asynchronous IO Calls.
Is it possible to get a ASMX or WCF proxy client to use IO Completion ports? If not - really what is the point?
[UPDATE]
The project was using ASMX proxy client(s). It appears that they are using the normal thread pool inorder to register a WaitOrTimerCallback. I'm now working with WCF Proxy clients. These are not spawning extra threads so i can only assume they are using the desired IO completion ports.
The ASMX Proxy class was created using Visual Studio 2008. I had added the following line to the the project file: "WebReference_EnableLegacyEventingModel>true" As the current flavour of ASMX clients do not have Asynchronous enabled by default.
I can't speak for ASMX, but WCF definitely does (and like you I'd be surprised if ASMX doesn't). Can you get the call stacks to ensure that they really are blocked on network calls (and not some other user code)?