22 Mar 2015

Version 1.6.0 is released. Custom spec rules and test groups

The version 1.6.0 was just released with the following major features:

You can see complete list of features on GitHub milestone 1.6

Custom rules in Galen Specs language

This is a major improvement in Galen Specs language which allows you to extend your own page spec and make it much more readable. Custom rules allow you to group complex specs and give them a better naming. Lets take a simple example. Imagine you want to test that the icon is a square. So you need to test that its width is equal to its height. And for example there could be a lot of other elements on page which should have the same rule. You can write it like this:

@@ rule: %{name} should be squared ${name} width: 100% of ${name}/height @@ end # This is how you can use your spec | header-icon should be squared | footer-icon should be squared

Also you can try something more advanced with JavaScript based custom rules. For instance you can create a rule that checks that elements on page are aligned horizontally with equal distance between each other. You can create a JavaScript file (e.g. my-rules.js):

rule("%{objectPattern} are equally distant from each other", function (objectName, parameters) { // Searching for all objects with user-defined pattern var allObjects = findAll(parameters.objectPattern); if (allObjects.length > 1) { var distance = allObjects[1].left() - allObjects[0].right(); for (var i = 0; i < allObjects.length - 1; i++) { var nextObject = allObjects[i + 1]; this.addObjectSpecs(allObjects[i].name, [ "near: " + allObjects[i + 1].name + " " + distance + " px left" ]); } } else { throw new Error("Not enough objects for pattern: " + parameters.objectPattern); } });

And then you can use that rule in your spec like this:

@@ import my-rules.js ================================ menu-item-* #menu li a ================================ | menu-item-* are equally distant from each other

Test groups

Test groups allows you to group test by some specific functionality. You can choose which groups you want to execute and also the groups will be rendered in Html report. Here is how you can define groups in standard test suite:

@@ groups homepage, mobile Homepage on mobile device http://example.com 400x600 check homepage.spec --include mobile

Or in JavaScript test suite:

grouped(["homepage", "temp"], function () { test("Home page", function () { // ... }); });

Once you have specified the groups you can run tests for a specific set of groups only:

galen test . --groups "homepage,temp"

Or you can run all tests excluding a specific group:

galen test . --exclude-groups "temp"

Notes in specs

Another interesting feature that adds more readability to your specs. Sometimes you want to leave notes in spec file which explain why a certain spec was used. You can do that with comments but then you wouldn’t see those notes in the reports. Just for this case you can use spec notes:

header-logo "is squared" width: 100% of header-logo/height

Galen will take the sentence between double-quotes and will add it to Html report. This brings more clarity to both: spec file and resulting test report.

New specs: left of and right of

Till this moment you had to use spec near when you wanted to check that an element is located from the left or right side of another element. For better readability you can now use specs left of and right of

textfield left of: button 10px button right of: textfield 10px

Other features

There also were implemented a lot of other features. You can see a full list on the release page

Comments

We are moving all the discussions to Google Groups. From this moment, if you have problems with your test code or some issues with installation, please ask your questions in https://groups.google.com/forum/#!forum/galen-framework. This way more people will be able to help you.

comments powered by Disqus