In this release Galen Framework introduces JavaScript tests which means that it becomes a complete functional testing framework. You can now build more complicated tests in JavaScript and have a better execution and reporting mechanism.
Features in this release:
- JavaScript test executor
- GalenPages test framework for functional testing
- Hierarchical reports
JavaScript test executor
From now on you can write all your tests using JavaScript. In order to execute JavaScript-based tests you should store them in files with .test.js
suffix. Galen Framework looks for all files with this extension and executes one by one in order to build a list of tests. Later it takes that list and executes all test either sequentially or in parallel.
Here is a basic example of a test that loads a page and checks its layout. For instance lets say we put it into loginPage.test.js
file
test("Login page on mobile device", function () {
var driver = createDriver("http://example.com", "400x800");
checkLayout(driver, "loginPage.spec", ["mobile"]);
});
This is how you can execute the test
galen test loginPage.test.js --htmlreport reports
If you want to search for all tests and execute them in one go just do the command:
galen test . --htmlreport reports
As you can see there is no difference from the original tests executor that Galen had in its first versions.
For more information please read this JavaScript Tests Guide documentation page.
GalenPages test framework for functional testing
Also because of this JavaScript migration Galen Framework becomes now a functional testing framework. For this you should check GalenPages - a lightweight Selenium test framework for working with Page Objects model. Here is a small example for declaring and using a page:
this.LoginPage = function (driver) {
GalenPages.extendPage(this, driver, {
email: "input.email", // css locator
password: "xpath: //input[@class='password']", // xpath locator
submitButton: "id: submit", // id locator
load: function () {
this.open("http://example.com/login");
return this.waitForIt();
},
loginAs: function (userName, password) {
this.email.typeText(userName);
this.password.typeText(password);
this.submitButton.click();
}
});
};
// now you can use it like this
var loginPage = new LoginPage(driver).load();
loginPage.loginAs("[email protected]", "password");
Hierarchical reports
From now on the reports are implemented with hierarchy so you can organize your reports the way you want
Here is a quick example of a basic reporting
test("Some basic test", function () {
logged("Creating a user and authorizing", function () {
logged("Log in", function (report) {
report.error("Couldn't authorize user");
});
});
});
This is how it looks in the end in html report
You can download a new version here
Comments
We have moved 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.