Can't start test server on physical device - calabash

I installed calabash on a new machine, but tests that I ran on my old machine will not run.
As far as I can tell, both machines are set up the same way. They pull the project from the same repository, which includes a Gemfile with calabash-cucumber version 0.18.0. I set the same BUNDLE_ID, DEVICE_ENDPOINT, and DEVICE_TARGET values and use the same physical device.
When I try to run the tests in the console on the new machine, I get this:
$ bundle exec calabash-ios console
Running irb...
irb(main):001:0> start_test_server_in_background
ArgumentError: Could not find a device with a UDID or name matching 'com.my.apps.bundle.id'
from /Users/rjones/gambit/gemstubs/ruby/2.1.0/gems/run_loop-2.1.1/lib/run_loop/device.rb:126:in `device_with_identifier'
from /Users/rjones/gambit/gemstubs/ruby/2.1.0/gems/run_loop-2.1.1/lib/run_loop/device.rb:160:in `detect_device'
from /Users/rjones/gambit/gemstubs/ruby/2.1.0/gems/run_loop-2.1.1/lib/run_loop/core.rb:71:in `run_with_options'
from /Users/rjones/gambit/gemstubs/ruby/2.1.0/gems/run_loop-2.1.1/lib/run_loop.rb:134:in `run'
from /Users/rjones/gambit/gemstubs/ruby/2.1.0/gems/calabash-cucumber-0.18.0/lib/calabash-cucumber/launcher.rb:718:in `block in new_run_loop'
from /Users/rjones/gambit/gemstubs/ruby/2.1.0/gems/calabash-cucumber-0.18.0/lib/calabash-cucumber/launcher.rb:716:in `times'
from /Users/rjones/gambit/gemstubs/ruby/2.1.0/gems/calabash-cucumber-0.18.0/lib/calabash-cucumber/launcher.rb:716:in `new_run_loop'
from /Users/rjones/gambit/gemstubs/ruby/2.1.0/gems/calabash-cucumber-0.18.0/lib/calabash-cucumber/launcher.rb:584:in `relaunch'
from /Users/rjones/gambit/gemstubs/ruby/2.1.0/gems/calabash-cucumber-0.18.0/lib/calabash-cucumber/core.rb:943:in `start_test_server_in_background'
from (irb):1
from /Users/rjones/.rbenv/versions/2.1.5/bin/irb:11:in `<main>'
Any ideas why this isn't working?

Please update to 0.19.0.
Can you also paste the exact command you are using to start the
irb(main):001:0> start_test_server_in_background
ArgumentError: Could not find a device with a UDID or name matching
'com.my.apps.bundle.id'
It looks like you set your DEVICE_TARGET to the bundle id? If not, then you have found a bug. It is possible that 0.18.0 is not compatible with run-loop 2.1.1. Downgrade to run_loop 2.0.9 if you want to verify that this is the problem.

I experienced the same issue, when updating cucumber gem from version 1.3.19 to version 2.3.3. I also run tests on physical devices
edit: Sorry, forgot to mention, that I updated run_loop too from version 2.0.6 to 2.1.3
So the versions:
run_loop (2.1.3)
calabash-cucumber (0.18.1)
I guess these are the two that could affect this part, and cucumber was not involved
I found a solution, by setting the variable DEVICE instead of DEVICE_TARGET
For example:
BUNDLE_ID=<bundle_id> DEVICE=<dev_udid> DEVICE_ENDPOINT=<dev_ip> cucumber
Instead of
BUNDLE_ID=<bundle_id> DEVICE_TARGET=<dev_udid> DEVICE_ENDPOINT=<dev_ip> cucumber

Related

Pabot - Unable to run parallel robotframework tests

So, I'm working on a robotframework test project, and the goal is to run several test suites in parallel. For this purpose, pabot was chosen as the solution. I am trying to implement it, but with little success.
My issue is: after installing Pabot (which, I might say, I did by cloning the project and running "setup.py install", instead of using pip, since the corporate proxy I'm behind has proven an obstacle I can't overcome), I created a new directory in the project tree, moved some suites there, and ran:
pabot --processes 2 --outputdir pabot_results Login*.robot
Doing so results in the following error message:
2018-10-10 10:27:30.449000 [PID:9676] [0] EXECUTING Suites.LoginAdmin
2018-10-10 10:27:30.449000 PID:400 EXECUTING Suites.LoginUser
2018-10-10 10:27:30.777000 PID:400 FAILED Suites.LoginUser
2018-10-10 10:27:30.777000 [PID:9676] [0] FAILED Suites.LoginAdmin
WARN: No output files in "pabot_results\pabot_results"
Output:
[ ERROR ] Reading XML source '' failed: invalid mode ('rb') or filename
Try --help for usage information.
Elapsed time: 0 minutes 0.578 seconds
Upon inspecting the stderr file that was generated, I have this message:
Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\robotframework-3.1a2.dev1-py2.7.egg\robot\running\runner.py", line 22, in
from .context import EXECUTION_CONTEXTS
ValueError: Attempted relative import in non-package
Apparently, this has to do with something from the runner.py script, which, if I'm not mistaken, came with the installation of robotframework. Since manually modifying that script does not seem to me the optimal solution, my question is, what am I missing here? Did I forget to do anything while setting this up? Or is this an issue of compatibility between versions?
This project is using Maven as the tool to manage dependencies. The version I am running is 3.5.4. I am using a Windows 10, 64bit system; I have Python 2.7.14, and Robot Framework 3.1a2.dev1. The Pabot version is 0.44. Obviously, I added C:\Python27 and C:\Python27\Scripts to the PATH environment variable.
Edit: I am also using robotframework-maven-plugin version 1.4.0.8, if that happens to be relevant.
Edit 2: added the error messages in text format.
I believe I've come across an issue similar when setting up parallel execution on my machine. Firstly I would confirm that pabot is installed using pip show robotframework-pabot.
Then you should define the directory your results are going to using -d.
I then modified the name of the -o to Output.xml to make it easy to identify.
This is a copy of the code I use. Runs optimally with 8 processes
pabot --processes 8 -d results -o Output.xml Tests
Seems that you stumbled on a bug in the prerelease version of robot framework (3.1a2.dev1).
Please install a release version of robot framework. For example 3.0.4.
Just in case anyone happens to stumble upon this issue in the future:
Since I can't use pip, and I tried a good deal of workarounds that eventually made things more unstable, I ended up saving my project and removing everything Python-related from my system, so as to allow me to install everything from scratch. In a Windows 10, 64bit system, I used:
Python 2.7.14
wxPython 2.8.12.1, win64, unicode, for py27
setuptools 40.2.0 (to allow me to use the easy_install command)
Robot Framework 3.0.4
robotremoteserver 1.1
Selenium2Library 3.0.0
and Pabot version 0.45.
I might add that, when installing the Selenium2Library the way I described above, it eventually tries to download some things from the pip repositories - which, if you have a proxy, will cause you trouble. I solved this problem by browsing https://pypi.org/simple/selenium/, manually downloading the 2.53.6 .tar.gz file, then extracting it and running setup.py install on the command line.
PS: Ideally, though, anyone should be able to use proxy settings from the command line (--proxy http://user:password#server:port) to get pip and then use it; however, for some reason, probably related to network security configurations that I didn't want to lose time with, this didn't work in my case.

RSpec 3, capybara 2.3.0, Guard 2.6.1, Rails 4.1.1 uninitialized constant (NameError)

I've recently had to migrate a project from rails 4.0 to rails 4.1 and in the process I've also updated RSpec to RSpec (3.0.0).
The project previously had the following in certain feature specs being tested with Capybara:
require 'spec_helper' require 'support/integration_helpers.rb'
require 'support/admin_support/admin_user_creation_helpers.rb'
include BuildDefaults
The include BuildDefaults refers to a module spec/support/build_defaults.rb and has various helper methods to ensure that the database has been populated correctly. For some reason this has now stopped working and gives the following error (and stack trace):
path_to/spec/features/admin_features/admin_login_out_spec.rb:4:in
<top (required)>': uninitialized constant BuildDefaults (NameError)
from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in
block in load_spec_files' from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in
each' from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in
load_spec_files' from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:97:in setup' from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:85:inrun' from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:70:in run' from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:38:ininvoke' from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/exe/rspec:4:in
<top (required)>' from
/Users/u_name/Documents/rails/work/c_central_4.1.1/gemset_name/bin/rspec:7:in
' from
/Users/u_name/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
require' from
/Users/u_name/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
require' from -e:1:in `'
Would anybody happen to know why this has happened?
I would greatly appreciate any help on the matter.
I have looked at various other SO questions with a similar title as this one but none of them seem to be relevant.
Side note 1
It is worth noting that I have removed Spork from my test environment as it was not playing nicely for some reasons but have instead configured the project to use Spring. Though I don't think that this has anything to do with the issue, I did have to completely rebuild the test environment (running rails g rspec:install for instance) and then used Transpec to update the Rspec syntax.
Having spent some time looking around for a solution to this I eventually came across the official upgrade documentation (I know, I know).
As it says in the docs,
Default helper files created in RSpec 3.x have changed
In prior versions, only a single spec_helper.rb file was generated. This file
has been moved to rails_helper.rb. The new spec_helper.rb is the same
standard helper generated by running rspec --init.
This change was made to accomplish two general goals:
Keep the installation process in sync with regular RSpec changes
Provide an out-of-the-box way to avoid loading Rails for those specs
that do not require it
This second point got me thinking about the fact that a feature spec for capybara would need to load the application stack. As such, by loading the rails_helper.rb instead of the spec_helper.rb the spec/support/build_defaults.rb is now included in the load path.
Hope this helps somebody in the future.

Install ruby-opengl 0.60.1 on Ubuntu? ...in order to add 'gl', 'glu', and 'glut' extensions

How does one install ruby-opengl-0.60.1 on Ubuntu?
I keep trying
$ gem install ruby-opengl --version 0.60.1
and I am running into the following error:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
ERROR: 'rake/gempackagetask' is obsolete and no longer supported. Use
'rubygems/package_task' instead.
/home/matias/.rvm/gems/ruby-1.9.3-p362#sampleGemset/gems/ruby-opengl-0.60.1/
Rakefile:24:in `<top (required)>'
Perhaps I could manually change the "package task" parameter in the Rakefile
and then attempt a local gem install?...
I have found the following urls where the package can be downloaded for manual installation:
rubyforge.org/frs/?group_id=2103
launchpad.net/ubuntu/+source/ruby-opengl/0.60.1+dfsg1-2
And the following appears to be a patch or a small modification:
gist.github.com/tociyuki/2479308
I tried downloading the gem from the launchpad url, and then I tried
$ gem install ruby-opengl-0.60.1.gem
from the Downloads folder, and it gave me a ton of errors.
I eventually tried:
$ sudo apt-get install libopengl-ruby
which seemed to work, and now when I do:
$ gem list -r ruby-opengl
I get:
\*** REMOTE GEMS \***
ruby-opengl (0.61.0, 0.60.0 i386-mswin32)
ruby-opengl2 (0.60.6)
I believe that i386-mswin32 is version 0.60.1 for windows.
With this configuration, I try running Sapphire.rb and it still doesn't work.
I already have ruby-opengl versions 0.60.0 and 0.61.0 installed, but I need 0.60.1 because it creates the 'gl', 'glu', and 'glut' extensions which are required in order to run some .rb files which I have copied from other people. These .rb files are video games created with the Gosu gem.
This is for use specifically with the Gosu gem. Even more specifically, I am trying to run the Sapphire game (github.com/KoBeWi/Sapphire), which also requires the Texplay gem.
Or is there another way to activate the 'gl', 'glu', and 'glut' extensions?
Thanks to the nice people at libgosu for providing the answer:
$ gem install opengl --pre
took care of everything! Now if someone else runs into this
same difficulty, the answer is here!

Unable to "run" on Heroku

I have deployed a Clojure app to Heroku. When I run/request it I get an error: http://glowing-planet-168.herokuapp.com/. So now I want to start up a REPL to see if I can get some more info. But when I try it I get:
D:\Mijn documenten\My Dropbox\dev\clojure-projects\hebrewajax>heroku run lein repl
C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/heroku-2.2.4/lib/heroku/helpe
rs.rb:213:in ``': No such file or directory - tput cols (Errno::ENOENT)
from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/heroku-2.2.4/lib
/heroku/helpers.rb:213:in `get_terminal_environment'
from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/heroku-2.2.4/lib
/heroku/command/run.rb:16:in `index'
from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/heroku-2.2.4/lib
/heroku/command.rb:114:in `send'
from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/heroku-2.2.4/lib
/heroku/command.rb:114:in `run'
from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/heroku-2.2.4/bin
/heroku:14
from C:/RailsInstaller/Ruby1.8.7/bin/heroku:19:in `load'
from C:/RailsInstaller/Ruby1.8.7/bin/heroku:19
I get the same error when I do 'heroku run console'. I installed heroku using RailsInstaller.
I am running on Windows XP.
What could go wrong here? Some gem I have to installe besides heroku?
I don't have experience with heroku or Windows, but it looks like you're missing the shell command 'tput', which is (in this case) used to get the width of your terminal window. If I understand correctly, you need to have Cygwin installed, which might have been installed with RailsInstaller. You might also need to install the 'ncurses' package which has the tput utility. Good luck!

Given a typical Rails 3 environment, why am I unable to execute any tests?

I'm working on writing simple unit tests for a Rails 3 project, but I'm unable to actually execute any tests.
Case in point, attempting to run the test auto-generated by Rails fails:
require 'test_helper'
class UserTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
Results in the following error:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load --
test_helper (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from user_test.rb:1:in `<main>'
Commenting out the require 'test_helper' line and attempting to run the test results in this error:
user_test.rb:3:in `<main>': uninitialized constant Object::ActiveSupport (NameError)
The action pack gems appear to be properly installed and up to date:
actionmailer (3.0.3, 2.3.5)
actionpack (3.0.3, 2.3.5)
activemodel (3.0.3)
activerecord (3.0.3, 2.3.5)
activeresource (3.0.3, 2.3.5)
activesupport (3.0.3, 2.3.5)
Ruby is at 1.9.2p0 and Rails is at 3.0.3.
The sample dump of my test directory is as follows:
/fixtures
/functional
/integration
/performance
/unit
-- /helpers
-- user_helper_test.rb
-- user_test.rb
test_helper.rb
I've never seen this problem before - I've run the typical rake tasks for preparing the test environment. I have nothing out of the ordinary in my application or environment configuration files, nor have I installed any unusual gems that would interfere with the test environment.
Edit March 9th
Xavier Holt's suggestion, explicitly specifying the path to the test_helper worked; however, this revealed an issue with ActiveSupport.
Now when I attempt to run the test, I receive the following error message (as also listed above):
user_test.rb:3:in `<main>': uninitialized constant Object::ActiveSupport (NameError)
But as you can see above, Action Pack is all installed and update to date.
Edit March 13th
When attempting to run tests using rake test:units the following stack trace is dumped to the console:
test/unit/bookmark_test.rb:3:in `<top (required)>': uninitialized constant Objec
t::ActiveSupport (NameError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `block in <main>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `<main>'
rake aborted!
So looking into the file listed above, I see the following:
#!/usr/bin/env ruby
# Load the test files from the command line.
ARGV.each { |f| load f unless f =~ /^-/ }
To my knowledge, everything looks as expected.
Your test/test_helper file should have been created when you generated the application. It contains this valuable content:
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
end
The second line here is the most important: it requires the config/environment.rb file at the root of your application, which in turn requires a lot of other things, including the valuable (I like that word today, ok?) ActiveSupport constant.
When you generate a controller, model or scaffold it'll also generate tests for those. I just ran rails g scaffold ticket in my app and it generated test/unit/ticket_test.rb which contains this:
require 'test_helper'
class TicketTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
The first line of this file will require the test/test_helper.rb file that we jut saw. This will load ActiveSupport and the TestCase class within it, thereby making this test feasible. Everything else just flows on from there.
With all that explanation out of the way (even though it's something that you already know), I'm placing a large wager on it's something that's masscaring your LOAD_PATH, causing the test directory to be removed from it.
What's really unusual is that when you do specify the full path to the test/test_helper.rb you're saying it loads it, but ActiveSupport is still undefined. Well, that should be loaded as-per the description above. Is it actually loading config/environment.rb? Can you put something such as:
puts "LOADING CONFIG/ENVIRONMENT.RB"
At the top of your config/environment.rb file and then run the tests again? It should be output. Very unusual.
Continuing on the thread about LOAD_PATH... Got a dirty little secret you're not telling us about?
Actually, Dan Cheail makes a good point. You could be running the tests using ruby test/unit/ticket_test.rb in which case test_helper wouldn't be available, but still that still doesn't explain why when you specify the full path you're still getting an undefined constant ActiveSupport.
If you want to run a single test you should be doing this:
ruby -Itest test/unit/ticket_test.rb
That -I option there adds the test directory to the load path, meaning the test_helper file will be available through a straight require 'test_helper'. If it still errors after this, I reckon your test/test_helper.rb is either empty or broken.
The problem you're having is the way you're executing tests. Simply calling ruby test/unit/user_test.rb doesn't set up the load path, which explains the problems you've been having.
rake test:units is what you want and should work straight away.
Sorry about the post here, but I am unable to comment on questions yet.
what environment are you running, Win (has an issue with a .gemspec file) Linux, Mac?
Are you using RVM?
Test-Unit is installed by default with Rails, if you installed the gem Test-Unit you will get a conflict between the 2. try uninstalling the gem and your tests should start working.
If running on windows I would gem uninstall "autotest", then navigate to the following dir
drive:\Ruby192\lib\ruby\gems\1.9.1\specifications
In here you will find .gemspec files. Ensure that you dont have 2 autotest.gemspec files or any, for that matter. if so remove(delete) them, then download and gem install the autotest gem again. Grab the latest by using version switch.
You should be able to run your autotests. I did come across this once before, so to fix I simply removed the view and helper test files and wrote everything in the standard test file. Other than that I know running on windows autotest had issues, because of the ruby installer and bundler not clearing out things correctly and forgetting files.
I will find the link for you, to better explain.