How can I run unit test script in cakephp shell? - cakephp

In composer.json file php unit is added
"phpunit/phpunit": "^9.5",
I am just trying to run a test script in cmd
In project folder I have given command
vendor/bin/phpunit
Getting below result
How I will run test script using php unit in cakephp application ? My cakephp version : 4.x

In windows you have to write the command by back slash not by forward slash.
project>vendor\bin\phpunit

Related

To schedule crontab on linux env for selenium

I am running my selenium test case using "mvn clean test" and its working fine.
When tried to run it from crontab , getting error chrome driver crashed.
Tried to write shell script and provide pom , code directory etc but its of no help
any suggestions?
Suggesting to inject into your cron script 2nd line:
source /home/<your username>/.bash_profile
This will insert into your cron script all the required environment context and paths.

Jenkins/Windows - Launch TestNG suite from .bat

Stackoverflow helped me a lot to reach that point but now I'm completely stuck, here is my problem :
I'm currently developing several tests to check a website. I code with Java in Eclipse, using testNG plugin with ReportNG for report, all of this using Windows 7 pro.
My tests work, and my report is well generated, so now I have to put it on Jenkins for my company so they will run my tests every X hours.
In order to launch my tests, I have made a file, named Run.bat, which runs the Java code, I tested it and it works, here is the code :
Run.bat
set classpath=blex_test_v1\bin;blex_test_v1\lib\*
java org.testng.TestNG blex_test_v1\blex_test_v1.xml
I now try to launch the tests on Jenkins, creating a new job and configuring it with the build section :
Run.bat
And this is my problem, I've tried everything (relative path, only the name of the file etc...) I always get this error :
java.io.IOException: Cannot run program "cmd" (in directory "/var/jenkins_home/jobs/blex_functional_test/workspace"): error=2, No such file or directory
So I checked the Jenkins workspace but my Run.bat is in it :
Workspace
I have read that Jenkins is in Linux so it might cause problem with bat files, so I tried to create a script but I didn't succeed either ..
So my question is : How can I run my test on Jenkins using my file Run.bat ? What am I doing wrong here ?
Thanks a lot !
Finally I can add an answer :
Jenkins is installed on a Unix machine so you can't run a bat file, it has to be a bash script.
To create a bash script, refer here.
Then you have to make sure that the plugin Xvfb is installed (and works) on the computer where Jenkins is installed.
I use testNG with reportNg and it doesn't work with the last firefox version so you I use firefox v34.0.5 and this version must be installed also on the Jenkins computer.
If you want to open the report after the execution, install another plugin and configure it (report HTML or something like that)
God it took me about a week but it's good to see it working !

manage Jenkins build status

I'd like to run batch using jenkins. And the status of build depends of number of files created in a specific folder. My question is how could I manage Jenkins build status depending of number of files created?
You can execute a shell script to count the files and return 1, if the count isn't expected.
Another way would be to use the Text-finder Plugin searching for a pattern in the console log.
Groovy Postbuild Plugin is another alternative:
buildUnstable() - sets the build result to UNSTABLE.
If you like to use the CLI you can use the following command:
java -jar jenkins-cli.jar -s http://...:8080/ set-build-result
Sets the result of the current build. Works only if invoked from within a build.

Unable to execute TestNG Suite file via command line

I am trying to execute a TestNG Suite file via the command line in order to initiate a regression run.
Currently I am doing this through my Eclipse IDE successfully by right-click on the "testng.xml" file then selecting Run As > TestNG Suite.
However, when I try to run it via the command line, I get an error message. Steps below:
I navigate to the directory where my "testng.xml" file is saved. e.g. C:\Users\xxx\Documents\eclipse projects\Automated Testing\config
Run the command:
java org.testng.TestNG testng.xml
The above command generates the below response:
Error: Could not find or load main class org.testng.TestNG
I tried setting the classpath to include all of the selenium and testNG Jar files as per below:
set classpath C:/Users/xxxx/Downloads/selenium-java-2.25.0/selenium-2.25.0/libs/*
However, this generates the below error message:
Environment variable classpath C:/Users/xxxx/Downloads/selenium-java-2.25.0/selenium- 2.25.0/libs/* not defined
I have looked on the testNG Documentation (http://testng.org/doc/documentation-main.html) and this just says that testNG has to be in your classpath, so now I am a bit stuck. Any help would be greatly appreciated.
Either methods work :)
Method #1
cd C:\Workspace\projectname
java -cp C:\Workspace\projectname\lib\*;C:\Workspace\projectname\bin org.testng.TestNG testng.xml
Method #2
cd C:\Workspace\projectname
set ProjectPath=C:\Workspace\projectname
echo %ProjectPath%
set classpath=%ProjectPath%\bin;%ProjectPath%\lib\*
echo %classpath%
java org.testng.TestNG %ProjectPath%\testng.xml
Thanks #siemic, I have finally got it working now. Basically you just need
to run the two commands below:
set classpath=..\bin;C:\libs\selenium-java-2.25.0.jar;C:\libs\testng-6.0.1-nobsh
noguice.jar;C:\libs*
java org.testng.TestNG
It was the first command that I was having trouble with, so just to elaborate I needed to set the following three items on the classpath:
The BIN Directory of my project. This is because the java files that I have developed are located here.
The Selenium.jar file, this is because I am using the selenium framework
The testng.jar file, needed because this is my unit testing framework
Then finally I used a wildcard to include all other JAR files within my libraries folder. The weird thing
is I needed to fully specificy the name of the selenium and testng jar files, or else the tests don't work. Not too sure why.
Anyway it is working fine now and I am able to execute the tests via the command line.

Automating silverlight unit tests using StatLight and TeamCity

What is the best way to run silverlight unit tests automatically using team city?
I have found StatLight which we had working well when we used cc.net, and it says that it has support for teamcity. Does this just mean the test results output file is compatible with teamcity? Do I need to create a command line runner to run the tests? If so how do I get the test results into team city?
Thanks
TeamCity has an extensibility feature where you can output special commands to the console and the TeamCity agent will capture the commands and publish the results within TeamCity.
If you get StatLight running on your desktop - do a regular console-run. Then do another run by giving it the "--teamcity" parameter. Notice the difference in the output?
In TeamCity you can setup a Command Line Build Runner
Command executable: "<Path to statlight.exe>"
Command parameters: "-x=%system.teamcity.build.checkoutDir%\PathToXap\SilverlightClient.Tests.xap --teamcity"
Hope this helps.
There's also a StatLight TeamCity plugin that adds a test runner.
You can try using Lighthouse Silverlight Unit Test Runner, it works with every Build Server including TeamCity and CCNet because it by default produces NUnit compatible xml results file:
http://lighthouse.codeplex.com/

Resources