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

Unit test fails always #1

Closed veerajongit closed 5 years ago

veerajongit commented 5 years ago

Unit test keeps on failing and there is no error log. Tried running from terminal, I get this error Fatal error: Class 'PHPTDD\BaseTestCase' not found in /Users/veerajshenoy/development/php/caapp/tests/unit/cases/app/Http/Controllers/UserControllerTest.php on line 6

jasonterando commented 5 years ago

Will take a look at it this evening.

jasonterando commented 5 years ago

So... I grabbed the project on both Windows and Linux, ran "npm install" and then "npm run test" and stuff worked, on both. I'm running Node 8.1, NPM and VSCode are both current versions. Can you share with me how you're executing the tests?

In the mean time, I am going to update some of the dependencies in package.json to deal with the audit warnings and get that pushed hopefully this weekend..

Here's how it looked on my end...

jterando@TerandoX1:~/Projects$ git clone git@github.com:jasonterando/vscode-php-tdd.git && cd vscode-php-tdd && npm install && npm run test
Cloning into 'vscode-php-tdd'...
remote: Enumerating objects: 107, done.
remote: Total 107 (delta 0), reused 0 (delta 0), pack-reused 107
Receiving objects: 100% (107/107), 305.29 KiB | 2.05 MiB/s, done.
Resolving deltas: 100% (18/18), done.

> vscode-php-tdd@0.0.3 postinstall /home/jterando/Projects/vscode-php-tdd
> node ./node_modules/vscode/bin/install

Detected VS Code engine version: ^1.23.0
Found minimal version that qualifies engine range: 1.23.0
Fetching vscode.d.ts from: https://raw.githubusercontent.com/Microsoft/vscode/7c7da59c2333a1306c41e6e7b68d7f0caa7b3d45/src/vs/vscode.d.ts
vscode.d.ts successfully installed!

npm WARN vscode-php-tdd@0.0.3 No license field.

added 615 packages from 1377 contributors and audited 3214 packages in 6.068s
found 21 vulnerabilities (2 low, 16 moderate, 3 high)
  run `npm audit fix` to fix them, or `npm audit` for details

> vscode-php-tdd@0.0.3 test /home/jterando/Projects/vscode-php-tdd
> npm run compile && node ./node_modules/vscode/bin/test

> vscode-php-tdd@0.0.3 compile /home/jterando/Projects/vscode-php-tdd
> tsc -p ./ && cp src/dump.php out/dump.php && cp -r src/templates out && cp src/test/sample.php out/test/sample.php

### VS Code Extension Test Run ###
Current working directory: /home/jterando/Projects/vscode-php-tdd
Downloading VS Code into "/home/jterando/Projects/vscode-php-tdd/.vscode-test/stable" from: https://vscode-update.azurewebsites.net/1.32.3/linux-x64/stable
Running extension tests: /home/jterando/Projects/vscode-php-tdd/.vscode-test/stable/VSCode-linux-x64/code /home/jterando/Projects/vscode-php-tdd/out/test --extensionDevelopmentPath=/home/jterando/Projects/vscode-php-tdd --extensionTestsPath=/home/jterando/Projects/vscode-php-tdd/out/test
[main 2019-03-16T16:02:17.669Z] update#setState idle

bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell

  PHPClassInfo

    testable

      ✓ should return true

    identifier

      ✓ should return name

    functions

      ✓ should allow setting and getting functions

  PHPCommentInfo

    ✓ should construct and get properties

    ✓ should construct with defaults

    ✓ should change end line number

    ✓ should format single page range

    ✓ should format multiple page range

    ✓ should format invalid range

    ✓ should render inline

    ✓ should render block

  PHPFunctionInfo

    testable

      ✓ should return true

    identifier

      ✓ should return clsas and function name when class is defined

      ✓ should return function name when namespace is undefined

    class

      ✓ should set and get class

    fullName

      ✓ should return full class and function name when class is defined

      ✓ should return namespace and function name when namespace is defined

      ✓ should return function name when namespace is undefined

  PHPTestFunctionInfo

    testable

      ✓ should constrct and return property

    hasTestFunction

      ✓ should true when a testFunction is set

      ✓ should false when a testFunction is not set

  PHPUseInfo

    ✓ should construct, not be testable and expose properties

    ✓ should default end line number to NaN

  VisualCodePositionShim

    ✓ should construct and return properties

  ComposerSetupService

    loadComposerJson

      ✓ should return an object when loading composer.json file succesfully

      ✓ should throw an exception when composer.json file is not read succesfully

      ✓ should throw an exception when composer.json file is invalid

      ✓ should return an empty object if composer.json file does not exist

    saveComposerJson

      ✓ should save an object succesfully

      ✓ should throw an exception if file is not saved succesfully

    checkRequirements

      ✓ should exit if enableInstall is false

      ✓ should add new reqiured and development packages

      ✓ should not add existing reqiured and development packages

      ✓ should choke if loadComposerFile fails

    assignNamespace

      ✓ should exit if enableNamespace is false

      ✓ should add namespace and create psr-4 section in composer.json

      ✓ should default namespace to global and create psr-4 section in composer.json

      ✓ should append to existing namespace in psr-4 section in composer.json

      ✓ should append to existing namespace array in psr-4 section in composer.json

      ✓ should skip existing entry namespace array in psr-4 section in composer.json

  PHPDocumentEditorService

    addCommentBlock

      ✓ create comment block with specified text

    appendInlineComment

      ✓ append text to inline comment

      ✓ append text to comment block

    addTestFunction

      ✓ append to existing inline comment

      ✓ create new block comment

  PHPFileParser

    tokenize

      ✓ should return array of tokens

    getEntities

      ✓ should return a list of entities

      ✓ should fail to return a list of entities if parse fails

    getTestableEntities

      ✓ should return a testable entity

      ✓ should fail on testable entity if there is a parse fail

    getEntityAtLineNumber

      ✓ should return TestMethod1 function when positioned inside of function

      ✓ should return TestMethod1 function when positioned in function comment

      ✓ should return TestUncommentedClass when positioned at end of class

      ✓ should return standalone function

      ✓ should fail when PHP is invalid

    getNextDescriptorOnLine

      ✓ should return text before whitespace from getNextNonEmptyTextOnLine

      ✓ should return consecutive text before whitespace from getNextNonEmptyTextOnLine

      ✓ should return empty after lineNo when token isn't an array

      ✓ should return empty when token is a line after lineNo

      ✓ should return empty when ctr is past limit

    isLineClassOrFunction

      ✓ should return true on class

      ✓ should return true on function

      ✓ should return false after lineNo when token isn't whitespace or an array

      ✓ should return empty when token is a line after lineNo

      ✓ should return empty from getNextNonEmptyTextOnLine when ctr is past limit

  PHPUtility

    capitalizeFirstLetter

      ✓ should return empty on empty string

      ✓ should return capitalized first letter

    substituteValues

      ✓ should return empty on empty string

      ✓ should replace all instances

  SpawnService

    command

      ✓ should set and get

    arguments

      ✓ should set and get

    setCommandWithArguments

      ✓ should separate command and unquoted arguments

      ✓ should separate command and quoted arguments

    startInDirectory

      ✓ should set and get

    writeToStdin

      ✓ should set and get

    run

      ✓ should succeed when process returns zero

      ✓ should throw exception if process returns non-zero result

      ✓ should throw exception if spawn triggers error event with non-Error payload

      ✓ should throw exception if spawn triggers error event with Error payload

    launchFile

      ✓ should launch on MacOS

      ✓ should launch on Windows

      ✓ should launch on Linux

  82 passing (155ms)
jasonterando commented 5 years ago

Unit test keeps on failing and there is no error log. Tried running from terminal, I get this error Fatal error: Class 'PHPTDD\BaseTestCase' not found in /Users/veerajshenoy/development/php/caapp/tests/unit/cases/app/Http/Controllers/UserControllerTest.php on line 6

Hi - first, my apologies for the long time to get you a decent reply, and for initially misreading your problem.

I think I have a workaround for you, if you're still game to try it. In the tests/unit/bootstrap.php, add the following line:

require_once __DIR__ . "/BaseTestCase.php";

This should load in the base class that it's looking for. Thanks for your patience.

I'm working on an update now that will create the file bootstrap.php properly, as well as update the NPM dependencies to get rid of some security warnings.

Regards, Jason

jasonterando commented 5 years ago

One other thing... if you still have problems, you can go to the OUTPUT window in VS Code, select "PHP TDD" from the dropdown and you should see some logging there.

jasonterando commented 5 years ago

Work around documented above, and fixed version 0.0.5 posted. No further feedback received. Marking as closed.