Dominic Langenegger, Michael Werner, Rolf Bruderer
My Architect told me to only do Unit Tests!
Imagine 10 Coders doing this in parallel ...
ONLY Special E2E Tester / Testing Team ?
Tests are a Tool for the Developers!
Scenarioo helps answer these questions ...
Working Software over comprehensive Documentation
Documentation is in the Code
Code IS the Documentation
Tests are Documentation
Jump through User Scenarios like a Kangaroo ...
demo.scenarioo.org
What have the developers in your team under their control?
If the test is broken, the developer must be able to fix it!
Subsystem not under your control: fake it!
Document Expectations about other Systems
{
"stringValue": "Our UI can display generic string values!",
"dateValue": "1978-06-13"
}
A Specification by Example of what our system can consume
Structure Scenarios by Use Case
Use Case
Scenario = Test Case = One flow through the use case
A hand full of scenarios per use case:
Use Case "Task - Create"
Use Case "Player - Find"
Avoid E2E-Testing Creep
1 hand full of scenarios per use case
focus on high-level business functionality
DON'T test all details of complex logic in E2E tests
Extract that logic into a Component / Service / Class / Function
Extensively test that Logic in Unit Tests
Think about your Application ...
describe('Example Use Case', function() {
it('Example Scenario', function() {
browser.get('/index.html');
element(by.css('li#item_one')).click();
expect(element(by.id('selected')).getText()).toEqual('one');
});
});
So far so good, let's look at a bigger example.
describe('Example Use Case', function() {
it('Example Scenario', function() {
browser.get('/index.html');
var firstname = by.id('#firstname');
element(firstname).sendKeys('Stephen');
var lastname = by.id('lastname');
element(lastname).sendKeys('Strange');
element(by.id('#submit')).click();
expect(element(by.id('#message'))).getText()
.toEqual('Registration successful!');
});
});
Cool, but it's starting to get a bit messy...
var RegistrationPage = {
var firstnameTextbox = element(by.id('#firstname'));
var lastnameTextbox = element(by.id('#lastname'));
var registerButton = element(by.id('#submit'));
this.register = function(firstname, lastname) {
firstnameTextbox.clear();
firstnameTextbox.setText(firstname);
lastnameTextbox.clear();
lastnameTextbox.setText(lastname);
registerButton.click();
};
}
var TextBox = function(element) {
this.element = element;
this.set = function(value) {
element.clear();
element.sendKeys(value);
}
this.clear = function(value) {
element.clear();
}
}
var RegistrationPage = {
var firstnameTextbox = new TextBox(element(by.id('#firstname')));
var lastnameTextbox = new TextBox(element(by.id('#lastname')));
var registerButton = element(by.id('#submit'));
this.register = function(firstname, lastname) {
firstnameTextbox.set(firstname);
lastnameTextbox.set(lastname);
registerButton.click();
};
}
describe('Example Use Case', function() {
it('Example Scenario', function() {
registrationPage.open()
.register('Stephen', 'Strange');
confirmationPage.expectRegistrationSuccessful();
});
});
The intention of the code becomes visible.
OK cool, but how do I activate this Scenarioo now?
For installation and configuration see: https://github.com/scenarioo/scenarioo-js/blob/develop/README.md
onPrepare: function onPrepare() {
global.scenarioo = require('scenarioo-js');
scenarioo.setupJasmineReporter(jasmine, {
targetDirectory: './scenariooReports',
recordLastStepForStatus: {
failed: true,
success: true
},
...
}
describe('Example Use Case', function() {
afterEach(scenarioo.saveLastStep);
it('Example Scenario', function() {
registrationPage.open()
.register('Stephen', 'Strange');
confirmationPage.expectRegistrationSuccessful();
});
});
describe
it
scenarioo.saveStep(...)
var RegistrationPage = {
var firstnameText = new TextBox(element(by.id('#firstname')));
var lastnameText = new TextBox(element(by.id('#lastname')));
var registerButton = element(by.id('#submit'));
this.open = function() {
browser.get('/registration.html');
scenarioo.saveStep('Registration page opened');
};
this.register = function(firstname, lastname) {
firstnameTextbox.set(firstname);
lastnameTextbox.set(lastname);
scenarioo.saveStep('Registration data entered');
registerButton.click();
};
}
Define steps inside of page objects!
useCase('Register User')
.labels('mobile')
.describe(function() {
scenario('Register new user')
.labels('happy')
.it(function() {
registrationPage.open()
.register('Stephen', 'Strange');
confirmationPage.expectRegistrationSuccessful();
});
});
Feature Branches and Pull Requests
Failed tests on master / develop disturb others!
Let CI Build System verify your Pull Requests
Short Demo
# Definition of Done
* Feature is covered by tests
Any better ideas?
Our Definition of Done in our Markdown Documentation:
# Definition of Done
* Feature is documented in Scenarioo
What is wrong?
if (element.isPresent()) {
element.click();
}
element.isPresent().then(function(present) {
if (present) {
element.click();
}
};
Methods on element return a Promise!
https://github.com/scenarioo/scenarioo-java https://github.com/scenarioo/scenarioo-cs
New Features in Scenarioo 3.0
Release 1st December 2016
Planned Features 2017
Feedback: https://github.com/scenarioo/scenarioo/issues/new?labels=feedback