Writing Cucumber tests with Protractor

So, one of the things about ClearPoint that’s different to most other places I’ve worked is that there’s a big focus on testing. In particular the “end to end” or “black box” automated testing. Meaning at the “highest” level feasible (e.g. browser, mobile UI, desktop UI).

In fact, I’d argue that there’s such a focus on creating and maintaining automated tests that the measure of whether a project will achieve it’s goals isn’t so much down to the strength of the programmers on the team, but rather the test coders.

However, good automated testers are relatively hard to come by and there are occasions where we’ve been caught out not having anyone with that particular skillset on a project. My own philosophy regarding cross functional teams and work life in general is to assume that everyone is “smart enough” to do “my job” if they only apply themselves to the tasks of learning and practicing the same skills. The other edge of that sword is that I believe that I’m smart enough to do theirs, given enough learning and practice.

In that spirit (and due to the current lack of testing talent) I took it upon myself to learn Protractor and Cucumber in order to be useful in maintaining and writing our automated tests.

I mostly followed this guide: https://semaphoreci.com/community/tutorials/getting-started-with-protractor-and-cucumber
which is good in getting a simple “hello world” demo of Protractor/Cucumber going, but is somewhat out of date (though this is probably the fault of the Node/Javascript community for moving so fast rather than any other reason).

What were the issues I hit? I hit these NodeJS v10 issues:

which I had to downgrade to NodeJS v8 to fix.

Also the guide was for cucumber 1.3, was using 4.x which has a different syntax
(was getting scenarios/steps being “undefined”). I figured this out after reading through the comments on the article and finding a more up to date version of the code here.

Another issues that was a bit annoying was using NPM and trying to work out where to use “local” packages vs “global”.

Overall though, I really like the BDD/Cucumber approach to writing tests as the ability to write them in “business” language and be able to generate readable reports is amazing for ensuring everyone uses the same language and knows the state of the system at any point in time.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.