Try Jenkins/PHP on Winows

1. install jenkin on windows 
download and install
> http://mirrors.jenkins-ci.org/windows/latest

2. install pear
download
> http://pear.php.net/go-pear.phar
run
> php go-pear.phar
add Environment Variable to your pear installation folder

3. install phpunit from pear
run
> pear config-set auto_discover 1
(set pear to search for package)
> pear install pear.phpunit.de/PHPUnit
(install pear from url)

additional
DbUnit
> pear install phpunit/DbUnit
PHP_Invoker
> pear install phpunit/PHP_Invoker
PHPUnit_Selenium
> pear install phpunit/PHPUnit_Selenium
PHPUnit_Story
> pear install phpunit/PHPUnit_Story
PHPUnit_SkeletonGenerator
> pear install phpunit/PHPUnit_SkeletonGenerator
PHPUnit_TestListener_DBUS
> pear install phpunit/PHPUnit_TestListener_DBUS
PHPUnit_TestListener_XHProf
> pear install phpunit/PHPUnit_TestListener_XHProf
PHPUnit_TicketListener_Fogbugz
> pear install phpunit/PHPUnit_TicketListener_Fogbugz
PHPUnit_TicketListener_GitHub
> pear install phpunit/PHPUnit_TicketListener_GitHub
PHPUnit_TicketListener_GoogleCode
> pear install phpunit/PHPUnit_TicketListener_GoogleCode
PHPUnit_TicketListener_Trac
> pear install phpunit/PHPUnit_TicketListener_Trac

test
> phpunit –version

4. install apache ant

windows
> https://code.google.com/p/winant/
** require JDK

PHPUnit 101
===

1. Create [User.php]

<?php
class User {
protected $name;

public function getName() {
return $this->name;
}

public function setName($name) {
$this->name = $name;
}

public function talk() {
return “Hello world!”;
}
}

2. Create [UserTest.php]

<?php
// include test target
require ‘User.php’;

class UserTest extends PHPUnit_Framework_TestCase
{
// define target object
protected $user;

// init object
protected function setup()
{
$this->user = new User();
$this->user->setName(‘Tom’);
}

// detroy after test finished
protected function tearDown()
{
unset($this->user);
}

// test talk()
public function testTalk()
{
$this->assertEquals(“Hello world!”, $this->user->talk());
}
}

3. run test

> phpunit UnitTest UserTest.php

Ant 101

1. Create [build.xml]

<project name=”user”>
<copy file=”User.php” tofile=”builds/User.php”/>
</project>

2. build file by ant
> ant -v
Ant will copy User.php to builds/User.php

3. run test before build
update build.xml

<project name=”user”>
<exec executable=”D:\wamp\bin\pear\phpunit.bat” failonerror=”true”>
<arg line=” UnitTest UserTest.php” />
</exec>
<copy file=”User.php” tofile=”builds/User.php”/>
</project>

*** executable should insert the fullpath

Jenkins 101

Create new job on jenkins dashboard
1. Click “new job”
2. enter job name
3. select free-style software project
4. ok
5. on Build trigger tab click Build periodically > Schedule
6. write “H/5 * * * *” mean build file every 5 minutes
7. on Build button click “Add build step”
8. select Invoke Ant
9. click advance
10. enter build file path
11. save

*** but for windows we prefer to use “Execute Windows batch command”
> “C:\Program Files (x86)\WinAnt\bin\ant” -file D:\wamp\www\lab\DEMO\build.xml

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s