Test methods generation

PhpStorm 2017.3 makes it easier to create tests with all supported test frameworks.

Previously available for PHPUnit tests only, test file templates will now assist you in creating Codeception Unit, Codeception Functional, and PHPSpec Specification tests.

You can choose the desired template by selecting New | PHP Test in the Project view:

new_test_menu

Alternatively, you can invoke the Test action from within a class or a method. Simply press Shift+Command+A (Shift+Control+A on Windows) and then search for “Test”:

new_test_action

We’ve also reworked the Create New PHP Test dialog. It now allows you to switch between the test file templates as well as to choose specific class methods to create tests for:

new_test_dialog

The test class will be generated within the framework-specific class namespace and will contain stubs for the test methods:

generated_test_class

In all likelihood you will want to customize the content a template produces. Do so by navigating to Settings | Editor | File & Code Templates. Here, you can locate the test file templates on the Files tab, and test method code templates – on the Code tab:

test_templates

Stay tuned for more updates!

Your JetBrains PhpStorm Team
The Drive to Develop

This entry was posted in Cool Feature, Newsletter and tagged . Bookmark the permalink.