How to run monkey testing ONLY in application? - monkey

How to run monkey testing ONLY in testing application?
How can I set border for monkey testing. I don't want that it touches any button out of my testing application.

According to the doc. You can use the option -p to limit your test in specific package.
Something like this:
adb shell monkey -p your.package.name -v 500

Related

Is there a way to run parallel cucumber tests providing different users to each process

Problem to solve: We want to be able to run multiple ruby cucumber tests in parallel with different users. Since we have user collision in the app, we are not able to use the same user simultaneously.
We tried looking into parallel_test gem to use parallel_cucumber but did not find any way to pass a different user for each process. One option I read online was to have user info in the DB and make a call to get a free user before each test. This was not feasible for us.
Does anyone know any way to make parallel_cucumber or any other ruby gem work to run parallel cucumber tests with a different user for each process
If you are running parallel tests you should be able to use a separate db for each stream. This should avoid the issue of user collisions.

How to e2e test multiple client synchronization?

I am writing e2e tests where I want to test that when I add an entity on one client, the other online client will be synced and see the added entity. (Think google docs when you type and the words appear on the other users' screens).
My question is: how can I e2e test client synchronization through WebSockets?
Should I mock WebSockets if possible? Should I find an e2e framework that allows multiple tabs/ browser instances and test that the clients sync like that? Is there another way?
I have looked at applications that also use synchronization like these: https://github.com/automerge/trellis/blob/master/test/application.js and https://github.com/automerge/pixelpusher. Unfortunately, they either don't have tests or don't use WebSockets.
I think the simplest way would be to start two tests simultaneously like this:
create a new script entry in the scripts section of the package.json file:
"scripts" : {
"testcafe": testcafe chrome,
"test-synchro": npm run testcafe -- test1.js & npm run testcafe -- test2.js
}
in test1.js you add one entity then create a json file that contains all information on the new entity.
in test2.js you wait for this file to be present and stable in the file system and then you act on it. Maybe you could use package wait-on to achieve this.

How to stop Event Machine in setup like this?

I have a Sinatra app, overall configured like described here sinatra docs.
It basically starts an event machine loop.
Now, If I want to write a RSpec test, how do I start server like this and shutdown it after?
I can do this from console by ruby server.rb, I may execute this command from spec file in test suit setup (however, I'm not sure if it is right). But then, even if I do so, how I stop it after? (and do I need or it will be stopped after test is finished?)
I think, in any case, you can use Rack::Test to test your Sinatra app. In order to run the specs, you don't need to run the server from the terminal.
Take a look at the documentation, you can find different examples:
http://www.sinatrarb.com/testing.html

Pass parameter to Rspec test on the command line

I am trying to use RSpec to functional test my REST apis.
The way I would LIKE it to work is using a CI build to build and deploy my application to a test server somewhere in the cloud and then have it kick off automated functional tests. But in order to properly do that, I need to be able to pass in the base url/domain for where the app was deployed. It will not be the same.
Everything I've found so far makes it seem like RSpec can't do this. Is there another way to do it if I can't pass in parameters on the command line? Or is RSpec not the right choice for this?
One way would be to bypass the call to rspec with something that accepts command line arguments and then initiate rspec in code. If you do not want to write your own binary for that, rake is capable of that too.
Look here for how to run rspec from code.
Another way would be setting an ENV variable when calling your test and preferably making it optional in the specs.
$> SPEC_URL=http://anotherhost:666 rspec
in code:
url = ENV['SPEC_URL'] || "http://localhost:4000"
I would suggest method two as it's the cleaner and easier approach in my opinion.

How to run an EventMachine application on your own production server?

I have just written my first EventMachine application. In development, to start the server, all I do is:
ruby myapp.rb
Which runs my application until I kill it with control+C. In production, this doesn't seem like the right way to do it.
How would I go about running this on my production server?
Check out daemons: http://daemons.rubyforge.org/ - a simple gem written for precisely this use case.
At PostRank we always used God to start/restart our production EventMachine APIs.
I prefer to have a completely external process handling my daemons rather than using something like the daemons library but that's a personnal preference.
You have many solutions out there, here those I know of, all of them will restart your application when it crash more or les quickly and some offer a management interface whether it is a cli or a web interface:
supervisord (http://supervisord.org/): he one I prefer so far
daemontools (http://cr.yp.to/daemontools.html): works well but can be anoying to configure
god as mentionned (http://god.rubyforge.org/): Never used it most for this horrible and cryptic config file syntax
And the last one is whatever comes with your linux distrib, init can run an application and restart it when it dies, you have neary no control over it but it can do the job.
You can type "man inittab" to learn more.

Resources