jasonterando / vscode-php-tdd

Microsoft Visual Code Extension to support PHP Test Driven Development
https://marketplace.visualstudio.com/items?itemName=jasonterando.vscode-php-tdd
MIT License
3 stars 2 forks source link

Adjustment of creation path #3

Open ghost opened 4 years ago

ghost commented 4 years ago

Greetings, I recently decided to use this extension but I came upon a problem the Tests get created in the Wrong Directory. It would be nice If their was a Setting to choose if tests get generated in the cases folder or not.

jasonterando commented 4 years ago

Hi, in VSCode, try the following:

  1. F1, then Preferences: Open Settings (UI)
  2. Filter by "php-tdd"
  3. Switch to Workspace
  4. Down toward the bottom, you should find a setting called "PHP-tdd: Test Subdirectory"

Let me know if that's what you need.

ghost commented 4 years ago

What I meant is your plugin creates the directory "cases" inside the Test-Subdirectory and wants to delete it and recreate it if it already Exists.

The following screenshot was taken in an empty workspace with a folder "tests/unit" preexisting:

image

What I would love to define is to define my Testdirectory as "tests" and the "cases" folder as unit without overwriting existing files. Which would be pretty ouch in a laravel Project since laravel provides a test folder with subfolders a TestCase.php a Trait that is useable and Example tests.

image

jasonterando commented 4 years ago

Gotcha. I'm pulling up the project now and will find out where that happens and fix it. It's been a while since I've looked at this, I need to make some updates to how the extension's unit tests are run, and also deal with some changes in how PHPUnit works (ex. now requires a : void return type on setUp and tearDown functions). Give me a day to dig into this a bit. Thanks for the feedback!

ghost commented 4 years ago

I looked at the source code myself a bit and the following line is the "devil" in this case. https://github.com/jasonterando/vscode-php-tdd/blob/4244fc834849f329a151716a3cce1e66e183cb46/src/services/php-unit-test-project-service.ts#L84

jasonterando commented 4 years ago

Yah, the part above that (the bit with "rimraf" in it) basically says "if they set something else up for unit testing, clear it out because I know what's right"... I'm not sure what I was thinking there, other than fear of bumping into a phpunit.xml or something that didn't play nice with what I was doing. I'm fixing that now, along with making sure I don't overwrite phpunit.xml, etc. if those files are already there. I'm also updating my template for the unit test and default phpunit.xml to be compatible with current phpunit.xml.

jasonterando commented 4 years ago

Hi, I've posted an update, 0.0.6. If the configured test directory contains a phpunit.xml there already, it leaves it alone, and bases test off of PHPUnit's TestCase. If there is not a phpunit.xml, it will create a new one and put in it's own BaseTestCase class. I haven't tested this a lot yet, but if you want to take a look and let me know if I'm on the right track, I'd be obliged. Thanks.

ghost commented 4 years ago

Sadly no I have the Updated plugin and after trying it it still wanted to delete my folder.

So I locked into the code of the extension that was installed and it does not seem like the compiled code got updated.