I am using Selenium locally to run two .feature files. Both pass locally. Neither of the tests interact with a db (nor will future tests). I would like to use the parallel_tests gem to spin up two selenium web browsers concurrently and run each .feature file. I have tried to follow the readme on gems homepage, but am still having no luck.
I can run rake parallel:features and I get the following output:
Using recorded test runtime
8 processes for 2 features, ~ 0 features per process
However, it then proceeds to fail immediately and informs me that I have not defined the scenarios.
I am using Rails 3.2 and Capybara
I have also tried adding begin; require 'parallel_tests/tasks'; rescue LoadError; end
to the top of my Rakefile which I found elsewhere, but doesn't help.
Try using:
parallel_cucumber -n 2 features
Related
Working for a large company, we are using the parallel_tests gem to run our cucumber automation. This works well for our Ruby divisions, but for our Jruby folk we need another option. The issue is that Jruby (as of 1.7) fork spawns a new java JVM without the JVM options. I have figured out that I need 1 of 2 solutions and I'm not exactly sure how to implement either of them.
We need to be able to pass the JVM options into fork so we can get all the options we need.
or
We need to change how the gem handles forking so the processes all run on the same JVM
I don't know if either of these solutions are a possibility, but maybe someone else will know better
According to a solution posted at Alternative for spawning a process with 'fork' in jRuby?
I found out the solution for this. We can use the built-in library FFI in JRuby to 'simulate' the Process.fork in MRI.
To mimic the Process.fork in MRI Ruby
module JRubyProcess
require 'ffi'
extend FFI::Library
ffi_lib FFI::Library::LIBC
attach_function :fork, [], :int
end
pid = JRubyProcess.fork do
#do_your_work
end
More details:
https://github.com/ffi/ffi
http://blog.headius.com/2008/10/ffi-for-ruby-now-available.html
another option was to use spoon:
https://github.com/headius/spoon
I am no linux guru, but these seem like simple ways to implement Jruby. Does anyone know if this is an effective solution?
I don't think there is any safe way you can fork the jvm like you can ruby. There is a gem called childprocess that provides cross platform process managemant.
I've created a gem called jcukeforker that can run both features and scenarios in parrellel in jruby.
Feel free to submit an issue or a pull request for setting environment variables on the subprocesses. This is only relevant if you want the subprocess to have different environment variables than the parent process.
I am trying to set up two specific PHPUnit test environments for Symfony2.
I am using Ant to run PHPUnit, so when I run the two commands below I would expect the following results:
ant test
Runs the test suite using MySQL databse. (matching staging and production envs)
ant ramdisk
Runs the test suite using a SQLite ramdisk. (super fast!)
I can figure out how to set up the MySQL & SQLite for PHPUnit individually, quite easily.
How do I get PHPUnit to specify a particular environment to use?
Our base class for testing sets up the environment, but I cannot figure out how to get a argument passed into here from PHPUnit so that I can conditionally set the environment.
I have tried a different bootstrap for ramdisk, but since the base test class sets the environment I could not make much progress.
Any ideas?
I eventually solved this.
PHPUnit can pass variables through to Symfony: http://phpunit.de/manual/3.7/en/appendixes.configuration.html#appendixes.configuration.php-ini-constants-variables
Anyone know any particular reason why a request spec never passes when run with bundle exec rspec spec but passes when run directly bundle exec rspec spec/requests/models_spec.rb?
I have tried the spec in both selenium and poltergeist but get the same result. When I run the whole test suite the specs fail, when I run it individually it passes.
I have a related question concerning a model spec Why would RSpec report multiple validation errors of the same type? that could possibly be related.
Interesting but simple. Threads seems to have gotten intertwined and a button that should be saying Add was saying Manage. Temporary fix was to just delete everything from the database before running each spec.
I have two apps. One is a very simple app that I built with rails new..., added a unit test to and ran the unit test. The other is an existing app that is running fine but I'd like to add some tests to it. In AppA (the simple one) when I run rake -vT I see:
...
rake test # Runs test:units, test:functionals, test:integrati...
rake test:recent # Run tests for {:recent=>"test:prepare"} / Test re...
rake test:single # Run tests for {:single=>"test:prepare"}
rake test:uncommitted # Run tests for {:uncommitted=>"test:prepare"} / Te...
...
Which seems normal. But when I run that same command in AppB (the existing app) I don't see any of the commands related to rake test. My first thought was to just 'bring over' the tests from AppA to AppB to see if that would help. So I wiped all content from the test directory in AppB and copied over the test directory from AppA. Still no rake test in the list of apps. But I can run a unit test in AppB via ruby -Itest test/unit/first_test.rb (oddly I have to comment out fixtures :all to get it to work, maybe that's a clue).
Found the answer to this last night. Where a new app's application.rb has:
require 'rails/all'
I had:
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
I did that because I was following a guide about MongoMapper I think. Go forward a few versions and the last line is commented out -- that's the real reason. I commented it out at the same time I switched my ODM over to Mongoid. I'm not sure why I commented it out, but that definitely did it.
Without knowing the contents of your Rakefile it's really hard to debug this, but you might be missing the .load_tasks call in the Rakefile.
If you're using Rails 3 you should have something like this:
MyApplication::Application.load_tasks
That line will take care of loading the default Rails tasks. You might be able to accomplish the same calling require "rails/tasks" in your Rakefile.
The rails command-line command provides a couple of commands, like rails generate, rails console etc. Now I'd like write a gem which registers my own command for use with rails mycommand.
Is this possible?
If so, any guides on how to do that?
NB: This is for rails 3+
regards, apeiros
Haven't done it, but here are some leads. In your Rails app, the script directory holds a file called 'rails' that has this line
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
It then requires this Rails file: https://github.com/rails/rails/blob/master/railties/lib/rails/commands.rb