Enter Kahlan

unified.diff

15th January 2015

Warren Seymour

warren@radify.io

@woogoose

Server

Browser

Jasmine Goodness

describe("Math", function() {
    describe(".min()", function() {
        it("returns the smallest argument", function() {
            expect(Math.min(1,2,3)).toEqual(1);
        });
    });

    describe(".max()", function() {
        it("returns the largest argument", function() {
            expect(Math.max(1,2,3)).toEqual(3);
        });
    });
});

PHPUnit Badness

<?php

namespace app\tests;

use app\lib\Math;

class MathTest extends \lithium\test\Unit {

    public function testMin() {
        $result = Math::min([1, 2, 3]);
        $this->assertEqual(1, $result);
    }

    public function testMax() {
        $result = Math::max([1, 2, 3]);
        $this->assertEqual(3, $result);
    }
}

Simon Jaillet

composer.json

{
	"autoload": {
		"psr-4": {
			"demo\\": "src/"
		}
	},
	"minimum-stability": "dev",
	"require": {
		"crysalead/kahlan": "dev-master"
	}
}

Spec Structure

describe, context, it

Expectations

expect($this)->toBe('that');

Setup/Teardown

before/afterEach

Matchers

->toBe() or ->not->toBe()

  • toEqual
  • toMatch
  • toThrow
  • toHaveLength
  • toBeA
  • toBeAnInstanceOf
  • toEcho
  • ...

Invocation Matchers

toReceive

Stubs

Look ma, no mocks!

Inheritance, Interfaces, Traits

Monkey Patching

Replace core classes & functions

Code Coverage

  • 1806 Assertions (Kahlan + li3)
  • Kahlan - 10.4 Lines / Assertion
  • li3 - 11.6 Lines / Assertion
  • Full Coverage - 1m46s
    • Was ~15m (40m on CI Server)
  • Coverage on each build
    • Was nightly

Q & A

Enter Kahlan

By Warren Seymour

Enter Kahlan

  • 1,168