I have a mobile application running on iOS and Android, I need to create my functional Automated test cases, however for some scenarios I need specific data , so I think a mock server can help on this. I'm not sure how to start with that as I never setup a mock data server, can someone point to the right direction how to start with that?
It depends on what you mean by mock server.
If you want to make actual network calls you could use services like myjson.com or mocky.io to get the specific json.
If you want to simulate the network calls take a look at MockingJay
https://github.com/kylef/Mockingjay
it will stub the network calls and return the specified json.
I usually have many .json files in my test target and use MockingJay to stub the network and test the response/failures.
Related
I want to build an App with support of chopper (or dio, is this is easier), where I can configure fixtures for responses, which are deployed with my app (for testers only).
Example:
The app does a request to api.service.com and would receive a JSON response. Now I want to be sure, that (for testing purpose) the result is always the same at runtime. That's why I add a file (name is independent from the requested uri) into my assets folder. I want to add a checkbox in my dev menu, where I can choose to use the file a the real request.
What could be the best solution for that? Do I need to write a response interceptor for that or is there a better solution, because the interceptor would also do a real request, but I don't need that.
Kaa demo show lots of example of application&client,but actually in the fact solution, may need some of function together,
so,question is:
one client (e.g. android app) access the multiple function (e.g. 2 function:event and notifications)in the server,so:
i need put all function in one application,or
create 2 applications,android app access the different function separate?
You can use some of the SDK API (functions) or all at the same time (within single client application). The Kaa Sample Applications were made with an intent to be as simple (thus clear and easy to understand) as possible. Therefore, just for simplicity most of the samples use just one Kaa feature. This does not mean that they cannot be used in a single application at the same time.
Please feel free putting them all into a single application.
I'm trying to pull-of some tests for my RESTful api functions.
For this I did the following:
Installed PHPUnit.
Created a new database for testing.
Created a new enviorment (test) and changed the doctrine config for it.
Created a test.
My problem is this:
When performing a request (somedomain.com/api/somemethod) -> the requested page doesn't know i'm performing a test on it -> so the data it uses is the production/development database and not the 'test' db i have created for the tests.
(the script using test db, the requested page uses normal configurations).
Is there a way to solve it without touching or modifying the API code/behavior?.
Thanks.
Since you said you're requesting somedomain.com I can only suspect you're firing requests over HTTP.
Symfony is made to be easily testable and you can perform functional test without ever making a real HTTP request. Instead, it will make a request object and tell it's kernel to handle it as if it were coming from a real client.
There is a chapter in symfony book on this: Functional tests
If you use method described there (using Symfony BrowserKit client and paths instead of complete urls), Symfony will have it's kernel booted in test environment and will handle request like that.
If, however, for any reason you are unable/don't want to do it that way, and want to fire real HTTP requests, I suggest you to make a file in web directory called app_test.php. In that file you should boot the kernel in test environment and make sure your tests are actually hitting that file (instead of app.php or app_dev.php). However, have in mind that this file will be publicly available and as so, it will cause a security hole so make sure to guard it somehow (check app_dev.php for hints). As an idea, you could require specific key to be provided in request header to allow it to pass on. Or if it will be tested from a single machine, you could also guard it by IP, or whatever works for your case.
This has happend to me more than once, thought someone can give some insight.
I have worked on multiple projects where my project depends on external service. When I have to run the application locally, i would need that service to be up. But sometimes I would be coding to the next version of their service which may not be ready.
So the question is, is there already a way that can have a mock service up and running that i could configure with some request and responses?
For example, lets say that I have a local application that needs to make a rest call to some other service outside to obtain some data. E.g, say, for given a user, i need to find all pending shipments which would come from other service. But I dont have access to that service.
In order to run my application, i need a working external service but I dont have access to it in my environment. Is there a better way rather than having to create a fake service?
You should separate the communications concerns from your business logic (something I call "Edge Component" see here and here).
For one it will let you test the business logic by itself. It will also give you the opportunity to rethink the temporal coupling you currently have. e.g. you may want the layer that handle communications to pre-fetch, cache etc. data from other services so that you will also have more resilient services at run time
I am nearing the release of an iOS app that syncs and otherwise interacts with a server. I am struggling with a testing procedure that can cover most/all possible situations. I don't have any experience with automated testing so I have been doing everything manually so far with the iPhone simulator and a physical device.
How would I start designing automated tests that can help me get better coverage of possible situations and also serve me well in the future as I make changes and add new features?
You probably need to be more specific in your question. ie. outline how you communicate with your server, what technology is being employed etc.
But as a general approach the first thing I would be doing is looking to find a way to get reproducable results from the server. For example if I send a message asking for a record with an id of 'x' then the server will alwasy return the same record with the same data. There are severa ways to do this, one would be to load a set of test data into your server. Another would be to create a local test server and talk to that instead. Another option is to avoid the server all together in your automaticed tests and mock out the communication classes in your app. It totally depends on what you are trying to test and how.
Once you have your back end dealt with you can then look into automating the tests. This very much depends on how you have dealt with the server. For example, if you are performing an integration style test where you actually talk to a server, then the test might take the form:
Reset or clear the server data.
Load it with predictable data.
Run the iOS app using some testing framework and verify any data sent from the server.
Access the server and verify any changes made there.