Code Monkey home page Code Monkey logo

vscode-phpunit's Issues

"FAILURES!" = Pass

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:

image

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);

image

run_phpunit.php:

    echo "SUCCESS!";
    exit(1);

image

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);

image

Not working with Docker and WSL2 - Windows 10 - wrong path escaped

I am trying to run this inside Docker in Windows 10 with WSL2, but it is not working at all. The screenshot shows the definitions I am using and that the path escaped by the spawn command shows it wrong.

image

Executing the correct command would work, as show in the next screenshot:

image

Not working with Docker and differents paths

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/"
}

TypeError: Cannot read properties of undefined (reading 'loc')

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!

plugin inject wrong config file

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

PHP server is crashing

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.

image

After this happens I only can run my tests after restarting vscode.

Below is the following error that is printed in the output.

image

settings.json

{
    "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"]
}

phpunit.ssh setting not working

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!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.