Main

My projects

Spectrum

About framework

Spectrum is a PHP framework for test automation.

Spectrum requires PHP 5.3 or later.

Spectrum is licensed under the free "New BSD License" (license text and copyright).

You can download source code from https://github.com/m-haritonov/spectrum.

Current version is alpha and not stable.

Tests

Tests destination is code declaration that executes expected result checking. Tests are declared by test function call.

require_once 'spectrum/init.php'; test('Does something useful', function(){ be(111)->ident(111); }); \spectrum\run();

Groups

Groups destination is tests into group union. Groups are declared by group function call and can contains tests and groups.

require_once 'spectrum/init.php'; group('Group 1', function(){ test('Does something useful', function(){ be(111)->ident(111); }); group('Group 1', function(){ test('Does something useful', function(){ be(111)->ident(111); }); }); }); \spectrum\run();

You can create groups without name. It is useful for contexts.

require_once 'spectrum/init.php'; group(function(){ before(function(){ // Does actions before each test }); test('Does something useful', function(){ be(111)->ident(111); }); test('Does something useful', function(){ be(111)->ident(111); }); }); \spectrum\run();

Contexts

Contexts destination is same settings union of several tests and same code in different environment execution (with different settings). Executed before and after tests code is declared by before and after function call.

require_once 'spectrum/init.php'; before(function(){ // Does actions before each test }); after(function(){ // Does actions after each test }); test('Does something useful', function(){ be(111)->ident(111); }); test('Does something useful', function(){ be(111)->ident(111); }); \spectrum\run();

data function is available inside before, after and test functions. data function returns object for data storage (creates before each before/text/after sequence call).

require_once 'spectrum/init.php'; before(function(){ data()->someClass = new SomeClass(); }); test('Does something useful', function(){ be(data()->someClass->someMethod1())->ident(111); }); test('Does something useful', function(){ be(data()->someClass->someMethod2())->ident(111); }); \spectrum\run();

test and group functions call with addition parameters is uses for same test or group in different environment executing.

require_once 'spectrum/init.php'; // Context (second parameter) is array test('Does something useful', array( array('value' => 111), array('value' => '1 1 1'), array('value' => '11 1'), array('value' => '1 11'), ), function(){ $someClass = new SomeClass(); be($someClass->someMethod1(data()->value))->ident(111); }); // Context (second parameter) is function test('Does something useful', function(){ before(function(){ data()->someClass = new SomeClass(); }); group('111', function(){ before(function(){ data()->value = 111; }); }); group('1 1 1', function(){ before(function(){ data()->value = '1 1 1'; }); }); group('11 1', function(){ before(function(){ data()->value = '11 1'; }); }); group('1 11', function(){ before(function(){ data()->value = '1 11'; }); }); }, function(){ be(data()->someClass->someMethod1(data()->value))->ident(111); }); // Context (second parameter) is array on group group('Group 1', array( array('value' => 111), array('value' => '1 1 1'), array('value' => '11 1'), array('value' => '1 11'), ), function(){ before(function(){ data()->someClass = new SomeClass(); }); test('Does something useful', function(){ be(data()->someClass->someMethod1(data()->value))->ident(111); }); test('Does something useful', function(){ be(data()->someClass->someMethod2(data()->value))->ident(111); }); }); // Etc. \spectrum\run();

Asserts and matchers

In progress.

Run

In progress.

Run results

In progress.

Error handling

In progress.

Configuration

In progress.

Builders

In progress.

Plugins

In progress.

Function and class replacing

In progress.

E-mail for contacts: mail@m-haritonov.net