When running PHPUnit, if there are no errors it runs in aprox. 6 seconds, nevertheless if there are errors it can take up to 3 or 4 minutes....Only to report the error information.
I'm running PHP version 5.5.3 and PHPUnit version 3.7.28 in Windows.
The tests are painfully simple, even the simplest assertion fail makes the test report take forever.
class MyTest extends PHPUnit_Framework_TestCase
{
public function someTest() {
$this->assertEquals(true, false); // takes forever to report
}
}
Running a database test with --debug I get the following output
D:\xampp\htdocs\blueberry-cms
λ phpunit --debug tests\unit\DatabaseTest.php
PHPUnit 3.7.28 by Sebastian Bergmann.
Starting test 'DatabaseTest::testCRUD'.
F
Starting test 'DatabaseTest::testRetrieval'.
.
Time: 8.91 seconds, Memory: 2.25Mb
There was 1 failure:
1) DatabaseTest::testCRUD
Failed asserting that 19 matches expected 18.
D:\xampp\htdocs\blueberry-cms\tests\unit\DatabaseTest.php:37
FAILURES!
Tests: 2, Assertions: 22, Failures: 1.
The test runs fine until "There was 1 failure:" then it stops outputting text... stops for like 2 or 3 minutes and then finishes outputting text.
I'm having the same issue. I found out a workaround:
Download a .phar copy of PHPunit and put it in your document root. (link to phpunit downloads page)
Instead of running the phpunit command from the php "bin folder" (or wherever you have it in your $PATH), run php phpunit.phar from the root of my repository.
Ej: php phpunit.phar --bootstrap=./tests/bootstrap.php ./tests/
Probably this issue can be solved by updating phpunit.
(In my case (PHP 5.6) the phpunit version in my PHP "bin folder" is 3.7.21, while the .phar I downloaded is version 4.8.36)
I haven't tested this, but it should work as well:
Replace the phpunit version located in your php "bin folder" (or in wherever you have it in your $PATH)
Now every time you run phpunit you will be using the latest version, whithout having to copy the .phar to every new project.
Related
I have a deno repository of my own. I have recently switched to a new machine, and I have git clone'd that repository to my new machine.
Now when I run deno task start, it fails with this error
❯ deno task start
Task start deno run -A --watch=static/,routes/ dev.ts
Watcher Process started.
The manifest has been generated for 3 routes and 2 islands.
error: The source code is invalid, as it does not match the expected hash in the lock file.
Specifier: https://esm.sh/*preact-render-to-string#5.2.4
Lock file: /Users/john/my-project/deno.lock
I have read this page, but it is not telling me exactly what to do for my error
https://deno.land/manual#v1.29.4/basics/modules/integrity_checking
Based off of what that page says, the contents of one of your dependencies has changed since your original computer downloaded it for the first time, so the hash of the contents are different.
If you just want to ignore this, it says to use the flags
--lock=deno.lock --lock-write
which I assume means to run
deno task start --lock=deno.lock --lock-write
This will overwrite the current lock file with the new version of the code.
While this will work, the better option for the future is to specify the version in your dependency url.
For example, instead of
import { z } from "https://deno.land/x/zod/mod.ts";
you should say
import { z } from "https://deno.land/x/zod#v3.20.2/mod.ts";
(the #v3.20.2 specfies the exact dependency version)
I have a symfony command to send emails. In the terminate listener, I run this command.
Below is the command I run,
php ../app/console insead:email:prepare <Base64 information> &
I passed & (Ampersand) sign to the command in order to spawn a new process on the shell.
The version of Symfony was 2.4 and it was working fine. Last week I updated the version to 2.7 and now it is not working.
It seems the command is not running in the shell. I am using Symfony Process.
$process = new Process($command, $this->rootDir);
$process->start();
I tried to get errorOutput, output and all of them return empty.
Did anybody face this kind of issue?
(Note - My operating system is Windows 7 and I am running my application on top of WAMP)
Simple tests are timing-out intermittently on CircleCi. This only happens on CircleCi, locally on OSX, all testing is fine. Anyone having success with CircleCi specifically?
Running tests should be straightforward, but no one at CircleCI, or at the velocity forum have been able to solve this.
I've used the simple example tests from sanjo:jasmine. Intermittently, velocity hangs and goes to timeout. No errors. Nothing informative in logs. Strangely it did work once on CircleCi, and then never again.
The test command is simply:
meteor --test
The output I get doesn't print any tests:
stream error Network error: ws://localhost:3000/websocket: connect ECONNREFUSED
[[[[[ ~/app ]]]]]
=> Started proxy.
=> Started MongoDB.
=> Started your app.
=> App running at: http://localhost:3000/
In the .meteor/local/log/jasmine-client-unit.log this is the last line:
Chrome 38.0.2125 (Linux): Executed 0 of 0^[[32m SUCCESS^[[39m (0 secs / 0 secs)
^[[1A^[[2KChrome 38.0.2125 (Linux): Executed 0 of 0^[[31m ERROR^[[39m (0.023 secs / 0 secs)
I confirmed that the versions are the same Meteor 1.03.2, Node 0.10.33, Phantomjs 2.0.0, Chrome 40. Sorry that I can't provide a reproducible repository, it's a very intermittent error likely related to environment.
Try meteor --test --once
The once might be the reason it's not finishing up
edit
It turns out that jasmine end to end testing recommends webdriver as well. So my advice below should still apply for jasmine.
/edit
What framework? If it is cucumber, the issue is the phantomjs version that gets installed doesn't install the right binary for some reason.
For that reason, in CI, you need to install phantom and set the path as an environment variable.
npm install -g phantomjs
export PHANTOM_PATH=`which phantomjs`
This will tell webdriver to use your path of the correctly installed binary instead of the wrong version.
We should really just fix Cucumber.js to not fail silently.
The other error you are seeing about websockets is just --test not connecting right on startup, it doesn't affect anything.
I am building a Qt GUI application via Jenkins. I added 3 build steps:
Building the test executable
Running the test executable
compiling a coverage report with gcovr
For some reason, the shell task for running the test executable stops after execution. Even a simple echo does not run after. The tests are written with Google Test and output xUnit XML files, which are analyzed after the build.
Some tests start the applications user interface, so I installed the jenkins xvnc plugin to get them to run.
The build tasks are as follows:
Build
cd $WORKSPACE/projectfiles/QMake
sh createbin.sh
Test
cd $WORKSPACE/bin
./Application --gtest_output=xml
Coverage Report
cd $WORKSPACE/projectfiles/QMake/out
gcovr -x -o coverage.xml
Now, an echo at the end of the first build task is correctly printed, but an echo at the end of the second is not. The third build task is therefore not even run, although the Google Test output is visible. I thought that maybe the problem is that some of the Google Tests fail, but why whould the script stop executing just because the tests fail?
Maybe someone can give me a hint on why the second task stops.
Edit
The console output looks like this:
Updating svn://repo/ to revision '2012-11-15T06:43:15.228 -0800'
At revision 2053
no change for svn://repo/ since the previous build
Starting xvnc
[VG5] $ vncserver :10
New 'ubuntu:10 (jenkins)' desktop is ubuntu:10
Starting applications specified in /var/lib/jenkins/.vnc/xstartup
Log file is /var/lib/jenkins/.vnc/ubuntu:10.log
[VG5] $ /bin/sh -xe /tmp/hudson7777833632767565513.sh
+ cd /var/lib/jenkins/workspace/projectfiles/QMake
+ sh createbin.sh
... Compiler output ...
+ echo Build Done
Build Done
[VG5] $ /bin/sh -xe /tmp/hudson4729703161621217344.sh
+ cd /var/lib/jenkins/workspace/VG5/bin
+ ./Application --gtest_output=xml
Xlib: extension "XInputExtension" missing on display ":10".
[==========] Running 29 tests from 8 test cases.
... Test output ...
3 FAILED TESTS
Build step 'Execute shell' marked build as failure
Terminating xvnc.
$ vncserver -kill :10
Killing Xvnc4 process ID 1953
Recording test results
Skipping Cobertura coverage report as build was not UNSTABLE or better ...
Finished: FAILURE
Generally, if one Build Step fails, the rest will not be executed.
Pay attention to this line from your log:
[VG5] $ /bin/sh -xe
The -x makes the shell print each command in console before execution.
The -e makes the shell exit with error if any of the commands failed.
A "fail" in this case, would be a return code of not 0 from any of the individual commands.
You can verify this by running this directly on the machine:
./Application --gtest_output=xml
echo $?
If the echo $? displays 0, it indicates successful completion of the previous command. If it displays anything else, it indicates an error code from the previous command (from ./Application), and Jenkins treats it as such.
Now, there are several things at play here. First is that your second Build Step (essentially a temporary shell script /tmp/hudson4729703161621217344.sh) is set to fail if one command fails (the default behaviour). When the Build Step fails, Jenkins will stop and fail the whole job.
You can fix this particular behaviour by adding set +e to the top of your second Build Step. This will not cause the script (Build Step) to fail due to individual command failure (it will display an error for the command, and continue).
However, the overall result of the script (Build Step) is the exit code of the last command. Since in your OP, you only have 2 commands in the script, and the last is failing, it will cause the whole script (Build Step) to be considered a failure, despite the +x that you've added. Note that if you add an echo as the 3rd command, this would actually work, since the last script command (echo) was successful, however this "workaround" is not what you need.
What you need is proper error handling added to your script. Consider this:
set +e
cd $WORKSPACE/bin && ./Application --gtest_output=xml
if ! [ $? -eq 0 ]; then
echo "Tests failed, however we are continuing"
else
echo "All tests passed"
fi
Three things are happening in the script:
First, we are telling shell not to exit on failure of individual commands
Then i've added basic error handling in the second line. The && means "execute ./Application if-and-only-if the previous cd was successful. You never know, maybe the bin folder is missing, or whatever else can happen. BTW, the && internally works on the same error code equals 0 principle
Lastly, there is now proper error handling for the result of ./Application. If the result is not 0, then we show that it had failed, else we show that it had passed. Note, this since the last command is not a (potentially) failing ./Application, but an echo from either of if-else possibilities, the overall result of the script (Built Step) will be a success (i.e 0), and the next Build Step will be executed.
BTW, you can as well put all 3 of your build steps into a single build step with proper error handling.
Yes... this answer may be a little longer than what's required, but i wanted you to understand how Jenkins and shell treat exit codes.
I'm supposed to run some jbehave(automated) tests in bamboo. Once the tests run I'll generate some junit compatible xml files so that bamboo could understand the same. All the jbehave tests are ran as part of a script, because I need to run the jbehave tests in a separate display screen(remember these are automated browser tests). Example script is as follows.
Ex:
export DISPLAY=:0 && xvfb-run --server-args="-screen 0, 1024x768x24"
mvn clean integration-test -DskipTests -P integration-test -Dtest=*
I have one more junit parser task which points to the generated junit compatible xml files. So, once the bamboo build runs and even if all the tests pass, I get red build with the message "No failed tests found, a possible compilation error occurred."
Can somone please help me on this regard.
Your build script might be producing successful test reports, but one (or both, possibly) of your tasks is failing. That means that the failure is probably* occurring after your tests complete. Check your build logs for errors. You might also try logging in to your Bamboo server (as the bamboo user) and running the commands by hand.
I've seen this message in the past when our test task was crashing halfway through the test run, resulting in one malformed report that Bamboo ignored and a bunch of successful reports.
*Check the build log to make sure that your tests are indeed running. If mvn clean doesn't clean out the test report directory, Bamboo might just be parsing stale test reports.
EDIT: (in response to Kishore's links)
It looks like your task to kill Xvfb is what is causing the build to fail.
18-Jul-2012 09:50:18 Starting task 'Kill Xvfb' of type 'com.atlassian.bamboo.plugins.scripttask:task.builder.script'
18-Jul-2012 09:50:18
Beginning to execute external process for build 'Functional Tests - Application Release Test - Default Job'
... running command line:
/bin/sh
/tmp/FUNC-APPTEST-JOB1-91-ScriptBuildTask-4153769009554485085.sh
... in: /opt/bamboo-home/xml-data/build-dir/FUNC-APPTEST-JOB1
... using extra environment variables:
<..snip (no meaningful output)..>
18-Jul-2012 09:50:18 Failing task since return code was 1 while expected 0
18-Jul-2012 09:50:18 Finished task 'Kill Xvfb'
What does your "Kill Xvfb" script do? Are you trying something like pkill -f "[x]vfb"? pkill -f silently returns non-zero if it can't match the expression to any processes.
My solution was to make a 'script' task:
#!/bin/bash
/usr/local/bin/phpcs --report=checkstyle --report-file=build/logs/checkstyle.xml --standard=PSR2 ./lib | exit 0
Which always exits with status 0.
This is because PHP code sniffer return exit status 1 when only 1 coding violation (warning / error) is found which causes the built to fail.
Turns out to be a simple fix.
General bamboo behavior is to scan the entire log and see for any failure codes(1). For this specific configuration i had some 6 scripts out of which one of them was to kill the xvfb(frame buffer). For some reason server is not able to kill xvfb and that task was returning a failure code. Because of this, though all the tests passed, bamboo got one of this error codes from previous tasks and build was failing.
Current fix is to remove the task which kills xvfb and the build went green! \o/.