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
Related
I am new to unit testing (and would really like to learn). I tried pulling down this repository (https://github.com/serbanghita/Mobile-Detect) and have been trying to run their unit tests they already have set up. I have it to the point where phpunit is running but when I run
phpunit tests
from the root directory I get:
Tests: 1411, Assertions: 0, Errors: 1411
I have tried running
phpunit --configuration tests/phpunit.xml
but then I get the error:
Class "JohnKary\PHPUnit\Listener\SpeedTrapListener" does not exist
They have something in their documentation about running:
php phpunit.phar -c tests/phpunit.xml
but I get the error
Could not open input file: phpunit.phar
which is because of the way I have phpunit set up I'm sure...
Any suggestions on how to further trouble shoot this?
It appears you have configured https://github.com/johnkary/phpunit-speedtrap to be used as a test listener in your phpunit.xml but have not (properly) installed this extension.
And if your PHP cannot find phpunit.phar then you are either not pointing it to the correct path or you have not downloaded / installed the PHPUnit PHAR, maybe because you chose to install PHPUnit via Composer. In that case the correct path would be vendor/bin/phpunit, of course.
I'm having trouble getting any of my Polymer Dart tests to run due to the following error that appears after I run pub run test --pub-serve=8081 -p chrome
00:18 +1 -2: compiling test\markdone_test.dart
Failed to load "test\markdone_test.dart": Reflecting on type 'TodoInput' without capability
dart:_internal wrapException
TodoInput is one of the Polymer Dart components for this project, but I've gotten the same error on other projects I have tried testing.
I have followed the documentation on the pub package for dart-lang/test:
Added listorder_test.dart and listorder_test.html with x-dart-test referencing my dart file
Added an entrypoint under the polymer transformer for test/listorder_test.html
Added the test/pub_serve transformer with $include: test/**_test{.*,}.dart
Am I missing some setup step or annotation/metadata? I've been over the docs for testing and they really only have the one mention of testing Polymer components without much else.
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
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
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)