Use Coding Standards for Test Code

Should you adhere to coding standards when writing test automation code?

In short, yes. Follow coding standards for the language and technology used. Do this even if the quality of test automation code isn’t expected to be at the level of application code.

The example below uses the fantastic tool TestCafe.

import { Selector } from 'testcafe';

fixture `example`
    .page ``;

// Incorrect. An obscure way to name a selector.
const txtSearch = Selector('#q');

// Correct. Selectors have meaningful names.
const searchField = Selector('#q');
const pageTitle = Selector('title');

test('User can search Google', async t => {
    await t
        .typeText(searchField, 'Jason Riley')
        .expect(pageTitle.innerText).contains('Jason Riley');

Leave a Reply

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

You are commenting using your 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