I am trying to use SimplePHPUnit package in Sublime Text 3, but when I am issuing the run command, it only and always returns:
[Finished in 0.4s with exit code 1]
[cmd: phpunit --stderr]
[dir: C:\Apache24\htdocs]
[path: ...]
phpunit.xml:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
strict="false"
bootstrap="phpUnitAutoload.php"
verbose="true">
</phpunit>
Is this package suposed to be working on windows? If so, any idea how to get it to work properly?
I am using phpunit-6.2.1 and php 7.0.6 on Windows 10
My phpunit.cmd was not properly set or accessible in the PATH. Hence it was not found by SimplePHPUnit.
Related
My unit tests on CakePHP still run, but the code coverage has disappeared. All I get is "No files to generate coverage for".
Our application is currently running on CakePHP 2.10.15. I have PHPUnit 5.7 installed. Running PHP 7. I use the web runner for tests & coverage. I have XDebug 2.7.0beta1 running.
Did one of our recent upgrades break some sort of connection between Cake and PHPUnit?
Create a file phpunit.xml in your app folder:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd">
<logging>
<log type="coverage-text" target="tmp.txt" showOnlySummary="true"/>
</logging>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
</testsuite>
<filter>
<whitelist processUncoveredFilesFromWhitelist="false">
<!-- directories that you want in code coverage -->
<directory suffix=".php">app/</directory>
</whitelist>
</filter>
</phpunit>
For me just adding this file like this worked just fine. For more information about this xml: https://phpunit.de/manual/5.7/en/appendixes.configuration.html
Be aware to include only the files and directories you need, otherwise it will became very slow.
If you install phpunit/phpunit package in Symfony 4 application, you get the message:
Adding phpunit/phpunit as a dependency is discouraged in favor of Symfony's PHPUnit Bridge.
Instead:
Remove it now: composer remove --dev phpunit/phpunit
Use Symfony's bridge: composer require --dev phpunit
So, I installed symfony/phpunit-bridge package.
It created bin/phpunit file and vendor/bin/simple-phpunit.
If I run bin/phpunit, it downloads phpunit project and installs its dependencies in bin/.phpunit/phpunit-6.5.
If I run vendor/bin/simple-phpunit, it downloads phpunit project and installs its dependencies in vendor/bin/.phpunit/phpunit-5.7.
Note that the versions are not the same. Why?
And why to not use composer and its autoloader? Now we have troubles with it and other tools like PHPStorm (broken phpunit debugging, etc).
I know, that I can add phpunit path to main composer autoload, but this method seems very dirty.
How to use phpunit in Symfony 4 proper way, with all debugging integrations, etc?
I have managed to fix this issue by adding phpunit.xml.dist in the root of the Symfony.
The file existed previously but I suspect that when I did remove phpunit, it also removed this file.. (I could be wrong but I am pretty certain)
When I add back the standard phpunit.xml.dist file to the root, it prompts me to add 'KERNEL_CLASS' variable in it.
When I add it in, it started working fine.
Full contents of my phpunit.xml.dist in case someone needs it
<?xml version="1.0" encoding="UTF-8"?>
<!--
https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_CLASS" value="App\Kernel" />
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
</phpunit>
I am running phpunit (composer provisioned and version 4.8) from PHPStorm 8. Usually it works fine but whenever I need to use the #runInSeparateProcess annotation it starts screaming this error:
Fatal error: Class 'PHPUnit_Util_Configuration' not found in - on line 334
Call Stack:
0.0013 395808 1. {main}() -:0
The PHPUnit configuration on the IDE is the following:
Language & Frameworks > PHP > PHPunit: custom autoloader pointing to codebase/vendor/autoload.php
Run/Debug Configuration: alternative configuration file which point to my local phpunit.xml
This is the content of the configuration:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.2/phpunit.xsd"
colors="true"
bootstrap="./vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="My Project">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
The tests run as expected from the command line with the same phpunit executable and the same configuration file.
Any suggestion?
Apparently removing all dependencies and re-installing phpunit from composer (phpunit 4.8.6) solved the problem.
A modification of the fix the folks over at Drupal are using (https://www.drupal.org/node/2597814)
Add to the top of your boostrap file:
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
define('PHPUNIT_COMPOSER_INSTALL', __DIR__ . '/path/to/composer/vendors/dir/autoload.php');
}
I tried many other methods, including upgrading PHPStorm and up/down-grading PHPUnit. This works.
Getting "invalid application descriptor: Unknown namespace: library://ns.adobe.com/flex/spark"
when using adl (command-line debugger) for a flash-builder 4.6 adobe air project
its a very simple project
mxml file starts like this :
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
invoke="onInvoke(event)" visible="false"> ...
i read about a similer problems, where solution was to swap the
xmlns value to "http://ns.adobe.com/air/application/3.1"/.
swapping values gave me another error :
"invalid application descriptor: application filename must have a non-empty value"
also,
the whole reason for this is that i have a program that must run my air app
so i need a way to run a flash-builder project in the command-line
im using adl
is this the best way ?
edit :
the descriptor file code :
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<application xmlns="http://ns.adobe.com/air/application/3.1">
<id>exporter</id>
<filename>exporter</filename>
<name>exporter</name>
<versionNumber>0.0.0</versionNumber>
<initialWindow>
<content>[This value will be overwritten by Flash Builder in the output app.xml]</content>
<autoOrients>false</autoOrients>
<fullScreen>false</fullScreen>
<visible>false</visible>
</initialWindow>
</application>
I have a Java application and I integrated JavaFX 1.3 on it. I have spent more than three days trying to deploy it as a Web Start Application and it is impossible.
I have a jar running with the console (javafx -jar MatchTestCaseGenerator-2.0-jar-with-dependencies.jar) but when I try to execute the jnlp I have the following error:
java.security.AccessControlException: access denied (java.util.PropertyPermission user.home read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1285)
at java.lang.System.getProperty(System.java:667)
at sun.awt.shell.ShellFolderManager.get(ShellFolderManager.java:57)
at sun.awt.shell.ShellFolder.get(ShellFolder.java:227)
at javax.swing.filechooser.FileSystemView.getDefaultDirectory(FileSystemView.java:404)
at javax.swing.JFileChooser.setCurrentDirectory(JFileChooser.java:552)
at javax.swing.JFileChooser.<init>(JFileChooser.java:334)
at javax.swing.JFileChooser.<init>(JFileChooser.java:286) ...
I have the jar file signed and verified and my JNLP file is like that:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="file:/Users/ana/Projects/Java/workspace/Match Test Case Generator 2.0/target" href="MatchTestCaseGenerator.jnlp">
<information>
<title>Match Test Case Generator</title>
<vendor>KV </vendor>
<homepage href=""/>
<description>some_description</description>
<offline-allowed/>
<shortcut>
<desktop/>
</shortcut>
</information>
<resources>
<j2se version="1.6+"/>
<extension name="JavaFX Runtime" href="http://dl.javafx.com/1.3/javafx-rt.jnlp"/>
<jar href="MatchTestCaseGenerator-2.0-jar-with-dependencies.jar" main="true"/>
</resources>
<application-desc main-class="com.sun.javafx.runtime.main.Main" progress-class="com.javafx.progressbar.ProgressManager">
<argument>MainJavaFXScript=com.knowledgevalues.mtcg.javafx.MainFx</argument>
</application-desc>
</jnlp>
Am I missing something? should I introduces a policy file in the jar?? I'm totally lost
Thank you very much in advance for any help.
Try to add next section to your jnlp file:
<security>
<all-permissions/>
</security>
The final solution was to remove all the folders that included javafx classes except the Main class.
With that, it worked without problems!!