PHPStorm 8 + PHPUnit 4.2.6 Error - phpunit

I can't make PHPUnit 4.2.6 to work with PHPStorm 8.
PHPUnit is loaded as phar inside PHPStorm 8 settings.
Whenever i try to run unit test in PHPStorm i get this error:
Parse error: syntax error, unexpected '}' in /private/var/folders/qh/xjz1kr297v34pl6zy70_2rl00000gn/T/ide-phpunit.php(171) : eval()'d code on line 1
Call Stack:
0.0006 344584 1. {main}() /private/var/folders/qh/xjz1kr297v34pl6zy70_2rl00000gn/T/ide-phpunit.php:0
0.0007 344880 2. IDE_PHPUnit_Loader::init() /private/var/folders/qh/xjz1kr297v34pl6zy70_2rl00000gn/T/ide-phpunit.php:194
Warning: require_once(PHPUnit/Runner/Version.php): failed to open stream: No such file or directory in /private/var/folders/qh/xjz1kr297v34pl6zy70_2rl00000gn/T/ide-phpunit.php on line 49
When i looked into "ide-phpunit.php", i found that it tries to eval invalid code, because of invalid "substr" function usage.
So my question is, if someone managed to make PHPUnit 4.2.6 work with PHPStorm 8?

Here is how to "unhack" the IDE to run with phpnunit.phar (4x+) nicely on windows and linux!
Download phpunit.phar under php, set your phar location from the IDE -> settings -> phpunit and phar location. THEN CLOSE IDE
Find where your plugin files are, for php on windows this would be :\Program Files (x86)\JetBrains\PhpStorm 8.0.3\plugins\php\lib.
Open php.jar with winrar and open scripts/phpunit.php.
Comment out all PHPUnit/… require statements, so autoloader can do its job instead of using hardcoded values.
Go to public static function init() method.
Find the if section with a comment at the end says “awful hack”, screenshot.
Remove all the amateur hacky stuff and replace it with this, screenshot.
Save the file, Winrar will prompt you to save the archive, SAVE that one too.
Run IDE And Run your tests, coverage. Enjoy!
Hope this helps some of you out there. I will post the information to their forums as well.

I got the exact same error, and fixed it like this:
Installed phpunit using: composer global require phpunit/phpunit
Goto phpstorm settings: PHPUnit
Select "Use custom autoloader"
On Windows: C:\Users\[username]\AppData\Roaming\Composer\vendor\autoload.php
On Linux: /home/[username]/.composer/vendor/autoload.php
Or point it to the autoloader of your composer project

PhpStorm generates special temporary "wrapping" to execute the tests and get the output in the form it understands better. In your case it's /private/var/folders/qh/xjz1kr297v34pl6zy70_2rl00000gn/T/ide-phpunit.php. Since the error says there is a syntax error, the first thing you should try is deleting it, on the next run the IDE will create the new one, hopefully without that problem.
If that doesn't help, as suggested in the comments, try downgrading the PHPUnit a few versions back, see if that helps. Alternatively try reinstalling the PhpStorm. If that doesn't work, you have better chances of finding an answer by reporting an issue to the dev team.

Related

RobotFramework RIDE cannot import library

I have a file right here: Library ../../MyLib/My_Lib.py, and I try to import the python file in RIDE, but RIDE still report "FAIL : No keyword with name '****' found", and this keyword is defined in the My_Lib.py, seems RIDE cannot find the python file.
I using python 2.7.8+Robot Framework 3.1.2+windows server 2012r2. I even selected Library -> Name -> Browse in RIDE, but the error still there and this whole robot test case folder is copied from another server which is working fine
Can anyone suggest what have I missed?
Ah! I have worked this out, if anyone else meets the same issue, you can click Tools->view RIDE Log, to see what's happening there. For my case, it's because I didn't install thrift but the My_Lib.py obviously used thrift module, so the My_Lib.py compile failed with "No module named thrift.Thrift".
Is it possible the Python library was created to work with Python 3.x.x leading it to not work on your Python 2.7.8? See https://wiki.python.org/moin/Python2orPython3
Check what python version is being run on the other server where the test is running fine. You might need to update your local Python version.
Also, you could try running the Robot test outside of RIDE just in case. You may do so by navigating to the test folder where the .robot file resides and running the following command:
robot test_file_name.robot
See if you get the same error that way. Please report back after doing the mentioned checks and we can continue debugging, my reputation doesn't let me comment on your question so I will just update the answer as we go along.

TypeScript compiler failing on a mac

Typescript compilation task works fine on linux machines but on a mac fails with the following not particularly useful error message and what looks like a binary dump.
$ grunt
Running "ts:build" (ts) task
Compiling...
Fast compile will not work when --out is specified. Ignoring fast compilation
Using tsc v1.4.1
������������=��AF���=����
>> Error: tsc return code: 3
Warning: Task "ts:build" failed. Use --force to continue.
Aborted due to warnings.
Im using nvm with node v0.11.4 and rvm with ruby v2.2.0.
Any ideas how to fix this, or even debug?
As the question includes debugging, here are some pointers which might help determine where the problem is.
Try compiling from the command line with tsc alone (no grunt), in case the problem is with grunt or the ts:build task (looks like grunt-ts).
Maybe one of your source files is causing the tools to crash (perhaps they can't cope with a file's encoding?). If a single, simple file will compile, then try removing subsets of your source from the build. If some of those files are causing the crash (whether valid TypeScript or not) you may be able to find a temporary workaround.
Try compiling with different versions of tsc. If you need 1.4.1 features you could try using the latest from https://github.com/Microsoft/TypeScript (see here for how to do this with grunt-ts).
The problem was with a malfunctioning node installation. I upgraded to node 0.12 which fixed the problem.
Just to check the problem wasn't node 0.11.4 specific I removed all previous versions of node and reinstalled 0.11.4 and the error no longer occurs.
I took these steps after removing all node modules, clearing the cache and reinstalling with no luck. I also tried using multiple typescript compiler versions.

adobe brackets-shell : cef extract failed

I followed all the step is mention in given below url to build my project( I am using win7 OS).
https://github.com/adobe/brackets-shell/wiki/Building-brackets-shell.
actullly i want to create brackets installer (installed wix 3.7).
but i am getting cef-extract failed error.
even though i also used grunt cef-extract --force.
after that its throunging new error.
create -project failed after that i am not able to process further.
can some one help me.
thanks in advanced.
Regards
ashish .
If you include the exact console output you're seeing, it would be much easier to help you. But based on snags other people have encountered recently, you can try these things:
Make sure your PATH includes Python 2.7 (otherwise "create-project" will fail).
Delete all these folders to be sure you're starting from a clean slate: deps, Debug, include, libcef_dll, Release, Resources.
Just run the high-level tasks grunt setup and grunt build, following the Building brackets-shell instructions. (There's a known bug where grunt cef-extract fails when run standalone).

How to run PHPUnit Test from another directory

I have a very straightforward PHPUnit test in c:\kim\test\HelloTest.php on a Windows PC. I can execute it from within the c:\kim\test directory with the command:
phpunit HelloTest
The problem is that I can't execute it from any other directory.
As far as I know I should be able to execute this from the c:\kim directory with:
phpunit test
Also, I would have thought the following syntax would work too:
phpunit c:\kim\test
But I don't get any response from the command. Simply a blank line and then I am returned to the cursor.
I am trying to get unit tests working properly with Netbeans and I think I need to solve this problem first. Perhaps it has something to do with paths? Any ideas?
I spent quite a while trying to sort this out, per the comments above. Also tried reinstalling PHPUnit. In the end I ran up a new server, installed XAMPP, and all works fine.
If any help.
I am using makegood extension for eclipse which handle phpunit test execution with one click.
Maybe you can find similar extension for Netbeans or switch to eclipse

phpunit (install) error

i have tried installing phpunit the install itself seems fine.
i can run "phpunit" but when i try to run a test "phpunit test.php" i get
'""C:\Program' is not recognized as an internal or external command,
operable program or batch file.
PHPUnit 3.3.17 by Sebastian Bergmann.
..
Time: 0 seconds
OK (2 tests, 2 assertions)
so as u can see, phpunit runs but with something wierd 1st. and in netbeans, i get "'""C:\Program' is not recognized as an internal or external command,
operable program or batch file." and it stops
When you installed PHPUnit, it made a phpunit.bat file in your PHP installation directory. For example, mine was at C:\PHP\phpunit.bat.
Open up that file in Notepad. At the bottom you'll see a line that looks something like
set PHPBIN=".\php.exe"
Edit that to a correct absolute path, such as
set PHPBIN="C:\php.exe"
If the path has a space in it, you need to escape it with double quotes, such as
set PHPBIN="""C:\some long path\php.exe"""
Hope that helps.
I had same problem and when run this command in:
phpunit -v
I saw following error :
'pupunit' is not recognized as an internal or external command,
operable program or batch file.
I copy the phpunit.bat in system32 folder( C:\Windows\System32 ) and it work.
This is a bug in PHPUnit. It was fixed in version 3.4.
Just upgrade to the newest version:
pear channel-update
pear install phpunit/PHPunit
and it should work correctly.
This looks like a DOS 8.3 notation error.
You should change the path-name in phpunit.bat to the shorthand notation.
You can find this notation by browsing in the DOS-prompt with the following command:
dir /o:e /p /x
(Or use the double quotes like Nicholas mentioned)
Here "C:\program.." is the issue. While running phpunit, it is not able to recognize it.
So You can refer the link Installing PHPUnit On Windows for cross checking PHPUnit installation.
It should help you.

Resources