I’ve been playing around with Protractor, a great, new(ish) testing framework from our friends at Google. I’ve shared my example code on GitHub for those that might be interested in such things.
Examples in the code include:
- Using page objects
- Running on TravisCI
- Running tests on Sauce Labs and Browserstack
- Running multiple browsers at once
I’ve also made a quick screencast that walks you through downloading and running the example code.
Cut to the chase, in the video we:
- Install Node (okay, I don’t show this but you need do to it!)
- Download the example code from GitHub
npm install to install the project dependancies
- Briefly discuss a config file
protractor conf.js to run the tests
A QA Engineer walks into a bar. Orders a beer. Orders 0 beers. Orders 999999999 beers. Orders a lizard. Orders -1 beers. Orders a sfdeljkn.
Because UI tests are inherently slow, running them in parallel–that is, running multiple tests, in multiple browsers concurrently–is all but a necessity.
Luckily, it’s hilariously easy to run Geb tests in parallel, using Maven… all you need do is add the following code to you Maven pom.xml:
And then run your tests via Maven. Eg.
mvn test -Dgeb.env=chrome . You can try it for yourself by running my geb-example on GitHub.
This code will spread your tests between up to 4 threads/forks and run tests at the method (test) level. You can also swap out “methods” for “classes” if you’re prefer to run at the spec (class) level. Either way, you can dramatically speed up your automated tests with a few lines of code…
You did think about running tests in parallel when writing your tests… didn’t you?
Dave Thomas (PragDave) has an interesting post regarding the use of the word “Agile”. In it, he argues against the use of “agile” as a noun, preferring using “agility”… fair enough… but like the context driven folks, who would have us use the phrase “automated checks” instead of “automated tests”, I don’t really care. The argument itself may be interesting, but semantic change is a bitch; good luck!
But he also talks about “How to do something in an agile fashion”… which I found most intriguing:
What to do:
• Find out where you are
• Take a small step towards your goal
• Adjust your understanding based on what you learned
How to do it:
When faced with two of more alternatives that deliver roughly the same value, take the path that makes future change easier.
I love the simplicity of this. Additionally, he also states:
“…anyone who comes up with something bigger or more complex is just trying to sell you something.”
Nice work, sir… and for that, I changed my tagline to aid your cause :)
When I’m finally in charge, two of my first mandates will be: If you’re driving in the left lane, BE passing. But only slightly less important will be: “Please read Mythical Man Month”.
And you don’t even have to read the book if you don’t want. Simply read the Wiki page about the book and believe it. In fact, you can skip the book and the Wiki page if you’ll repeat the following three times, out loud:
“Adding manpower to a late software project makes it later”.
You may now become a manager…