So this is my dilemma - I am using the excellent codeigniter-simpletest library by Eric Barnes (http://github.com/ericbarnes/codeigniter-simpletest). Its perfect for my purposes, as it adds an endpoint onto the test deployment of my CodeIgniter application, from which I have a dashboard to run all my unit tests and view the results. Everything fine so far.
But now I come to integrating it into my Phing build script (so that a phing release call on my test build will trigger the unit tests and fail the build if any of the tests fail), and I'm stuck.
Due to the integration package to make codeigniter play nice with simpletest, the command line runner of simpletest is not an option (I don't think).
Is there a way to invoke a URL from phing, and grab the resulting HTML? I could insert some hidden HTML into the built unit tests results page and check for it from the Phing task.
A new task HttpGetTask was recently added to Phing that should help you, it will be released in the next release (2.4.3).
Related
I've got an application developed in kohana 3.2. I want to write some functional tests that will affect database content. I would like to load the database from a dump file each time I run all functional test suite (so that I'm sure I can write and remove from the database as much as I want).
How can I do that in Kohana? Does it support functional testing anyhow?
Kohana supports unit testing with the unit test module and php unit installed. It sounds like you may be possibly want to do unit testing with mock objects. You could also set up your database using your models or a dump file too. Full functional testing is possible as well. A good place to start is enable the testing module and then start here...
https://github.com/kohana/unittest/tree/3.2/master/guide
And phpunit here...
https://github.com/sebastianbergmann/phpunit/
I use Codeception for all of my acceptance test, functional tests, and unit tests which is powered by PHPUnit. It is the best testing framework that I have found for PHP. You can pre-load sql dumps prior to functional tests and query directly against the database. It also integrates easily with Selenium for testing browsers.
I released a vagrant development environment with an empty checkout of Kohana 3.3.1 if you want to try it out Codeception. The tests are incredibly easy to write.
Intro to Vagrant with Kohana and Zen Kommerce
Codeception
I am new in PrestaShop and I need to create custom module, with XML files parsing and database operations. I would like to create unit test for this module, because I don't want to test it 'by hand'. Could you provide me any advices, methods or articles on the Web about the patterns how to do it well? I can't find good tutorial using web search engine.
I did write a blog post about testing prestashop with Mink and Behat (Cucumber equivalent) which you can read here - http://xavierriley.co.uk/blog/2012/10/12/test-driving-prestashop-with-behat/
There's also this pull request on Github for adding unit tests to the project - https://github.com/PrestaShop/PrestaShop/pull/70
The tooling for testing things like this in PHP doesn't seem to be as mature as the Ruby/Java equivalents so don't get your hopes up, but that should be a start.
I'm using php-codeigniter framework and to perform unit-test I use simple-test framework.
Simple-test generates an xml report which is stored in a file while running test cases. Both the application and test-files are committed in jenkins.
Whenever I perform a commit I need unit_test.php to be run automatically and based on the xml file output the build should be generated.
Is there a possible way for it......?
You can start with the PHP templates for jenkins.
You will need to setup Apache Ant on your CI box and configure the xml template to run the differents metric you want, like phpUnit, phpLOC, phpMD, phpCPD, etc.
Based on the output on each metric, you can then flag if the build fail, pass or just keep the metric for further references.
For simple-test, you might have to dig a bit further since its not a documented procedure here is a link
We're considering using a CI server soon.
From my reading, I've found that Sismo and Hudson were available for PHP project.
Considering that we're actually using GIT and PHPUnit, what are the big difference between Hudson and Sismo that we should know in order to make the best choice for our situation ?
Thanks
The language match is not key in your hunt for the best CI server; it's all the features around:
source control
concurrent build
trigger build
notification
Even for simple project, Jenkins (the new name for Hudson) is easy to use and quick to install. Then it is really easy to scale Jenkins up by adding more nodes (satellite machine that can execute build) when you need to. Also Jenkins has hundreds of plugin for numerous task.
Have a look at Bamboo, Jenkins, TeamCity, and CruiseControl Features to compare some of the features of the big names (you might actually want to consider Bamboo, TeamCity or Cruise Control over Jenkins)
I would lean towards Sismo since it matches the language of the project you are developing (PHP) and can be ran from just a single PHP and config file. Then you don't have to deal with having a java environment just for Hudson.
There is a really good php-integration for Jenkins by the phpunit inventor Sebastian Bergmann. You should really have a look at it.
As far as I see the biggest downside of Sismo is, that is not a "real" CI server, but more a build-and-report-environment, because you need to trigger the builds yourself (or let something trigger it).
I'll preface this by saying that I haven't used sismo.
We use Hudson with applications being built & tested in both Java and PHP. It has a nice plugin system, and getting it up and running on a centOS box took about 15 minutes yesterday. (We had to move it from one box to another).
For PHP Hudson integrates with both PHPUnit and Selenium so we run both unit tests and functional tests against the same codebase. Hudson has a great 'one-click' plugin system that really lets you customize your installation.
One thing we had to get a plugin for was sending an email on every build whether successful or not. Hudson by default will only email when your build goes from good (tests pass) to bad, from bad to good, or repeatedly bad. This means it will not send an email for every build if 2 builds in a row were successful. The email plugin solves this but it was confusing to uncover that.
I asked a question here on automated deployment of automatically deploying java code.
Our back-end Java API is accessed by a PHP web app. It would be nice to be able to automatically deploy this web app (along with static files like CSS, JS and images) to our web server while performing automatic testing on PHP code. Is there something similar to this for PHP?
I also wonder if as part of this automated testing you can check that each actual page loads without a fatal error. I am sure I read about a google project which allows you to write page tests e.g. click on link a, go to page b etc etc.
Thanks
You may want to look into using Phing for deployment which has features that allow testing with PHPUnit and/or SimpleTest
Maybe this question handling deployment strategies can help you.
Additionally, but maybe gone too far, tools like cruise control may help you to apply continuous integration, too.
PHPUnit with ant was my way to go for automated testing, which could be a vaild option for you, too since you're obviously using some java already :)
Since you're working with Java, you might consider using Hudson (also mentioned in your other question), which has the ability to execute build tasks consisting of several 'steps' One step step could be unit testing your Java App, another unit testing a PHP app, yet another deployinhg Java app, and another deploying a PHP app (and you could add some more ;P )
It has a Maven plugin, so you could actually use your existing Maven scripts.