A Plain Text User Stories Parser that supports native Programming Languages.
-
Install features:
$ gem install features
-
Generate the supporting folders from your rails apps root folder:
$ script/generate features
-
Run the HelloWorld.feature:
-
(OS X): There is a
run_features.rb
script that will open its results in Safari:$ ruby test/features/run_features.rb
-
(Other OS): INSTRUCTIONS WILL FOLLOW SOON ...
- Here is what the Html Output looks like:
Use the iphone-bdd-tools installer to install customized Xcode Templates that have a Features Target.
That files are made up of keywords (Feature:, Scenario:)
and step definitions (When I say 'Hello, World!'):
Feature: Hello World
Scenario: Say Hello World
When I say 'Hello, World!'
Each Feature (User Story) will be generated as a TestCase.
Each Scenario as a test method.
The step definitions provide the test method implementations.
Regarding the above Feature, here is what the autogenerated testcases
will look like in the different languages:
-
Rails:
require "/path/to/project/support/features_helper.rb" class HelloWorldTest < FeaturesTestCaseClass def test_SayHelloWorld when_I_say___("Hello, World!") end end
-
Objective C:
#import "OMFeature.h" @interface HelloWorldTest : OMFeature @end @implementation HelloWorldTest -(void) testSayHelloWorld { [self When_I_say___:@"Hello, World!"]; } @end
-
Other Languages (Java, C#, C++, Python, PHP) will follow soon ...
Steps are instance method of the intermediate TestCase class (eg 'FeaturesTestCaseClass' in Rails)
that inherits from the language specific TestCase class (eg 'ActionController::IntegrationTest' in Rails)
and that itself is the parent of the generated TestCases. This way, all test method implementations (aka Scenarios)
will have access to the steps.
The implementation follows the some patterns :
-
Only use characters that may appear in method and class definitions.
-
Spaces in the step definition map to underscores in the implementation:
(Rails) Given something => given_Something (ObjC) Given something => Given_Something
-
Place Holders for variable strings (that can be passed to the step implementation) are identified by double underscores (plus underscores for spaces) in the step implementation and strings are single quoted in the step definition:
# Step definition When i say 'Hello, World!' # Rails Step implementation def when_i_say___(string) # do something end # ObjectiveC Step implementation -(void) When_i_say___:(NSString *) string { // do something }
gem install features
- Idea?, Feature Request?, Bug? -> Lighthouse
- source -> GitHub
- talk? -> GoogleGroup
(The MIT License)
Copyright (c) Matthias Hennemeyer
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.