Phing and PHPUnit, just cant get even the most basic thing running - phpunit

Using a composer-installed bin
I'm running a most basic task as follows:
<autoloader autoloaderpath="vendor/autoload.php">
<target name="asdf">
<echo msg="test"/>
<phpunit configuration="app/phpunit.xml"
haltonerror="true"
haltonfailure="true"
pharlocation="bin/phpunit"
/>
</target>
Now simply running this task:
phing -debug asdf
Will result in:
+Task: echo
-calling setter EchoTask::setMsg()
[echo] qwerqwer
+Task: phpunit
-calling setter PHPUnitTask::setConfiguration()
-calling setter PHPUnitTask::setHaltonerror()
-calling setter PHPUnitTask::setHaltonfailure()
-calling setter PHPUnitTask::setPharLocation()
#!/usr/bin/env php
Cannot open file "asdf.php".
Using a .phar
Using the same configuration except pharlocation:
+Task: echo
-calling setter EchoTask::setMsg()
[echo] test
+Task: phpunit
-calling setter PHPUnitTask::setConfiguration()
-calling setter PHPUnitTask::setHaltonerror()
-calling setter PHPUnitTask::setHaltonfailure()
BUILD FINISHED
No errors, but the phpunit tasktype doesnt start.
Unrecognized option
Had a third simple variant that seemed fine, which resulted in 'phpunit: unrecognized option -- p' that i sadly cant reproduce..
Versions
PU 5.7
Phing 2.16
PHP 7.1

I see you used PHPUnit 5.7. Did you use namespaces in your tests?
The current version of Phing is not compatible with namespaces like PHPUnit\Framework\TestCase, you have to use the old class \PHPUnit_Framework_TestCase instead.
The next Phing's release is going to be compatible with PHPUnit's namespaces (https://github.com/phingofficial/phing/issues/659). Meanwhile you can create phpunit.xml and add this to build.xml to run your tests:
<target name="phpunit" description="Run tests">
<exec executable="bin/phpunit" passthru="true">
<arg value="--configuration"/>
<arg value="app/phpunit.xml"/>
</exec>
</target>

I faced this issue when invoking Phing using Jenkins. The Phing plugin for Jenkins adds a -buildfile switch to the command calling Phing and when I removed this switch (running the command manually), my PHPUnit test suit was executed successfully. I recommend avoiding the Phing plugin for Jenkins and using a shell execution step to invoke Phing directly:
/path/to/php /path/to/phing/binary/

Related

#PHPUnit Testing simple Code in this Link:https://phpunit.de/getting-started/phpunit-8.html

Hello I am new in PHPUnit and try to execute the Test Example:EmailTest by Composer, the Link is: https://phpunit.de/getting-started/phpunit-8.html
I got the text in the command_Line
$ phpunit --bootstrap vendor/autoload.php tests/EmailTest
PHPUnit 3.7.21 by Sebastian Bergmann.
Cannot open file "vendor/autoload.php".
It appears that you have different installations of PHPUnit mixed up.
For instance, you may have used Composer to install PHPUnit and have configured the autoloader generated by Composer as PHPUnit's bootstrap script but then you invoke PHPUnit using an executable other than vendor/bin/phpunit.

A parameter cannot be found that matches parameter name 'Script' [duplicate]

I'm building a MVC application with .Net Core and I need to generate the script of a migration.
With EF6 I did run the command
update-database -script
but when I try to do the same with .net Core is throwing the next exception:
Update-Database : A parameter cannot be found that matches parameter
name 'script'
Do you know if there is an equivalent for EF Core?
As per EF documentation you can use :
Script-Migration
If you want to just script all the migrations you can simply call it from Package Manager console like that. If you want to just script the changes from the last migration you can call it like this:
Script-Migration -From <PreviousMigration> -To <LastMigration>
Be sure to check the docs, there're a few more options to the command.
dotnet ef migrations script --help
Usage: dotnet ef migrations script [arguments] [options]
Arguments:
<FROM> The starting migration. Defaults to '0' (the initial database).
<TO> The ending migration. Defaults to the last migration.
Options:
-o|--output <FILE> The file to write the result to.
-i|--idempotent Generate a script that can be used on a database at any migration.
-c|--context <DBCONTEXT> The DbContext to use.
-p|--project <PROJECT> The project to use.
-s|--startup-project <PROJECT> The startup project to use.
--framework <FRAMEWORK> The target framework.
--configuration <CONFIGURATION> The configuration to use.
--runtime <RUNTIME_IDENTIFIER> The runtime to use.
--msbuildprojectextensionspath <PATH> The MSBuild project extensions path. Defaults to "obj".
--no-build Don't build the project. Only use this when the build is up-to-date.
-h|--help Show help information
-v|--verbose Show verbose output.
--no-color Don't colorize output.
--prefix-output Prefix output with level.
so,you can try
dotnet ef migrations script ver1 ver2
dotnet ef migrations script ver1 ver2 -o ./script.sql
This works in .Net Core 2.1
You can use dotnet core cli to generate script
dotnet ef migrations script
Also you can put this to file with new power shell out-file command.
dotnet ef migrations script | out-file ./script.sql
You can also generate a script to rollback a migration by reversing the parameters to Script-Migration. For example, if you have two migrations, BadLatestMigration and GoodPreviousMigration, you can revert to GoodPreviousMigration by using the following command
Script-Migration BadLatestMigration GoodPreviousMigration
Afterwards be sure to Remove-Migration to remove the bad migration
Remove-Migration
This works in .Net Core 2.2.0
This also generates only the SQL
Update-Database -script -TargetMigration TO -SourceMigration FROM

using phpdocumentor with Symfony3

I am wanting to use phpDocumentor with Symfony3. since they are not compatable with eachother as explained here I have installed phpDocumentor using pear as recomended.
My buidl.xml calls it like this.
<target name="phpdoc" description="Generate API documentation using PHPDocumentor">
<exec logoutput="true" command="/usr/bin/phpdoc -d ${source} -t ${basedir}/build/api" />
</target>
and when I run $ phing
I get the following error.
MyProject > phpdoc:
[exec] PHP Warning: require_once(/home/username/workspace/MyProject/vendor/dompdf/dompdf/dompdf_config.inc.php): failed to open stream: No such file or directory in /usr/share/php/phpDocumentor/src/phpDocumentor/Bootstrap.php on line 178
there is no dompdf/ folder in my vendor/ directory since it was not installed using composer
Is there anything else that I can use?
Is there a way of stopping phpdoc looking for a composer.json file and using the vendor directory of the project?
That'll likely be a bug. Right now, the PEAR and Composer installations might be unreliable. The development team recommends the PHAR instead, at least for now -- https://github.com/phpDocumentor/phpDocumentor2/issues/1859

Robot framework- Pabot Using Jython

As part of the pabot documentation
https://github.com/mkorpela/pabot
--command [ACTUAL COMMANDS TO START ROBOT EXECUTOR] --end-command
RF script for situations where pybot is not used directly
is given.Have anyone tried to use Pabot with Jybot command
Exmple:
pabot --command Jython --end-command TestCasesDirectory
It is failing with assertion Error.
The page has the example:
pabot --command java -jar robotframework.jar --end-command tests
That uses jython (embedded in the robotframework.jar) or you could also do
pabot --command jybot --end-command tests
You can't directly run your tests with Jython command in any case - so it will not work through pabot either. The actual command to run RF tests with jython is jybot.

How to use Ant with NetBeans C++ Qt applications

I'm using NetBeans C++ to build a simple Qt application. Here is what I did:
From 'File' I chose 'New project'
In the 'New project' window I selected C/C++ category and C/C++ Qt application
Then I clicked Next and on the second frame I renamed my project to 'Test'
Clicked 'Finish' and the sample project was created successfully (is is also the only project open so it is treated as the main project).
From 'Run' I chose 'Build Main Project' - the action was successful
Then I created an Ant script to build the same project from the console:
<?xml version="1.0"?>
<project name="Test.linux" default="My.Test" basedir="../..">
<description>Linux projects build</description>
<target name="My.Test">
<echo>Building my Test Linux project.</echo>
<exec executable="make" failonerror="true" dir="Test">
<arg value="-f"/>
<arg value="Makefile"/>
<arg value="clobber"/>
</exec>
</target>
</project>
When I run this script I get a peculiar error:
Test.linux:
[echo] Building my Test Linux project.
My.Test:
[echo] Building my Test Linux project.
[exec] for CONF in Debug Release ; \
[exec] do \
[exec] "make" -f nbproject/Makefile-${CONF}.mk QMAKE= SUBPROJECTS= .clean-conf; \
[exec] done
[exec] make[1]: Entering directory `/home/myusr/Development/Projects/Test'
[exec] VPATH=. -o qttmp-Debug.mk nbproject/qt-Debug.pro
[exec] /bin/sh: -o: not found
The build fails. After looking at the make files I found the following lines in Makefile-Debug.mk:
# Link Libraries and Options
LDLIBSOPTIONS=
nbproject/qt-${CND_CONF}.mk: nbproject/qt-${CND_CONF}.pro FORCE
${QMAKE} VPATH=. -o qttmp-${CND_CONF}.mk nbproject/qt-${CND_CONF}.pro
mv -f qttmp-${CND_CONF}.mk nbproject/qt-${CND_CONF}.mk
I don't understand why ${QMAKE} VPATH=. -o qttmp-${CND_CONF}.mk nbproject/qt-${CND_CONF}.pro is unacceptable and what is actually wrong.
After some pondering I noticed that NetBeans sets the value of ${QMAKE} to /usr/bin/qmake, but when I call the ant script it stays an empty string. So my question is rather how NetBeans knows where to find the qmake - is there a project setting or is it a setting of the IDE itself. Should I rely on the fact that the qmake path is always this '/usr/bin/qmake' and set ${QMAKE} variable in the ant script manually or is there another way to solve this?
Qt itself uses QTDIR to check which installation to use in case if you have several versions installed. Some linux distributions doesn't set this environment variable since in most cases it's not needed.
Good way to find out which Qt version to use is:
1) Check if ${QTDIR} exists. In this case qmake is located under ${QTDIR}/bin directory
2) If ${QTDIR} doesn't exists try to find qmake in the directories specified by ${PATH} env variable. For example using which command.
This method is used by SCons qt4 build tool (unofficial third party module for this build system). I think it should be simple to implement this algorithm with ant.

Resources