renandelmonico / vscode-phpunit Goto Github PK
View Code? Open in Web Editor NEWThis project forked from recca0120/vscode-phpunit
The VS Code Test Explorer extension for PHPUnit
This project forked from recca0120/vscode-phpunit
The VS Code Test Explorer extension for PHPUnit
Hey
Thanks for continuing the development of the original extension!
Just wanted to let you know that the issue reported in recca0120#104 is still a problem in this version here.
I run PHPUnit in Docker (I develop on Windows), with these settings:
Workspace settings:
"phpunit.php": "",
"phpunit.phpunit": "C:\\node\\npm.cmd",
"phpunit.args": ["run", "build-runtests", "--"],
"phpunit.relativeFilePath": true,
"phpunit.remoteCwd": "/opt/app/",
"phpunit.files": "myapp/tests/*Test.php",
packages.json:
"build-runtests": "gulp build-debug && docker-compose run --rm --entrypoint 'php' myapp /opt/app/myapp/tests/run_phpunit.php",
My run_phpunit.php
basically runs the test(s), prints the output, and returns a proper return code (would be "1" if tests fail).
I confirm that it's definitely returning the right error code.
The problem I have with this is that if there are tests that fail, I'm still seeing a green success icon:
After several experiments, I realized that as long as the output contains "FAILURES!", the test will be successful.
run_phpunit.php:
echo "FAILURES!";
exit(1);
run_phpunit.php:
echo "SUCCESS!";
exit(1);
I'm using testdox="true"
in my phpunit.xml, btw.
Somehow, it appears to me that this extension is looking at the output, rather than relying on the exit code,
and there's a bug in the way it looks at the output.
To fix this, I'm changing my run_phpunit.php
so that if there are failures, it will replace "FAILURES!" with something else...
run_phpunit.php:
$rc = null;
$cmd_output_ar = array();
exec($cmd, $cmd_output_ar, $rc);
$output = implode("\n", $cmd_output_ar);
echo str_replace('FAILURES!', '', $output);
Hi
Related to recca0120#122, which also seems to happen with this forked edition of the plugin. Although https://github.com/recca0120/vscode-phpunit seems to be somewhat unmaintained, maybe it would be possible to fix this here? ๐
When I'm using native VSCode native testing Run all tests command runs only tests in first file.
In my local project the paths is src/ but in docker it is mounted as /var/www/html/.
volumes:
- ./src/:/var/www/html/:rw
When the test is launched it runs as "src/tests/Unit/ExampleTest.php" and shows an error, but it should be "tests/Unit/ExampleTest.php".
$ docker-compose exec container bash -c "vendor/bin/phpunit --configuration ./phpunit.xml --filter /^.*::testThatTrueIsTrue.*$/ src/tests/Unit/ExampleTest.php"
But the correct:
$ docker-compose exec container bash -c "vendor/bin/phpunit --configuration ./phpunit.xml --filter /^.*::testThatTrueIsTrue.*$/ tests/Unit/ExampleTest.php"
Would there be a possibility to add an option with mapped paths? ex:
"phpunit.pathMappings": {
"${workspaceRoot}/src/":"/var/www/html/"
}
Every time I save a change on a file that is not inside the main folder of the workspace (but it's a folder in the folders
settings of the workspace), I get this crash and I must restart VSCode to be able to run tests again:
TypeError: Cannot read properties of undefined (reading 'loc')
at n.swapLocations (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:154736)
at n.resolvePrecedence (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:155463)
at a (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:157455)
at r.read_expr (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:217563)
at r.read_expr_item (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:219090)
at r.read_expr (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:216069)
at r.read_argument_list (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:228199)
at r.read_function_argument_list (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:227870)
at r.recursive_variable_chain_scan (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:250227)
at r.read_variable (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:248412)
[Info - 16:24:08] Connection to server got closed. Server will restart.
If you need to know my configs, please let me know.
Thank you!
I have a DDEV project I run in Remote WSL session.
If I configure this plugin to run with the following settings
"phpunit.relativeFilePath": true,
"phpunit.phpunit": "/var/www/html/vendor/bin/phpunit",
"phpunit.docker": true,
"phpunit.dockerImage": "docker exec -it 833f9",
I get the following error:
spawn docker exec -it 833f9 bash -c "var/www/html/vendor/bin/phpunit -c /home/user13/code/phpunit.xml" ENOENT
The following is successful
docker exec -it 833f9 "/var/www/html/vendor/bin/phpunit"
I do not understand why -c /home/user13/code/phpunit.xml
is being injected.
This config file is my WSL path. If the command is running in docker, then it should be the dockered path?
I check the actual path:
docker exec -it 833f9 "bash"
$ find ~+ -type f -name phpunit.xml
/var/www/html/phpunit.xml
I can run the following in my terminal:
docker exec -it 833f9 bash -c "/var/www/html/vendor/bin/phpunit -c /var/www/html/phpunit.xml"
So I think the correct spawn command should be:
spawn docker exec -it 833f9 bash -c "/var/www/html/vendor/bin/phpunit -c /var/www/html/phpunit.xml"
spawn docker exec -it 833f9 bash -c "/var/www/html/vendor/bin/phpunit -c /home/user13/code/phpunit.xml"
VSCode 1.66.2
renandelmonico.vscode-php-test-explorer 1.0.1
Iยดm using the phpunit extension and i'm having a few issues.
I can run my tests 2 or 3 times before I get the following error in the picture.
After this happens I only can run my tests after restarting vscode.
Below is the following error that is printed in the output.
{
"phpunit.phpunit": "/var/www/vendor/bin/phpunit",
"testExplorer.useNativeTesting": true,
"phpunit.files": "tests/**/*Test.php",
"phpunit.remoteCwd": "/var/www",
"phpunit.relativeFilePath": true,
"phpunit.php": "/usr/bin/docker compose exec -T accounts2 ",
"phpunit.shell": "bash",
"phpunit.args": ["--configuration ./phpunit.xml"]
}
Allow setting the path to the phpunit executable using ${workspaceRoot}
Hi !
I used PHPUnit extension to connect to remote machine successfuly. I run tests using "Ctrl+Shift+P -> PHPUnit Test -> myTestCase" as instance. See output below.
PHPUnit 8.5.26
Runtime: PHP 7.2.24-0ubuntu0.18.04.11 with Xdebug 2.6.0
Configuration: /home/sb-0/phpunit.xml
...... 6 / 6 (100%)
Time: 31.95 seconds, Memory: 16.00 MB
OK (6 tests, 7 assertions)
But when I run test using Test Explorer, or Run in top label of test function headers, the output command executed automatically by extension ignores ssh configuration and runs directly "phpunit.php": "/usr/bin/php", command. See output below.
[INFO] {
title: 'PHPUnit LSP',
command: '/usr/bin/php',
arguments: [
'/home/sb-0/www/iats/code/resources/composer/phpunit/phpunit/phpunit',
'-v',
'-c',
'/home/sb-0/phpunit.xml',
'--filter',
'/^.::testBadgeName.$/',
'/home/sb-0/www/iats/code/module/badge/test/BadgeUnitTest.phpunit.php'
]
}
How can we use current phpunit configuration to run tests using PHPUnit Test Explorer extension?
Am I doing something wrong?
Thnaks !!
Great work!!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.