8000 GitHub - behastan/behastan: Modern Static analysis for Behat tests
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

behastan/behastan

Repository files navigation

Behastan - Modern Static analysis for Behat tests

Downloads total

Swiss knife in pocket of every upgrade architect!


Install

composer require behastan/behastan --dev

Features

1. Find duplicated definitions

Some definitions have very similar masks, but even identical contents. Better use a one definitions with exact mask, to make your tests more precise and easier to maintain:

vendor/bin/behastan duplicated-definitions tests

2. Find unused Behat definitions with static analysis

Behat uses @When(), @Then() and @Given() annotations and their PHP 8 attribute alternatives to define method to be called in *.feature files. Sometimes test change and lines from *.feature files are deleted. But what about definitions?

This command helps you to spot definitions that are no longer needed. Just provide test directory (1 or more) and let it statically compare defined and used masks:

vendor/bin/behastan unused-definitions tests

Checking static, named and regex masks from 100 *Feature files
==============================================================

Found 1036 masks:

 * 747 exact
 * 106 /regex/
 * 181 :named

 1036/1036 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

the product price is :value
tests/Behat/ProductContext.php

/^I submit order form and see payment page$/
tests/Behat/OrderContext.php


 [ERROR] Found 2 unused definitions

You can also add this command to CI, to get instant feedback about unused definitions.

That's it!


Happy coding!

About

Modern Static analysis for Behat tests

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 12

0