ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

testify

A Sublime Text plugin aimed at making writing PHPUnit tests less painful.

Labels test

Details

  • 2014.02.13.14.00.08
  • github.​com
  • github.​com
  • 10 years ago
  • 2 hours ago
  • 10 years ago

Installs

  • Total 225
  • Win 103
  • Mac 75
  • Linux 47
May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12 May 11 May 10 May 9 May 8 May 7 May 6 May 5 May 4 May 3 May 2 May 1 Apr 30 Apr 29 Apr 28 Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6
Windows 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

testify

A Sublime Text plugin aimed at making writing PHPUnit tests less painful.

Installation

  1. Download the file
  2. Unarchive the file in Sublime Text packages folder

The new menus and command palette options should appear in yout Sublime Text installation

Usage

Natural language test names

The plugin will take test method names written in natural language

should throw for something
should not call that when called with this
constructor properly sets some value
constructor will not do something
some method should fail with foo, baz and bar

and will transform those in proper PHPUnit test methods like

public function SomethingProvider()
{
    // $something
    return array(
        array(null)
    );
}

/**
 * @dataProvider SomethingProvider
 */
public function testShouldThrowForThis($something)
{
    $this->markTestIncomplete('This test has not been implemented yet.');
}

/**
 * @dataProvider ThisProvider
 */
public function testShouldNotCallThatWhenCalledWithThis($this)
{
    $this->markTestIncomplete('This test has not been implemented yet.');
}
public function testConstructorProperlySetsSomeValue()
{
    $this->markTestIncomplete('This test has not been implemented yet.');
}
public function testConstructorWillNotDoSomething()
{
    $this->markTestIncomplete('This test has not been implemented yet.');
}

public function FooBazBarProvider()
{
    // $foo, $baz, $bar
    return array(
        array(null, null, null)
    );
}

/**
 * @dataProvider FooBazBarProvider
 */
public function testSomeMethodShouldFailWithFooBazAndBar($foo, $baz, $bar)
{
    $this->markTestIncomplete('This test has not been implemented yet.');
}

using camelCase notation.

Data Providers

The plugin will presume that lines containing the words with or for are for tests that will require a dataProvider method and will generate the data provider and the associated variables by default as seen in the first, second and fifth line above. The plugin will also avoid generating duplicate data provider methods. Appending a trailing - to the line will prevent the plugin from generating a data provider method

add default throws for null value argument-

will generate

public function testAddDefaultThrowsForNullValueArgument()
{
    $this->markTestIncomplete('This test has not been implemented yet.');
}

while

add default throws for null value argument

would generate the test method and the data provider method as well

public function NullValueArgumentProvider()
{
    // $nullValueArgument
    return array(
        array(null)
    );
}

/**
* @dataProvider NullValueArgumentProvider
*/
public function testAddDefaultThrowsForNullValueArgument($nullValueArgument)
{
    $this->markTestIncomplete('This test has not been implemented yet.');
}

which might not always be the desired result.