WP7 3 tier architecture unit testing - unit-testing

I have a WP7 application that uses a 3 tier architecture with an Azure service in the middle carrying out all DB manipulations but have run into difficulty when trying to wrote unit tests for this.
Can anybody suggest any methods on how I could test my system
Regards

Usual unit test solutions will work fine in this scenario. On the Windows Phone side, you can create a mocking service. That is, you don’t actually connect to Windows Azure, but you have an interface that is identical to the Windows Azure service interface. This interface returns some mocked data. You test against this mocked interface. On the Windows Azure side, you need to do some unit tests on data accessing layer as well as the service layer. I assume you use Entity Framework, you can create a unit test to test the CRUD operations without introducing the service. As for the service layer, you need to add a service reference in another unit test (suppose you’re using SOAP or OData), and then do the test.

Related

Automated Unit Testing Oracle BPEL SOA projects

Is there an alternative to the Oracle SCA Unit tests provided with JDeveloper for testing SOA projects/BPEL?
The problem I have is with it is the amount of effort required to write the tests through the clunky UI and the smallest change will invalidate all tests currently built which makes them un-maintainable.
The other issue is due to the graphical interface the SOA composite must first be written before unit tests can be written meaning a test driven-development is not possible.
The final issue is the emulation functionality is incomplete with database partner links.
I use SOAP-UI to perform unit testing. I create separate test scripts with SOAP-UI which allow me to generate a number of different test case scenarios which can be targeted at individual services.
I then invoke these from a Jenkins/Hudson script to provide continuous integration testing.
In this way you can do your TDD without first creating the composite.
With your database partner links you can emulate them either with a stub composite or alternatively with SOAPUI. This depends on what your configuration is and exactly what you use the data for.

How to Unit Test a WebService call?

I have a standard web application, it contains a UI (which has an WebService API), which references a Business Layer which in turn references a SQL based DAL. These layers have a good coverage of unit tests which use mocking to replace their dependencies.
I also have an API library which allows users to access the WS via code (and handles a lot of the issues like credentials, urls etc). I want to write unit tests for my library.
Currently the only way I can do this is to write tests referencing the library and populate the database using the same mechanism I use to test the DAL. However this approach is clearly flawed as it doesn't test my API library classes - it tests the entire stack!
How can I insert a mock under the WS (which is in a different project)? I'm currently using MBUnit and MOQ to test.
EDIT: My unit tests currently test two things:
That the API is translating from WS objects to local objects I pass to the consumer correctly
That the fields of the transport objects were populated correctly
Your API really seems to be doing 2 things, so I'd place these responsibilities in 2 distinct modules and test them separately
A Translator module. Translates API calls into web service proxy calls and maps back responses from the web service to appropriate data structures defined in the API. To test it, use a mock of the Adapter module described below.
An Adapter / Proxy module whose job is to call the real web service. You can test it using integration tests. If the only way to do it is populate a database and exercise the full stack, you might want to move these tests out of your main test suite into a less frequent, long-running test suite.
Similar approaches are discussed here : http://blog.8thlight.com/eric-smith/2011/10/27/thats-not-yours.html and there http://nf2p.com/dot-net/mocking-web-service-proxies-using-the-adapter-pattern-to-allow-unit-testing/

How to use Microsoft Fakes for unit testing a web service?

I am working on a project which has 3 tier architecture:-
1. Business layer 2. Data layer 3. Service Layer
I want to unit test my Service layer.
Currently I succeeded to add a unit test to my Business layer by faking the Data Layer.
Now the issue is, I have a service layer which makes call to my Business layer, which in turn makes calls to my Data layer.
Initial test case that passed was written by adding a reference of Business layer project in my Unit test project and then creating Fakes of the Data layer.
Now what I want to do is, I want to achieve this by adding Reference of Service in the Unit test project and also using Microsoft Fakes at the same time.
Can someone please help me in understanding this? I am new to this Fakes framework.
This question is old, but hopefully it helps you, or someone in a search:
You seem (imho)to be mixing what is needed in your architecture(and/or integration testing) vs what is needed in unit testing. If you are trying to fake for unit testing, remember SUT! System Under Test should be the only component you are testing. In which case, if you are testing a component in your service layer you should fake(shim or stub) any calls external.
http://msdn.microsoft.com/en-us/library/hh549175.aspx
Gives a good example with the IStockfeed stub.
Please clarify if you are trying to integration test or unit test.

Integration testing with dependency on outside service

I am currently writing integration/functional tests for my system. Part of the functionality is to hit a web service via http (another system I run).
How should I set up a test instance of the web service to allow for good functional testing? I want to have my system run against this service with live production data.
Should the web service be an independent instance that always has the live production data that I reload manually (maybe reset every time I start an instance of it)?
Should the web service be setup and teared down with every test?
What are some common practices to deal with situations like this?
As first thing please make sure you know difference between Functional Testing and Integration Testing. You can do a pretty good functional tetsing wthout major efforts which are required by integration testing (instantiating web services, accessing a data base). Basically Mocking technique works pretty well even to simulate the Data Layer responses and web service behaviour (I believe such details like HTTP as transport could be ignored for most test cases)
For such integration testing I would suggest having a separate SIT environment which includes a separate Web service and a Data Base as well.
Should the web service be an independent instance that always has the live production data
that I reload manually (maybe reset every time I start an instance of it)?
Yep, it should be completely separate but data could be manually generated/prepared. For instance, you can prepare some set of data which allows testing some predefined test cases, this could be test data sets which are deployed to the SIT DB instance before the actual test run and then cleaned up in test TearDown.
Should the web service be setup and teared down with every test?
Yep, tests should be isolated one from each other so should not affect each one in any way.

how do you use TDD for developing webservices using Oracle Service Bus

Does anyone have any opinions on how TDD and UNIT testing would would when developing web services using Oracle Service Bus? All I can think of is stubbing out the back ends then running tests through the service bus, but that's really just integration testing. How would I apply TDD principles in this instance?
Is your question actually how best to conduct unit tests on Oracle Service Bus components? I have the same issue but have come to the view that now your unit of code is not a Java method or a class but a whole proxy.
It does however limit you to being only able, at best, to conduct component integration testing as you have described: Stubbing out the other systems and running what you'd traditionally call Integration tests through the Service Bus.
Scale up your unit of work.
If there is a better way to automate and test these code artifacts then I want to hear about it.