{"id":88615,"date":"2020-10-28T14:01:25","date_gmt":"2020-10-28T14:01:25","guid":{"rendered":"https:\/\/blog.jetbrains.com\/?post_type=phpstorm&#038;p=88615"},"modified":"2020-10-29T09:19:16","modified_gmt":"2020-10-29T09:19:16","slug":"how-the-pest-phpstorm-plugin-will-improve-your-testing-workflow","status":"publish","type":"phpstorm","link":"https:\/\/blog.jetbrains.com\/ja\/phpstorm\/2020\/10\/how-the-pest-phpstorm-plugin-will-improve-your-testing-workflow","title":{"rendered":"How the Pest PhpStorm Plugin Will Improve Your Testing Workflow"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2020\/10\/1_pest_plugin.png\" class=\"alignnone wp-image-88629\" alt=\"\" width=\"800\" \/><\/p>\n<p>Perhaps you\u2019ve already heard of <a href=\"https:\/\/pestphp.com\/\" target=\"_blank\" rel=\"noopener\">Pest<\/a>. It is a new PHP testing framework with a focus on simplicity. The Pest PhpStorm plugin is a new addition to PhpStorm\u2019s growing ecosystem. With this plugin, testing your code in your favorite IDE is even simpler and faster!<\/p>\n<p>The <a href=\"https:\/\/github.com\/pestphp\/pest-intellij\" target=\"_blank\" rel=\"noopener\">source code<\/a> behind the plugin is open source and community-driven, just like Pest itself.<\/p>\n<p>You can find the plugin in the <a href=\"https:\/\/plugins.jetbrains.com\/plugin\/14636-pest\" target=\"_blank\" rel=\"noopener\">JetBrains Marketplace<\/a>, a platform for plugin vendors to deliver tools like Pest to a wider audience and quickly roll out updates for everyone. Just search for &#8220;Pest&#8221; and install it from there.<\/p>\n<p align=\"center\">\n<iframe loading=\"lazy\" frameborder=\"none\" width=\"245px\" height=\"48px\" src=\"https:\/\/plugins.jetbrains.com\/embeddable\/install\/14636\"><\/iframe>\n<\/p>\n<h2 id=\"looking_around\">Looking around<\/h2>\n<p>Just like PHPUnit test, you can run your PEST test directly from PhpStorm. When you place your caret inside a test and trigger the run window, a run configuration will be created for that specific test. You can place the caret outside any particular test but still in the file to trigger all the tests in that file.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2020\/10\/2_looking_around.png\" data-gif-src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2020\/10\/2_looking_around.gif\" class=\"alignleft size-full wp-image-88649\" alt=\"\" width=\"800\" \/><\/p>\n<p>After pressing run, your new run configuration is available and can be edited. Now you can change your test or simply run the current configuration by pressing <kbd>Ctrl+R<\/kbd> (<kbd>Shift+F10<\/kbd> on Windows)<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2020\/10\/3_run_configuration.png\" class=\"alignnone wp-image-88659\" alt=\"\" width=\"800\" \/><\/p>\n<p>A run configuration can also be created by clicking the PEST styled run icon that is in the gutter on the line with the test.<\/p>\n<p>Pest lets you write assertions by calling functions or methods on <code>$this<\/code>. The plugin supports autocompletion, so you can see what assertions are available as you type!<br \/>\nPest can run some code before each test. In that code, you can assign a value to a property that will be available in the tests themselves.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2020\/10\/4_autocompletion.png\" data-gif-src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2020\/10\/4_autocompletion.gif\" class=\"alignleft size-full wp-image-88679\" alt=\"\" width=\"800\" \/><\/p>\n<p>This is very useful if you need to share some data across multiple tests. And again, the plugin can autocomplete the properties that are defined.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2020\/10\/5_property_new.png\" data-gif-src=\"https:\/\/i.imgur.com\/KxD5gHU.gif\" class=\"alignleft size-full wp-image-89346\" alt=\"\" width=\"800\" \/><\/p>\n<h2 id=\"debugging\">Debugging<\/h2>\n<p>Debugging code is often necessary. Fortunately, Pest works well with <a href=\"https:\/\/xdebug.org\/\" target=\"_blank\" rel=\"noopener\">Xdebug<\/a>.  The plugin allows you to run a test with the debugger. You will be able to see all of the debugging information directly in PhpStorm, and breakpoints can be easily added.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2020\/10\/6_debugging.png\" data-gif-src=\"https:\/\/i.imgur.com\/1qwChQN.giff\" class=\"alignleft size-full wp-image-88719\" alt=\"\" width=\"800\" \/><\/p>\n<p>Pest also supports code coverage. This means that we can see how much of our code is covered by our Pest tests and easily pinpoint where we need to add more tests. The plugin has support for code coverage, and the code coverage results can also be seen directly in PhpStorm.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2020\/10\/7_code_coverage.png\" data-gif-src=\"https:\/\/imgur.com\/m9axqzl.gif\" class=\"alignleft size-full wp-image-88739\" alt=\"\" width=\"800\" \/><\/p>\n<h2 id=\"running_together_with_phpunit\">Running together with PHPUnit<\/h2>\n<p>PHPUnit and Pest tests can be run together. This allows existing PHPUnit users to switch easily to Pest, as they won\u2019t have to convert all of their old tests but can instead transition on an as-needed basis. The plugin also follows the principle that you should be able to run two testing frameworks together as if they are one.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2020\/10\/8_running_with_phpunit.png\" data-gif-src=\"https:\/\/imgur.com\/XwH1BM5.gif\" class=\"alignleft size-full wp-image-88759\" alt=\"\" width=\"800\" \/><\/p>\n<p>We hope this post sheds some light on what Pest and its plugin for PhpStorm can do for you. If you want to stay informed about Pest, take a quick look at the<a href=\"https:\/\/pestphp.com\/\" target=\"_blank\" rel=\"noopener\"> documentation<\/a> to learn more, join the other users on <a href=\"https:\/\/discord.com\/invite\/bMAJv82\" target=\"_blank\" rel=\"noopener\">the official Discord server<\/a>, and follow <a href=\"https:\/\/twitter.com\/pestphp\" target=\"_blank\" rel=\"noopener\">Pest on Twitter<\/a>. <\/p>\n<p><em>Thanks for reading!<\/em><\/p>\n<table style=\"width: 100%; border-spacing: 0;\">\n<tbody>\n<tr style=\"background-color: #f1f6fe;\">\n<td style=\"width: 200px; height: 200px; padding: 0;\">\n<img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2020\/10\/oliver-nybroe.jpg\" class=\"alignnone wp-image-88929\" alt=\"Oliver Nybroe\" width=\"200\" \/>\n<\/td>\n<td style=\"padding: 0 0 0 32px;\">\nOliver Nybroe<br \/>\nCopenhagen, Denmark<br \/>\nLaravel backend developer at <a href=\"https:\/\/www.worksome.com\/\" target=\"_blank\" rel=\"noopener\">Worksome<\/a>.<\/p>\n<p><a href=\"https:\/\/twitter.com\/OliverNybroe\" target=\"_blank\" rel=\"noopener\">Twitter<\/a> | <a href=\"https:\/\/github.com\/olivernybroe\" target=\"_blank\" rel=\"noopener\">GitHub<\/a> | <a href=\"https:\/\/nybroe.dev\/\" target=\"_blank\" rel=\"noopener\">Blog<\/a>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n","protected":false},"author":1152,"featured_media":88629,"comment_status":"closed","ping_status":"closed","template":"","categories":[2347],"tags":[6345,41,207],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/phpstorm\/88615"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/phpstorm"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/types\/phpstorm"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/users\/1152"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/comments?post=88615"}],"version-history":[{"count":3,"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/phpstorm\/88615\/revisions"}],"predecessor-version":[{"id":399355,"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/phpstorm\/88615\/revisions\/399355"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/media\/88629"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/media?parent=88615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/categories?post=88615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/tags?post=88615"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/cross-post-tag?post=88615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}