Skip to content
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

Refactoring: Adding cmd line runner to parse user-written BDD Stories into stubbed mspec code #10

Open
eduncan911 opened this issue Jun 23, 2016 · 0 comments
Assignees

Comments

@eduncan911
Copy link
Owner

eduncan911 commented Jun 23, 2016

E.g. spec, mspec, bdd, etc.

A conversation I had with a user recently gave me an idea. I have always asked the user to write general BDD-style ticket and bug reports. For example:

Story: Registering a new user
  As an user visiting the site
  I want to signup
  So that I can use the system

Scenario 1: User is unregistered
Given the user is not signed in
  and their email address does not exist in our system
  and their username does not exists in our system
  and they do not uncheck Subscribe to our Newsletter
 When the User registers
 Then a new User is created
  and a welcome email is sent to the User
  and a verify email address email is sent to the User
  and they are subscribed to our newsletter

While usually not that pretty, I have gotten 100s of tickets and bugs like this in the past.

So, I had a thought:

why not take this, verbatim, copy-n-paste it into a text file, and execute a command line parser that generates the actual mspec code that is all stubbed out?

Makes total sense. Using go generate, just parsing raw text and generating all the Given, When and Thens that are needed. The entire workflow (from scratch) would be:

go install -v github.com/eduncan911/mspec/cmd
cd $GOPATH/src/company/www/
mspec jim-user-story.txt > registration_test.go
go test

It is boilerplate code that I have typed 100s of times by hand. This utility will generate and output the complete file, ready to go test and will output the NOT IMPLEMENTED we all love about the Stubbing feature of mspec. Lovely!

GoConvey actually follows this paradigm as well with their browser. But the focus of this utility will be lightweight copy-n-pasting and parsing. Oh, that's another idea: reading from the Clipboard of the OS directly.

mspec -from clipboard > registration_test.go

Of course it isn't a replacement for double-loop unit and bdd testing that you should continue doing. But, it gets the Acceptance Testing coded out for the developer, leaving them free to iterate with normal TDD quickly.

See #4 and #9 for more details.

@eduncan911 eduncan911 changed the title Adding cmd line runner to parse user-written BDD Stories into stubbed mspec code Refactoring: Adding cmd line runner to parse user-written BDD Stories into stubbed mspec code Jun 23, 2016
@eduncan911 eduncan911 self-assigned this Jun 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant