New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start using arcus-software/concrete-php-assert
as my Assertion Library in Behat tests
#2
Comments
Let's navigate to the root of my project and run the composer require command as per the instructions. $ pwd
/Users/jw/Documents/Projects/PackageDev/xandria-demo
$ composer require --dev arcus-software/concrete-php-assert
Using version ^0.0.3 for arcus-software/concrete-php-assert
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing arcus-software/concrete-php-assert (v0.0.3): Downloading (100%)
Writing lock file
Generating autoload files
That seems OK. |
Now let's check to see my Behat tests are acutally running as good as can be afore I go a-meddling with it. $ pwd
/Users/jw/Documents/Projects/PackageDev/xandria-demo
$ vendor/bin/behat
Feature: Quick Start to see demo in action.
In order to encourage speedy use and understanding of the Xandria library
As a PHP developer who is new to the project
I can see the demo code working with least amount of effort on my part.
It is a common courtesy to make it easy for newcomers. Any project that exposes the ethos that they value contributors
and make the effort to welcome them will get more supporters.
Scenario: Launching the environment. # features/quickstart.feature:10
Given I have installed the project # FeatureContext::iHaveInstalledTheProject()
And I have Vagrant and a virtualization product installed on my host machine # FeatureContext::iHaveVagrantAndAVirtualizationProductInstalledOnMyHostMachine()
When I run `vagrant up` in the root of the project # FeatureContext::iRunVagrantUpInTheRootOfTheProject()
TODO: write pending definition
Then vagrant provisions and launches a Homestead Improved virtual environment # FeatureContext::vagrantProvisionsAndLaunchesAHomesteadImprovedVirtualEnvironment()
Scenario: Run the demo code to prove it works. # features/quickstart.feature:16
Given I have installed the project # FeatureContext::iHaveInstalledTheProject()
When I run the command to run the project's quickstart.php script # FeatureContext::iRunTheCommandToRunTheProjectsQuickstartPhpScript()
Then The expected output is written to STDOUT to prove that the project code is working OK. # FeatureContext::theExpectedOutputIsWrittenToStdoutToProveThatTheProjectCodeIsWorkingOk()
2 scenarios (1 passed, 1 pending)
7 steps (5 passed, 1 pending, 1 skipped)
0m0.42s (7.65Mb)
|
That's ok. Now let's replace my usage of Done. Let's test it works before I commit the changes... $ vendor/bin/behat
Feature: Quick Start to see demo in action.
In order to encourage speedy use and understanding of the Xandria library
As a PHP developer who is new to the project
I can see the demo code working with least amount of effort on my part.
It is a common courtesy to make it easy for newcomers. Any project that exposes the ethos that they value contributors
and make the effort to welcome them will get more supporters.
Scenario: Launching the environment. # features/quickstart.feature:10
Given I have installed the project # FeatureContext::iHaveInstalledTheProject()
And I have Vagrant and a virtualization product installed on my host machine # FeatureContext::iHaveVagrantAndAVirtualizationProductInstalledOnMyHostMachine()
When I run `vagrant up` in the root of the project # FeatureContext::iRunVagrantUpInTheRootOfTheProject()
TODO: write pending definition
Then vagrant provisions and launches a Homestead Improved virtual environment # FeatureContext::vagrantProvisionsAndLaunchesAHomesteadImprovedVirtualEnvironment()
Scenario: Run the demo code to prove it works. # features/quickstart.feature:16
Given I have installed the project # FeatureContext::iHaveInstalledTheProject()
When I run the command to run the project's quickstart.php script # FeatureContext::iRunTheCommandToRunTheProjectsQuickstartPhpScript()
Then The expected output is written to STDOUT to prove that the project code is working OK. # FeatureContext::theExpectedOutputIsWrittenToStdoutToProveThatTheProjectCodeIsWorkingOk()
2 scenarios (1 passed, 1 pending)
7 steps (5 passed, 1 pending, 1 skipped)
0m0.44s (7.66Mb)
OK good. So, my change broke nothing. Nice. Let's commit. |
It saves having to type the PHPUnit class out each time and I can store it as an object in a property.
Goal
Start using
arcus-software/concrete-php-assert
as my Assertion Library in Behat testsWhy
I was getting real tired of typing the full name of the PHPUnit class to invoke assertion methods in my Behat
/features/bootstrap/FeatureContext.php
script like:I wanted to create one instance of the assertion library in the constructor. But, I couldn't create an instance of the Assert class because it was an abstract class.
So, I wrote a package which simply extended that Assert class as a concrete class which could be instantiated.
Note: During the process I learned that you could use PHP Namespace aliases. So, perhaps the package is unnecessary. But, now I have written it, I may as well try it out and use it.
How
Follow the instructions on the
arcus-software/concrete-php-assert
README page > Using ConcreteAssert in your own project.The text was updated successfully, but these errors were encountered: