Running Calabash Android from Rubymine - calabash

Can someone post some help. I have tried different config but can't run Calabash Android tests from within Rubymine. Works on Terminal though.

Finally found the solution after some trial and error. Here is what you need to do on Rubymine:
EDIT Runner Options and add: APP_PATH= "" and TEST_APP_PATH="" and run the feature file. This should do it.
Thanks,

Method, suggested by Manpreet Singh, uses cucumber as the test runner. Here you need to define APP_PATH and TEST_APP_PATH environmental variables:
APP_PATH will need to be reset if apk file or file name changes (e.g. uploaded a new version of the apk)
TEST_APP_PATH points to the test server file, which is generated by calabash when you try to connect calabash to your new apk for the first time (e.g. with "calabash-android run" or "calabash-android console"), or if previous test server file was deleted
This way it's easier to create a new test using "Right-click on a scenario or feature file > Create configuration" in RubyMine thanks to its robust cucumber support
Another method is, as pointed by Dave, to set up a calabash-android run as a gem executable - see this thread for details.
Need to set apk path only
This way, your execution is the same as in the command line and passing arguments (such as cucumber profile, output options etc) will work for sure. Also, such configuration is less fragile to the test_server change. However, it's a bit more cobersome to setup than as a cucumber run.
After all with the current architecture of calabash, I still prefer to code in IDE but run in the command line :) IDE becomes very useful, when you need to debug tests.

the setting above does not work for me
here is the setting worked. basically, in Run/Debug configureation, need to create a Gem command to execute calabash-android, and correct arguments, not a configure for Cucumber .
http://daedalus359.wordpress.com/2013/11/02/getting-calabash-to-play-nicely-with-rubymine/
-dave

Related

Vue CLI plugin to add Jest test runner doesn't transpile .js files

Just a quick disclaimer, I cannot reproduce this on another project, which is why I'm here instead of making an issue on the Github.
Issue
So a quick demo project I made to show a co-worker how to use the Vue test utils, went off the wagon. It doesn't get picked up in the transform part of the jest.config.js.
I made the project with the Vue CLI, using vue create demo-project choosing ESlint and Babel, then running vue add #vue/cli-plugin-unit-jest. Everything went fine, I committed, ran the test command and everything went fine.
So we started testing snapshots, and everything was fine. Next day, come back to the project to keep going, and this is the error I get.
> vue-jest#0.1.0 test:unit .../demo-projects/vue-jest
> vue-cli-service test:unit
FAIL tests/unit/example.spec.js
● Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
.../demo-projects/vue-jest/tests/unit/example.spec.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { shallowMount } from '#vue/test-utils';
^
SyntaxError: Unexpected token {
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.163s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
Just running the normal npm run test:unit results in the example.spec.js that comes with the test utils is not babel'ed, and fails in the Node test environment.
Attempted Solutions
Did not work
Deleting node_modules and reinstalling
Deleting package-lock.json, in addition to the above step ( separately done )
Reverting back to the commit when it was working
Checking out to a different branch, deleting all the files that vue add #vue/cli-plugin-unit-jest added, then running the command again to re-create all the files
jest.config.js
tests/ - and all it's files
Worked
Pretty clear what's happening, so in the jest.config.js file, I added the .js file under the transform field.
transform: {
'^.+\\.vue$': 'vue-jest',
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
'^.+\\.(js|jsx)?$': 'babel-jest' // added .js
},
This solution solves the problem, and properly transforms the example.spec.js
Attempted Recreation
I tried to see if this was a bug by creating another project, running the same steps and it worked just fine. I even copied and pasted all the files from the broken one to the new one, looking for differences in git. It was exactly the same. Which is why I thought it might be node_modules, but it still didn't work.
Uhh
Hopefully this isn't a waste of time for anyone reading since it's not truly a problem. I mainly wanted to have it for anyone who might have the same issue to see that adding the .js extension would solve the problem without having to start over, but also curious if anyone has insight on why this might be happening?

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.

AndroidStudio 3.2 test configuration does not work

After migrating to AS 3.2 android JUnit test run configuration does not work, all types "All in directory",
"All in package" etc.
I mean it does work, but always claims that:
0 test classes found in package '<default package>'
Process finished with exit code 254
Empty test suite.
using ./gradlew test triggers every test
and every single test can be run by AS using that green play button inside editor (for class or single method)
but not for package, module etc.
How to fix that ?
many thanks
Wojtek
Declare your test classes as public
Fixed in Android Studio 3.2.1
So just update AS to newest version and the problem disappears

Headless testing with JavaFx and TestFx

I have a simple JavaFx application (Java 8) that has a unit test using TestFx. However, when the test is run, the application window starts up and the mouse is moved to do whatever action is in my test. Can these tests be run in a way where the application doesn't popup and I can still use my mouse for other things as the automated build and tests are running?
Update:
I found this blog post that provides the solution for me to this problem. As the author suggests, you need to add the following dependency to your build:
testRuntime 'org.testfx:openjfx-monocle:1.8.0_20'
Then you will need to include the following somewhere before you call registerPrimaryStage(), in my case in a method marked with #BeforeClass as I am using JUnit:
System.setProperty("testfx.robot", "glass");
System.setProperty("testfx.headless", "true");
System.setProperty("prism.order", "sw");
System.setProperty("prism.text", "t2k");
I would also add that its useful to include System.setProperty("java.awt.headless", "true") to ensure that you're not relying on anything from the AWT (in my case I had a call to get the size of the screen that was causing problems). I also followed the blog author's advice to add a switch to turn headless mode on and off. This gives the final method as follows:
#BeforeClass
public static void setupSpec() throws Exception {
if (Boolean.getBoolean("headless")) {
System.setProperty("testfx.robot", "glass");
System.setProperty("testfx.headless", "true");
System.setProperty("prism.order", "sw");
System.setProperty("prism.text", "t2k");
System.setProperty("java.awt.headless", "true");
}
registerPrimaryStage();
}
You can see the solution in context here
Original Answer:
If you're using Linux, you can use xvfb for this. On a Debian-based system you can install xvfb as follows:
$ sudo apt-get install xvfb
With xvfb installed, run the following before you run your tests:
$ Xvfb :99 &>/dev/null &
$ export DISPLAY=:99
If you launch your tests in the same console TestFX will use the frame buffer instead of your main display. Thus the tests will run but you won't be bothered with windows opening and the mouse pointer being moved around.
I would agree with KDK for using Monocle, since it does work as charm with Jenkins. I couldn't have reliable result from Xvfb on Jenkins. Below is the steps I took and works for me.
Prepare Monocle
You want to download Monocle from Monocle Github. It looks there is api change, so you would want to edit MonocleView.java with adding below method after download. I'm not sure what I should put in the method, but found it just works without implementing it.
#Override
protected int _getNativeFrameBuffer(long ptr) {
// TODO Auto-generated method stub
return 0;
}
Install Monocle
Build the Monocle jar and put the jar into your JRE (under jre/lib/ext path)
Run Monocle with Glass lib
Below is my maven command used in jenkins, you will have interest on java runtime option portion.
$ mvn clean install -Dtestfx.robot=glass -Dglass.platform=Monocle -Dmonocle.platform=Headless -Dprism.order=sw
Yes, it is possible to perform headless testing of JavaFx2 applications.
You will need Monocle(part of OpenJFX). More details here:
https://github.com/TestFX/Monocle

Running unit tests in Pydev

I am trying to run unit tests in Pydev using IronPython.
When I try to run a test with Ctrl+F9 the following error message shows up in the Eclipse console window:
AttributeError: 'module' object has no attribute '_getframe'
I figured out that I have to invoke the IronPython interpreter with the '-X:Frames' argument.
Setting up the arguments in the 'Arguments' tab under 'Run->Run Configurations...' doesn't work. They seem to disappear everytime I run (Ctrl+F9) and choose another test.
Clicking 'Run->Run As->Iron Python unit-test' shows up more and more options to choose from.
Is Eclipse/Pydev creating new run configurations everytime I run a different set of tests? How can I permanently pass the '-X:Frames' argument, so my tests will run under IronPython?
(In Python the tests run without any problem.)
This shouldn't really be needed... I've just fixed the PyDev unittest runner so that it works properly (just pushed a new nightly build with that fix included -- if you're in Aptana Studio 3, a nightly is still not available, but you can patch your own version by applying the changes from the commit locally, as they're all changes in Python code: https://github.com/aptana/Pydev/commit/d5d262dbcd0c126ec0ec37e116ff79575c5dd6d8)