Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
291 lines (184 sloc) 7.68 KB

Integration of atoum in your IDE

Sublime Text 2

A plug-in for SublimeText 2 allows the execution of unit tests by atoum and the visualization of the results without leaving the editor.

The information necessary for its installation and its configuration are available on the blog's author.

VIM

atoum comes with a plug-in for VIM.

It lets you run tests and obtain a report in a separate window without leaving VIM.

It's possible to navigate through errors, or even to go to the line in the editor with an assertion from failed test with a simple combination of keystrokes.

Installation of the plug-in atoum for VIM

You will find the file corresponding to the plug-in, named atoum.vmb inside the dedicated repository. Once you have the atoum.vmb file, you need to edit it with VIM:

$ vim path/to/atoum.vmb

Now install the plug-in by using the command in VIM:

:source %

Use of the atoum plug-in for VIM

To use the plug-in, atoum must be installed and you must be editing a file containing a class of unit tests based on atoum.

Once configured, the following command will launch the execution of tests:

:Atoum

The tests will be executed, and once finished, a report based on the configuration of atoum file located in the directory ftplugin/php/atoum.vim in your .vim directory is generated in a new window.

Of course, you are free to bind this command to any combination of keystrokes of your choice, for example adding the following line in your .vimrc file:

nnoremap *.php <F12> :Atoum<CR>

F12 in normal mode will call the command :Atoum.

Configuration file management of atoum

You can specify another configuration file for atoum by adding the following line to your .vimrc file:

call atoum#defineConfiguration('/path/to/project/directory', '/path/to/atoum/configuration/file', '.php')

Indeed the function atoum#defineConfiguration lets you configure the file to use, based on the directory where the unit test files are located. It take three arguments:

  • a path to the directory containing the unit tests;
  • a path to the configuration file of atoum to be used;
  • the extension's file of relevant unit tests.

You can access help about the plug-in in VIM with the following command:

:help atoum

Coverage reports inside vim

You can configure a specific :ref:`report<reports-using>` for the coverage in vim. In your atoum configuration file, set:

<?php
use \mageekguy\atoum;
$vimReport = new atoum\reports\asynchronous\vim();
$vimReport->addWriter($stdOutWriter);
$runner->addReport($vimReport);

PhpStorm

atoum comes with an official plug-in for PHPStorm. It really helps you in your day-to-day development. The main functionality are:

  • Go to the test class from the tested class (shortcut : alt+shift+K)
  • Go to the tested class from the test class (shortcut : alt+shift+K)
  • Execute tests inside PhpStorm (shortcut : alt+shift+M)
  • Easily identify test files by a custom icon

Installation

It's easy to install, simply follow theses steps:

  • Open PhpStorm
  • Go to File -> Settings, then click on Plugins
  • Click on Browse repositories
  • Search for atoum in the list, then click on the install button
  • Restart PhpStorm

If you need more information check the repository of the plugins.

Atom

atoum comes with an official package for atom. It helps you in several tasks:

  • A panel with all tests
  • Run all the tests, a directory or the current one

Installation

It's easy to install, simply follow the official documentation or theses steps:

  • Open atom
  • Go to Settings, then click on Install
  • Search for atoum in the list, then click on the install button

If you need more information check the repository of the package.

netbeans

atoum is officially integrated into netbeans since a long time, so you have nothing to do. Check this tutorial on how to use netbeans with atoum.

Automatically open failed tests

atoum is able to automatically open files from failed tests at the end of there execution. Several editors are currently supported:

To use this feature, you need to change the :ref:`configuration file <fichier-de-configuration>` following you ide:

Note

You also simplfy you life using an extension that do it for you.

macvim

<?php
use
    mageekguy\atoum,
    mageekguy\atoum\report\fields\runner\failures\execute\macos
;

$stdOutWriter = new atoum\writers\std\out();
$cliReport = new atoum\reports\realtime\cli();
$cliReport->addWriter($stdOutWriter);

$cliReport->addField(new macos\macvim());

$runner->addReport($cliReport);

gvim

<?php
use
    mageekguy\atoum,
    mageekguy\atoum\report\fields\runner\failures\execute\unix
;

$stdOutWriter = new atoum\writers\std\out();
$cliReport = new atoum\reports\realtime\cli();
$cliReport->addWriter($stdOutWriter);

$cliReport->addField(new unix\gvim());

$runner->addReport($cliReport);

PhpStorm

If you are under Mac OS X, use the following configuration:

<?php
use
    mageekguy\atoum,
    mageekguy\atoum\report\fields\runner\failures\execute\macos
;

$stdOutWriter = new atoum\writers\std\out();
$cliReport = new atoum\reports\realtime\cli();
$cliReport->addWriter($stdOutWriter);

$cliReport
    // If PhpStorm is installed in /Applications
    ->addField(new macos\phpstorm())

    // If you have installed PhpStorm
    // in another directory than /Applications
    // ->addField(
    //     new macos\phpstorm(
    //         '/path/to/PhpStorm.app/Contents/MacOS/webide'
    //     )
    // )
;

$runner->addReport($cliReport);

Under Unix environment, use the following configuration:

<?php
use
    mageekguy\atoum,
    mageekguy\atoum\report\fields\runner\failures\execute\unix
;

$stdOutWriter = new atoum\writers\std\out();
$cliReport = new atoum\reports\realtime\cli();
$cliReport->addWriter($stdOutWriter);

$cliReport
    ->addField(
        new unix\phpstorm('/path/to/PhpStorm/bin/phpstorm.sh')
    )
;

$runner->addReport($cliReport);

gedit

<?php
use
    mageekguy\atoum,
    mageekguy\atoum\report\fields\runner\failures\execute\unix
;

$stdOutWriter = new atoum\writers\std\out();
$cliReport = new atoum\reports\realtime\cli();
$cliReport->addWriter($stdOutWriter);

$cliReport->addField(new unix\gedit());

$runner->addReport($cliReport);