I have the following build.xml file setup in phpUnderControl.
<target name="phpunit">
<exec executable="phpunit" dir="${basedir}/httpdocs" failonerror="on">
<arg line="--log-junit ${basedir}/build/logs/phpunit.xml
--coverage-clover ${basedir}/build/logs/phpunit.coverage.xml
--coverage-html ${basedir}/build/coverage
--colors
${basedir}/httpdocs/qc/unit/CalculatorTest.php" />
</exec>
</target>
For some unkown reason the build always fails with the below message.
phpunit:
[exec] PHPUnit 3.4.15 by Sebastian Bergmann.
[exec]
BUILD FAILED
/opt/cruisecontrol-bin-2.8.3/projects/citest.local/build.xml:30: exec returned: 255
I have run the very simple unit test manually within the unit directory and PHPUnit returns.
PHPUnit 3.4.15 by Sebastian Bergmann.
.
Time: 0 seconds, Memory: 5.25Mb
OK (1 test, 1 assertion)
Does anyone know why it keeps failing the build, when all the tests are fine?
My build script does have a clean method which removes and log files, so its not that. I have also manually removed the log files, just in case it's that script. And changed the owner of the log directories so they are writable.
If it makes any difference the phpunit.xml is empty after PHPUnit is run.
Thanks.
UPDATE: Incidentally if I remove failonerror="on" it works, obviously, but PHPUnit still returns 255 and I do want it to fail on any errors, the issue is there isn't any errors yet it still fails!
255 is the error code that PHP throws on fatal and (I think) parse errors.
Could there be a fatal or parse error in the script execution, maybe after the tests have run?
Any PHP errors? What happens if you add error_reporting(E_ALL); ?
Probably the 'exec returned: 255' is caused by the memory consumption of the CodeCoverage report, which will be displayed after enabling error_reporting(E_ALL) like Pekka mentioned. Try init_set('display_errors','on'); also. Usualy you will face a 'memory size ...exhaused' fatal.
In my case, it turned out to be that I didn't have a webserver installed. Installing nginx and setting it up as a webserver (even if I'm not using it) fixed the problem.
it might be caused by some empty testsuite in phpunit.xml, that is, no assertXXX in test code
I got Selenium, PHPUnit, PHPUnderControl, and CruiseControl all working together (here http://www.siteconsortium.com/h/p1.php?id=php002)
Just a very basic example but I was able to get it to work like this. Start from something simple and copy the other stuff back in.
<?xml version="1.0" encoding="UTF-8"?>
<project name="test" default="build" basedir=".">
<target name="build">
<exec executable="C:\\PHP\\phpunit.bat" dir="C:\\workspace\\proj\\phpunit" failonerror="on">
<arg line="--log-junit C:\\workspace\\proj\\build\\logs\\phpunit.xml
--configuration C:\\workspace\\proj\\phpunit.xml
--include-path C:\\trunk\\includes C:\\workspace\\proj\\includes" />
</exec>
</target>
</project>
Related
When I try to run my appium scripts on the pom file ( with mvn verify or mvn test)
I get a
java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy12.proxyClassLookup()
On the line that instantiates my locators:
PageFactory.initElements(new AppiumFieldDecorator(driver, Duration.ofSeconds(15)), this);
When I run the test directly from InteliJ or run the testng.xml file, the test succeeds
Full pom.xml: https://pastebin.com/V0FbehMh
Full error stacktrace: https://pastebin.com/11TvTq7a
testng.xml: https://pastebin.com/8XZtCfRt
Related classes: https://pastebin.com/ynFizC9T
What can be the problem, when everything is fine running from test class / testng.xml, but suddenly failing when running with maven in command line
it's a bit embarrassing, (because i remembered I did this before)
After doing an mvn clean, and an mvn compile again,
Then the issue disappeared. something probably got stuck somewhere and needed a clean again..
I have a Sails Api which the first time boots like a charm.
Press CTRL + C to stop it and then try to start it again. It works, BUT,
error: ** Grunt :: An error occurred. **
error:
------------------------------------------------------------------------
Aborted due to warnings.
Running "clean:dev" (clean) task
Warning: Cannot delete files outside the current working directory.
------------------------------------------------------------------------
error: Looks like a Grunt error occurred--
error: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)
error: Or if you're stuck, check out the troubleshooting tips below.
error: Troubleshooting tips:
error:
error: *-> Are "grunt" and related grunt task modules installed locally? Run `npm install` if you're not sure.
error:
error: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
error:
error: *-> Or maybe you don't have permissions to access the `.tmp` directory?
error: e.g., `folderthingy` ?
error:
error: If you think this might be the case, try running:
error: sudo chown -R 501 folderthingy
Well, I check it all, and the folder just is my own and has enough rights. I also put up a 777 for testing purposes but this didn't change a thing.
Then, I decided to clear out all the contents of the .tmp folder and try to boot again. This worked like a charm, .tmp got filled again, and when I stopped the server, tried to reboot it, I got the exact same error message again!
I'm booting with the --no-frontend option, so in fact I don't understand why it even wants to load grunt.
Why is this happening? What's going wrong here?
Why it happens is still not known to mankind, but I fixed it with removing the Gruntfile.
Fixed this by following below steps :
File path in your sails app -> tasks/config/sync.js
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-sync --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-sync');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Note: Work for Warning "sync:dev" not found
If you are using Linux, try doing sudo sails lift, you can have problems with permissions (happened to me). If Windows - check that no file manager or some other program is blocking the .tmp folder (also happened to me when I opened the folder in Total Commander).
In any case, since you don't use frontend, you can simply remove some of the grunt tasks (in the folder tasks/ you have README.md which explains which tasks are run in which case) or all of them (see documentation) and you won't have the problem.
i also got this error-
error: ** Grunt :: An error occurred. **
error:
------------------------------------------------------------------------
Aborted due to warnings.
Running "sass:dev" (sass) task
> error: Looks like a Grunt error occurred--
>
> error: Please fix it, then **restart Sails** to continue running tasks
> (e.g. watching for changes in assets)
>
> error: Or if you're stuck, check out the troubleshooting tips below.
error: Troubleshooting tips:
error:
error: *-> Are "grunt" and related grunt task modules installed locally? Run `npm install` if you're not sure.
error:
error: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
error:
error: *-> Or maybe you don't have permissions to access the `.tmp` directory?
error: e.g., `/Users/siyaram.malav/Desktop/repo/project1/.tmp` ?
this error came because it could not find the sass module.And ran following command
sudo gem install sass
it worked for me.
In your case, try running sudo gem install clean command.
it should work.
thanks.
I had the same problem while following this tutorial:
https://www.youtube.com/watch?v=ZE7ye2G_H9Q&index=4&list=PLf8i4fc0zJBzLhOe6FwHpGhBDgqwInJWZ
I created a "linker" folder since that's what the guy did, which then prompted me with the error. It looks like he's using an older version of SailsJS since he runs into no errors.
Did you by any chance create a new folder in the assets folder? If you did, the problem is that grunt isn't able to run tasks on the specific folder since it's not linked with the rest of the assets folders and files. Try placing all newly created files within already existing folders and trying again. This worked for me.
Why phpunit is green when there are tons of exceptions?
Here's an example job in travis: https://travis-ci.org/ConnectCorp/nexmo-client/jobs/79275172
Strict standards: Declaration of Nexmo\Tests\Service\TestServiceTrait::exec() should be compatible with Nexmo\Service\Service::exec($params, $method = 'GET') in /home/travis/build/ConnectCorp/nexmo-client/tests/Service/VoiceTest.php on line 42
Call Stack:
0.0013 415584 1. {main}() /home/travis/.phpenv/versions/5.4.37/bin/phpunit:0
0.0209 1038200 2. PHPUnit_TextUI_Command::main() /home/travis/.phpenv/versions/5.4.37/bin/phpunit:722
0.0209 1044680 3. PHPUnit_TextUI_Command->run() phar:///home/travis/.phpenv/versions/5.4.37/bin/phpunit/phpunit/TextUI/Command.php:104
0.0209 1045112 4. PHPUnit_TextUI_Command->handleArguments() phar:///home/travis/.phpenv/versions/5.4.37/bin/phpunit/phpunit/TextUI/Command.php:114
0.0281 1812016 5. PHPUnit_Util_Configuration->getTestSuiteConfiguration() phar:///home/travis/.phpenv/versions/5.4.37/bin/phpunit/phpunit/TextUI/Command.php:664
0.0281 1812928 6. PHPUnit_Util_Configuration->getTestSuite() phar:///home/travis/.phpenv/versions/5.4.37/bin/phpunit/phpunit/Util/Configuration.php:814
0.0318 2063368 7. PHPUnit_Framework_TestSuite->addTestFiles() phar:///home/travis/.phpenv/versions/5.4.37/bin/phpunit/phpunit/Util/Configuration.php:901
0.1145 6533504 8. PHPUnit_Framework_TestSuite->addTestFile() /home/travis/build/ConnectCorp/nexmo-client/vendor/phpunit/phpunit/src/Framework/TestSuite.php:403
0.1145 6571744 9. PHPUnit_Util_Fileloader::checkAndLoad() /home/travis/build/ConnectCorp/nexmo-client/vendor/phpunit/phpunit/src/Framework/TestSuite.php:331
0.1146 6571880 10. PHPUnit_Util_Fileloader::load() phar:///home/travis/.phpenv/versions/5.4.37/bin/phpunit/phpunit/Util/Fileloader.php:42
0.1148 6681536 11. include_once('/home/travis/build/ConnectCorp/nexmo-client/tests/Service/VoiceTest.php') phar:///home/travis/.phpenv/versions/5.4.37/bin/phpunit/phpunit/Util/Fileloader.php:58
PHPUnit 4.8.6 by Sebastian Bergmann and contributors.
............................................................... 63 / 117 ( 53%)
......................................................
Time: 511 ms, Memory: 13.00Mb
OK (117 tests, 210 assertions)
https://travis-ci.org/ConnectCorp/nexmo-client/jobs/79275172
I would expect it would fail and travis report that a build has failed, but it just silently passes. Is there any phpunit config option I am missing?
Current phpunit config is this:
<?xml version="1.0" encoding="utf-8"?>
<phpunit colors="true"
bootstrap="./vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Nexmo Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<blacklist>
<directory suffix=".php">vendor/*</directory>
</blacklist>
</filter>
</phpunit>
Even though there is an error, no tests have actually failed, so phpunit will return a success code.
Before running the tests, phpunit first loads and parses *Test.php files and this is where your errors are coming from, rather than from a test method itself.
Changing the config option stopOnFailure="false" to stopOnFailure="true" or stopOnError="true" should make this task fail.
From the documentation:
--stop-on-error Stop execution upon first error.
--stop-on-failure Stop execution upon first error or failure.
Edit
Actually, just been playing with this and as it is a notice and before the tests actually start those flags won't have any effect.
You seem to discovered a bug in phpunit and I suggest you report it to their repository.
It only seems to be a problem if a notice is triggered from the test class. Your mock classes are defined in the same file as a test class. If you move them out to its own file tests will start failing as expected. Methods need to have the same signature as their parent.
Might be also worth to configure error reporting in your phpunit.xml to report all errors (although this alone will not solve your current issue, error reporting will be enable no matter how environment is configured):
<php>
<ini name="error_reporting" value="-1" />
</php>
I get an error when I try to run a test in PHPUnit. Even if I type phpunit by itself, I still get an error. It works fine when I call it outside the Bootstrap folder.
Configuration read from /home/milen/Documents/codific/icho/module/Application/tests/phpunit.xml
PHP Fatal error: Call to a member function getId() on a non-object in /home/milen/Documents/codific/icho/module/Application/tests/ApplicationTest/Controller/PoCourseTest.php on line 268
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:129
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:176
PHP 5. PHPUnit_Framework_TestSuite->run() /home/milen/Documents/codific/icho/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:426
PHP 6. PHPUnit_Extensions_SeleniumTestCase->run() /home/milen/Documents/codific/icho/vendor/phpunit/phpunit/src/Framework/TestSuite.php:699
PHP 7. PHPUnit_Framework_TestCase->run() /home/milen/Documents/codific/icho/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumTestCase.php:648
PHP 8. PHPUnit_Framework_TestResult->run() /home/milen/Documents/codific/icho/vendor/phpunit/phpunit/src/Framework/TestCase.php:760
PHP 9. PHPUnit_Framework_TestCase->runBare() /home/milen/Documents/codific/icho/vendor/phpunit/phpunit/src/Framework/TestResult.php:686
PHP 10. PoCourseTest->tearDown() /home/milen/Documents/codific/icho/vendor/phpunit/phpunit/src/Framework/TestCase.php:852
I tried reinstalling it, no luck.
I usually see an error along these lines when I have defined a bootstap.php file to run for PHPUnit which gets specified in the phpunit.xml file. With this setup, you need to be careful from where you run your tests so that the bootstrap file is run properly. This isn't a problem of PHPUnit per se, but a side effect from the phpunit.xml file.
This would appear to be the case because you stated that when you are not in the folder called "Bootstrap" (what / where ever that is), PHPUnit works fine. But without more information aside from the error dump this would be difficult to ascertain.
I think this question could be fixed with this answer.
I don't think its a problem with configuration, but rather a code execution in the setUp and tearDown method.
I have an interesting (but ultimately harmless) problem: PHPUnit will report that no tests were executed, and then proceed to read the config file and run the tests, giving an output as below.
It would appear that PHPUnit is exiting and then resuming for some reason. I've looked through my bootstrap process and log files I can't see anything which would cause PHPUnit to exit (an exception or exit statement or the like).
The tests are being run from the tests directory, using the PHPUnit phar: php ../phpunit.phar -c phpunit.xml
Has anybody seen this behaviour before? What was the problem? Ultimately, this isn't harming anything at all, I'm just curious as to what's going on.
PHPUnit 3.7.34 by Sebastian Bergmann.
Time: 2.18 seconds, Memory: 23.50Mb
No tests executed!
PHPUnit 3.7.34 by Sebastian Bergmann.
Configuration read from /path/to/phpunit.xml
............................................................. 61 / 2630 ( 2%)
............................................................. 122 / 2630 ( 4%)
.. and so on ..
The configuration files also appears to be OK, since the tests do run.
<phpunit
colors="true"
bootstrap="/path/to/application/bootstrap.php"
backupGlobals="false"
>
<testsuites>
<testsuite name="Unit Tests">
<directory>./</directory>
</testsuite>
</testsuites>
</phpunit>
Try to run PHPUnit with --debug to see whats going on.