I’m going to share with all of you an interesting timeline related to the Gulf Oil Spill.
4/12: Halliburton buys an Oil Cleanup company Boots and Coots (http://bit.ly/dmYXVE)
4/19: Halliburton performs repairs on oil rig (http://yhoo.it/cLih3W)
4/20 (AM): BP warned to slow down operations, management orders otherwise (http://bit.ly/aZ0UJc)
4/20: Oil rig explodes, gushing gallons and gallons of crude oil into Gulf
TODAY: Guess who’s available to clean it up? Halliburton via Boots and Coots (http://bit.ly/a6qkML)
This blog post was inspired by Christopher McKay, who did most of the research online and put together the timeline. I feel the need to pass it on. Please do the same.
This is the first part of many on how to use Spectacular, an open-source acceptance test / behavior driven development tool for development teams. This installment will focus on how to use Spectacular to create Executable Use Cases, and how those use cases can be executed using Selenese to drive a Selenium browser!
Part of why I wanted to write a tool like Spectacular is that I wanted to explore the possibility of using simplified Use Cases in the context of Epics in order to describe the overall requirement, in addition to using that Use Case to assist in creating stories during a story workshop. Of course, the one thing bugging me about the whole subject is that I would also want those Use Cases to be completely testable. Enter Executable Use Cases.
The idea works like this: Let’s say that during a story mapping workshop, an agile team identified an Epic/Activity for logging into a system as an existing user. They collaborated on a simple diagram showing how this would work:

Using this web-flow diagram as a guide, the team can now start to write a simplified use case in order to weed out some details and describe the user flow and interactions. In Spectacular, the requirement for a Use Case is to create a table with at least 2 columns (though 3 or more is typical, to describe ancillary details). The first row should be the title of the use case, with the word “Flow” in there (i.e. “Primary Flow: Log In” or “Alternate Flow: Remember Me Log In”). The next row are the column headers (“User Action”, “Expectation), followed by the use case itself. Additional columns are ignored by Spectacular:
| Primary Flow: | Log In | |
| User Action | Expectation | Comments |
| User navigates to system home page. | User sees system home page with a header of “Home Page” | |
| User clicks login link | User sees a login form requesting credentials | Credentials include username, password. Should include a button for submission of form as well |
| User enters credentials and submits form | User sees a landing page with a list of submitted articles | |
Now that the team has written a use case, its time to make it executable. Many of the use cases I run into with my Agile teams are user-interaction based, which is what inspired me to giving user the ability to express a use case as a series of Selenese commands (in addition to writing the fixtures in Java, Ruby, and Groovy). Once the team has agreed to the use case details (and brainstormed user stories from this i.e. bad login, already logged in, etc.), the team opens up a text editor or IDE and writes the fixture in Selenese:
Flow: User navigates to system home page.
open "/"
waitForPageToLoad 5000
Expectation: User sees system home page with a header of "Home Page"
verifyText "xpath://h1[class='mainHeader']" "Home Page"
verifyText "id=loginLink" "Login"
Flow: User clicks login link
click "id=loginLink"
waitForPageToLoad 5000
Expectation: User sees a login form requesting credentials
verifyElementPresent "id=usernameLogin"
verifyElementPresent "id=passwordLogin"
verifyElementPresent "xpath://input[@class='loginButton']"
Flow: User enters credentials and submits form
type "id=usernameLogin" "myusername"
type "id=passwordLogin" "mypassword"
click "xpath://input[@class='loginButton']"
waitForPageToLoad 5000
Expectation: User sees a landing page with a list of submitted articles
verifyTitle "Welcome Michael!"
verifyElementPresent "xpath://div[@class='article']"
Make sense? The Selenese code above in a text file in effect becomes the fixture code for our executable use case. Executing Spectacular would look like (assuming we named the Selenese file “login.selenese” and the spec as “SystemSpec.html”):
> Spectacular -fixtures ./login.selenese -specLocation ./SystemSpec.html -seleniumRCHost localhost -seleniumRCPort 4444 -seleniumRCInitialUrl http://system-uat/ -seleniumRCStartCommand *safari
(don’t worry, these commands can be stored in a project xml file so that running Spectacular doesn’t require such a long command line
)
By default, results are output in the current directory as “TestResults.html”, which will be the same document the team wrote, but with annotated test results in the use case table. In our case, we haven’t written any implementation code yet, so it would look like this:
| Primary Flow: | Log In | |
| User Action | Expectation | Comments |
| User navigates to system home page. (FAIL) SeleniumException: URL “http://system-uat/” not available | User sees system home page with a header of “Home Page” (NOT PERFORMED) | |
| User clicks login link (NOT PERFORMED) | User sees a login form requesting credentials (NOT PERFORMED) | Credentials include username, password. Should include a button for submission of form as well |
| User enters credentials and submits form (NOT PERFORMED) | User sees a landing page with a list of submitted articles (NOT PERFORMED) | |
This is the essence of writing Executable Use Cases with Spectacular. For more details about how to write them or how to write the fixtures using other methods, visit the Spectacular EUC documentation.
Next in the “Using Spectacular” series, I’ll focus on how to document the executable use cases along with FIT and Gherkin/BDD tests and what they look like…
Boy, have I been busy the past couple months! And now, I’m comfortable enough to announce what I’ve been working on – my first major open-source project:
Spectacular is an Acceptance Test Driven Development (ATDD) / Behavior Driven Development (BDD) tool that aggregates several different types of testing frameworks into 1, and it also introduces the idea of Executable Use Cases (EUC) – if you have to write use cases, you might as well make them Not Suck.
The idea is that a Business Analyst (BA), Quality Assurance engineer (QA), or Developer can write a spec in any way they feel comfortable with, including diagrams and business rules if necessary. They can write tests in the form of Executable Use Cases, BDD-style tests (Gherkin/Given-When-Then scenarios), and/or FIT-style tests all within the same document. The tool will run through the document, “detect” test cases, execute them, and print out the results in the same format as it was input.
I work at a large financial services company, where compliance with Sarbanes-Oxley (SOX) and Office of the Comptroller of the Currency (OCC) rules and regulations is of utmost importance, specifically with the audit requirements.
I suspect that there are many, many organizations out there who have to comply with the same set of rules, so I took what I learned about SOX and OCC audit requirements, combined them with what I learned at Elisabeth Hendrickson’s AMAZING ATDD course, and created Spectacular to make writing requirements more natural while also making those same documents executable, and not restricting any team to any single tool.
Also, I found through practical application of various ATDD tools that they are all pretty amazing and useful, but it was really annoying to use all these various tools to write specs and tests in different ways located in different locations depending on the tool being used. Plus, I would suspect that most teams would prefer to write story tests in a single document in a single format rather than having them live all over the place.
I don’t think so. Actually, I think something like Spectacular will help any large organization with an established corporate hierarchy and previous experience writing specifications in a use-case format adopt Agile more easily, especially those with “hardened” quality-assurance/quality-control groups. In my experience, these large organizations can be like “steering the Titanic with a small rudder” when it comes to transitioning to a more Agile process – allowing teams to continue writing requirements in the form of Use Case flows and documenting the tests in the same document will let them experiment with the various ATDD best-practices while remaining compliant with their regulatory bodies.
Spectacular helps those teams constrained with writing full-specs by allowing those teams to write the specs with tests embedded in them. Agility is introduced because those specs – written in a format they are used to – are now executable. A core Agile practice IMHO.
Yes, really. Use cases can tell a lot of the “story” if written well. Use cases, just like implementation code when written after a unit test is written, can be written well if there a constraint of execution behind it. Also, traditionally use cases have been taken to a far extreme of complicated. Not necessary IMHO.
To me, Use Cases fill the role of “Epic Spec” in an agile process. I’m a huge believer in the practice of Story Mapping and Persona Development (from Jeff Patton and Dave Hussman, respectively. Two of my personal geek-heroes). While doing your story mapping workshop, the high-level “activities” that you decompose into stories can very easily be Use Cases. In fact, in my experience writing Use Cases to explain the high-level activity (or “Epic”) can help to decompose it into discreet stories. And as such, each level of requirement-granularity (from Epic/Use Case to the Story) requires a different way to test it.
As such, I use Spectacular myself to execute Use Cases against Epics, and BDD/Gherkin and FIT tests to execute Stories.
I don’t know about the rest of you, but I hate it when I stumble upon a useful open-source tool only to find that the documentation is poorly written. Now, I’m not saying Spectacular’s docs are amazing, but I did spend some time writing a good amount to make sure people could pick up Spectacular and use it relatively quickly. All of the docs are located at the Spectacular Wiki on Google Code. I welcome all feedback so that the documentation can be improved!
But here’s an example. Given a document:
(Executable Use Case)
| Primary Flow: Register New User to System | ||
| User Action | Expectation | Comments |
| User navigates to “http://blog.minderupt.com/” | User sees blog site with existing blog entries | |
| User clicks on “Log in” link | User sees page requesting credentials | |
| User clicks on “Register” link | User sees page requesting registration info | Reg info includes a username, password, confirm password, and age! |
| User enters registration information and submits form | User sees page asking user to confirm |
Business Rules:
Story: As a new user not already registered I want to register myself so that I can use the system.
(BDD/Gherkin Executable Test)
|
Scenario: Brand new user correctly registers Given a username of “myusername” is not already registered Scenario: Good username, duplicate email Given a username of “myusername” is not already registered Scenario: Duplicate username, good email Given a username of “myusername” is registered |
Story: As a new user not already registered I should not be able to skip any data elements so that…
(FIT executable test)
| Username | Password | Confirm Password | DOB | registered() |
| myusername | mypassword | mypassword | 11/01/1960 | true |
| username1 | password1 | password2 | 11/01/1960 | false |
| myusername | mypassword | mypassword | 01/01/2005 | false |
With these requirements written, Spectacular will run through this document and parse out the tests (basically, anything contained in a table and fitting particular patterns) and execute test fixtures for each of these. While for version 1.0 Spectacular only supports Java (using JBehave) for the BDD/Gherkin and FIT tests, Executable Use Case fixtures can be written in Java, Groovy, Ruby (experimental – using JRuby), and Selenese (to directly drive a browser using SeleniumRC). The ability to write fixtures for BDD/Gherkin and FIT in other languages is coming soon! (I’d really like to be able to write BDD/Gherkin tests using Cucumber as the engine if possible)
Try it out! I hope the Agile community finds some use out of this tool like I have. If you have any questions, you can leave them here in comments or join the users & dev lists.
Much of Spectacular is based in part or whole from the following projects:
As well as from the teaching/writing/works from the following people:
I’m having a total brainfart on using commons-CLI and PosixParser. For some reason, the following test is failing:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
@Test
public void testSpikeOnPosixParser() throws Exception {
Options options = new Options();
options.addOption("m", "multichar", true, "some description");
CommandLineParser cmdLineParser = new PosixParser();
CommandLine cmdLine = cmdLineParser.parse(options, new String[] {"-multichar", "somevalue"});
assertNotNull(cmdLine);
assertTrue(cmdLine.hasOption("multichar"));
assertEquals("somevalue", cmdLine.getOptionValue("multichar"));
} |
The test fails at the assertTrue statement on line 12.
Why? Am I misunderstanding the JavaDocs? Or am I being a dunce and forgot how to use commons-cli?
Arg.
I think Agile has a problem – it needs to grow up a little bit.
I’m not talking about “growing up” in terms of being more adopted. I think Agile (and it’s various incarnations/methodologies) has far reached the point where it is considered mainstream. At least to the point where it can be considered a viable option for teams/companies along with RUP and the likes.
What I mean by “growing up” is a change from rather informal, lax naming conventions that are, well, kinda puerile (“ScrumMaster?”) and tend to raise eyebrows a bit to folks in the corporate hierarchy, which tends to make them take Agile less serious because it seems like the Agile terminology was thought-up by a bunch of 16-year-old S&M RPG gamers.
I work for a well-known, established gargantuan of a company. The senior managers tend to be a bit more conservative than, say, the folks (wonderful as they are) at Twitter, Inc., Facebook, Inc., or <enter startup created by 25 year old geniuses here>, Inc. When I bring up Agile techniques to my senior managers, or do some coaching for teams new to implementing Agile, I always find a few people don’t take what I am trying to coach seriously at first, which makes my job just a tad bit harder. And that’s just the “do-ers” on the teams – for senior managers, I can see their little snarky grins when I talk about the role of “Scrum Masters” or techniques such as Kanban. Which actually makes it a LOT harder to push Agile as a strategy, especially when those same senior managers are the ones who have to sign off on said strategy.
The best (worst?) meeting ever came after a coaching session with a technical team, and I brought up the XP technique of “promiscuous pairing.” The dev manager pulled me aside and asked me (paraphrase) if some of these Agile “things” came out of swinger communities. (note: link not safe for work – see what I mean?)
I have found that once I changed the terminology of certain Agile techniques or roles folks took the philosophy quite a bit more seriously. Examples of terminology adaptations include:
The list goes on… The problem with the adaptations is that they are not official Agile terms, and so folks doing research on their own tend to not find the right kind of information because the Agile community uses the more informal terms.
I do get it – I understand why we use the more informal terms. Agile is a new way of thinking for a lot of development teams (though, I argue that it is a cleaner, more refined regurgitation of the old RAD style, but I digress), and with the new way of thinking we should use new terminology so that folks think about how they approach activities differently (i.e. if you call it a “requirement” they will do the old-style deep up-front analysis whereas “User Story” won’t invoke such a trained reaction). But as Agile adoption becomes more mature and enters the more mainstream “boring” old companies, I think we as a community need to take stock and consider formalizing the techniques and giving them names my senior managers won’t giggle at.
To be fair, some of the Agile terms aren’t that bad; things such as “Sprint” can be easily translated to “Iteration” without much problem and doesn’t raise many eyebrows. But, “ScrumMaster?” Are you kidding me? Oh, and “Backlog.” Now, this is something I didn’t realize until I started at my current employer, but “Backlog” has a bit of a negative connotation with many old-school senior managers, as it used to mean a list of things that are behind or late and needed to be done. In Agile, it means a prioritized list of things that need to be done as well, but “backlog” also implies those items are late and it’s bad. I’m not saying that’s right, it just is what it is. In fact, in sales organizations a backlog generally infers a list of customer orders/requests not yet fulfilled, but is also generally described in monetary units and not as individual items. Another confusion.
The “planning game” is simply silly. Many folks involved in software development do not consider planning, sizing, and estimating a game at all. It’s “serious business” and many careers are staked in proper planning.
Again, I do realize many of these terms are meant to be taken lightly – and part of doing Agile is inserting “fun” back into software development. But we also have to remember that not everyone thinks of software development as “fun” and that your manager may be more of an MBA-type rather than a Computer Science-type.
So I ask – is it time for us to consider making some of our techniques and methodologies a little more formal and a little less…. childish?
Just a thought.
So, I read someone’s blog post about the pros and cons of using UUIDs as primary keys. I am a big believer in using UUIDs as primary keys for domain objects in the DB. Having used them quite a bit in my projects, I wanted to debate a couple of the cons listed in the original post.
1. Performance can be an issue: Yes, it can, but grabbing a sequence from the DB creates a bigger issue (2 calls per new insert, depending on the RDBMS platform). This can be easily remedied by writing a simple UUID pool object which generates the UUIDs in batch, and doles them out on request. When the pool runs low/out, regenerate.
2. Ordering/Sorting. Indeed, you really cannot order by the primary key in the case of a UUID. But then again, why does one usually order by primary key? Sequential primary keys tend to indicate the order of entity creation. Good DB design principles include having a created_date and a modify_date column as part of the entity (depending on your needs and requirements, of course, but I’d say this is mostly true). With this in mind, you CAN order by the create date.
3. cannot test if a record has already been persisted by checking if the Id field has been set. Uhm, you can write a @GenericGenerator to generate the uuid if you’re using a JPA provider other than hibernate, and it wouldn’t be hard at all. The UUID is only set upon insert call to the DB, so you can do this check. But the OP is right, I question a design that checks for the existence of a PK being set.
Now, not all is roses of course. Using the pre-generated strategy in point #1 means that once in a while you may be generating 100 UUIDs to populate the pool, creating a slight response lag for that 1 in 100 new inserts (if you have a 100 UUID pool for example). This is akin to a GC cleanup cycle, though less harsh I think.
Depending on the DB platform, sorting by date columns can be slower, though I argue not so slow as to affect performance significantly.
One thing that annoys operations folks who may be tracking a transaction of some kind through multiple systems, with each transaction entity (whatever that is for your case) being marked with a UUID. So, rather than using a simple number as a tracking tag, you’re using a somewhat-hard-to-read 32 character (or more with hyphens) string.
Other than that, I think UUIDs are (generally) the best way to go with PKs. Personally, I make it a general rule to treat PKs as an implementation issue with using RDBMs and not an actual part of the persisted domain entity.
A great analogy, brought to you by a viewing of Bravo TV’s “The Fashion Show.”
Here it is: An architect who does not code produces the same quality of work as a fashion designer who does not sew.
Please, for all of you who hold that title of “Architect:” Do not tell me your “team of people” will dive into the details. If you do not know the ramifications of your design (which eventually come out in the details) then show me someone who does. If you’re responsible for systems design, even at bird’s eye level, please be able to do some coding so prove your design, even if you’re not officially coding for the project.
Seriously.

Read on Bob Lee’s blog about a new collaborative effort to “standardize” dependency injection via annotations:
@javax.inject.Inject at Google Code
Neat! I’m very happy to see this came about as a collaboration between the 2 competitors. I use that word a bit loosely here of course, as I switch between using Spring and Guice depending on the project and its needs, and (to me) they serve different types of applications.
Congrats guys!
Here I thought I was going to have to bite the bullet and learn more than a little bit of Ruby by way of Behavior Driven Development. I thought I was going to have to actually put my head down and start active coding in Ruby in order to use the Cucumber BDD framework, specifically to parse the Given/When/Then clauses.
I thought about writing my own framework to do just that in Java, and actually started to. Then I went to the magical Google and – wouldn’t you know it? – I found JBehave. Of course! I knew Dan wouldn’t have let me down by making me go the way of Ruby
(not that there’s anything wrong with Ruby, I just like to take my sweet time drinking kool-aid
)
I love how it is just as easy to write JBehave tests as it is to write Cucumber tests:
Given a user with the email address “someone@something.com” has not already registered with the system
When a user tries to register in the system with the email of “someone@something.com”
And a name of “Michael Dowling”
And a date of birth of “1/1/1985″ (yeah right)
Then register the user with an access token of “Registered”
In JBehave, being clearly well-designed in an IoC manner, asks you write the Steps to execute the above spec:
package minderupt.scenarios.steps; import org.jbehave.scenario.annotations.Given; import org.jbehave.scenario.annotations.Then; import org.jbehave.scenario.annotations.When; import org.jbehave.scenario.steps.Steps; public class CreateUserSteps extends Steps { private String email; @Given("a user with the email address \"$email\" has not already registered with the system") public void checkForRegisteredUser(String email) { // code to check for pre-existing email } @When("a user tries to register in the system with the email of \"$email\"") public void registerUserWithEmail(String email) { // code to register with email } @When("a name of \"$name\"") public void registerUserWithFullName(String name) { // code to register with name } @When("a date of birth of \"$dob\"") public void registerUserWithDateOfBirth(String dob) { // code to register with DOB } @Then("register the user with an access token of \"$token\"") public void checkForCreatedUser(String tokenExpected) { // register user and confirm returned token, blah blah } }
…and then write the actual test case, specifying configuration options and the actual steps to execute during the test:
package minderupt.scenarios; import org.jbehave.scenario.JUnitScenario; import org.jbehave.scenario.Scenario; import minderupt.scenarios.steps.CreateUserSteps; public class CreateUser extends Scenario { public CreateUser() { super(new CreateUserSteps()); } }
I like this approach for multiple reasons, not the least because I can re-use the steps for different spec documents utilizing the same language, but also, I can change the test case configuration so that on my dev machine (local build) I can run all the tests and simply outputthe results to my console, but in my CI system, the output goes out to some kind of standard reporting system in pretty HTML. Yay.
Like I mentioned in a previous post, one of the things I want to do is be able to fully spec out a requirement in a document (in Word, HTML, Wiki, etc) which will have a mix of business logic rules, FIT tests, and BDD tests. Then as part of a build, split out the FIT tests and run FIT against those, parse out the BDD tests and run those, and then output a report back into the combined document for the entire team to see. Can’t be too hard, just a matter of parsing Word/HTML, recognizing the type of tests, and running them. Integration project, really.
But I think it would be immensely useful, especially for organizations that (still) communicate over such types of documentation; a behavior that I feel isn’t going away anytime soon. Might as well make the transition a little bit easier, I think.