#BDD and Concordion ![Breizhcamp](breizhcamp.png) ######Sun Seng David TAN @ Serli
### Sun TAN - Java Developer #### 9 years and 9 months experienced - Previous: Nuxeo, Economic Outlook (Australia), Thales - Eclipse RCP, Nuxeo, FOSS, Agile EO Nuxeo Thales Twitter: @sunsengdavidtan IRC: sunix
### Java Software Developer @SERLi ####A few words about SERLi - IT services company based in France - 65 people - 80% of the business is Java-related - Small company working for big ones - OSS contribution: 10% of workforce - www.serli.com - @SerliFr
###Agenda - BDD and Concordion - BDD and Concordion - Corcordion basics and demo - Assertion - Parameters - Extension and Screenshots - Why BDD ? Why Concordion ?
## BDD and Concordion
### BDD Behaviour Driven Development (A)TDD but ...
Write "Behavioral specifications" first
####Behavioral specification - Spoken language - User stories - Scenarios - Given: Prerequisites - When: Actions - Then: Expectations - Usually your functional test scenarios ####Steps - Write "Behavioral specifications" - Code and Validate the feature right away Requirements met at the end :)

Concordion

A BDD tools

Composed of

Hidden html attributes, calls fixture methods.

Concordion life cycle

## Corcordion basics + Demos

Concordion basics

####Behavioral specs and fixtures - same folder/package - same name
####Requirements - Concordion namespace - `ConcordionRunner` JUnit4 runner
####Basic Concordion instrumentations - html instructions call fixture methods
####Use anything in java to "drive" your test - Plain java - Selenium Webdriver - SWTBot - Apache commons exec
Specs: com/serli/demo/concordion/HelloWorld.html
<html xmlns:c="http://www.concordion.org/2007/concordion">
<body>
Hello <span c:assertEquals="world()">World</span>
</body>
</html>
Fixture: com/serli/demo/concordion/HelloWorld.java
package com.serli.demo.concordion;

@RunWith(ConcordionRunner.class)
public class HelloWorld {
    public String world(){
        // write selenium code here
        return "World";
    }

}
Screencast is online here
###Assertions with `c:assertEquals()` demo
The most used Concordion instruction
Hello World Fails if `world()`≠ `"World"` ####Demo's content: - Project configuration - Eclipse plugin - Basic login scenario - Markdown.js - Given When Then - assertEquals - Webdriver

Variables with c:set

####Specification - Set variables
- pass variables to the fixture
![Hello Bob](sethelloBob.png)
Specs: com/serli/demo/concordion/HelloWorld.html
<html xmlns:c="http://www.concordion.org/2007/concordion">
 <body>
  The greeting for user
  <span c:set="#firstName">Bob</span>
  will be:
  <span c:assertEquals="greetingFor(#firstName)">Hello Bob!</span>
 </body>
</html>
Fixture: com/serli/demo/concordion/HelloWorld.java
package com.serli.demo.concordion;
@RunWith(ConcordionRunner.class)
public class HelloWorld {

public String greetingFor(String firstName) {
  return "Hello " + firstName + "!";
 }

}
Screencast is online here
###Variables with `c:set()` demo ####Demo's content: - param variable with c:set()
Screencast is online here
###Extensions and Screenshots ####Screenshot extension - Takes screenshots and display them in the reports ####Extensions - `@Extensions` to the class - `@Extension` to the extension attribute of the class - Available extensions with `concordion-extensions` ####Demo's content: - 2 ways to add screenshots - Screenshot on failure - Screenshot always
## Why BDD ?

Daily kanban board ... it works ...

It works ...almost

### What can we do ? #### What's wrong ? ##### Reassign to the developer - Already working on something else - A developer (usually) can't do 2 things at the same time - Context changes is hard for the developer ##### PO test fails - PO/Customer and developers don't speak the same language - specifications are not enough #### Where BDD can help - PO/User write/validate test scenarios ! - Developers know how to validate a feature

Scenario design

##Why Concordion ?
### Why Concordion ? #### What does this test do ? ![Screenshot failing selenium](selenium.png)
### Why Concordion ? #### What's the context ? ![Screenshot failing webdriver](webdriver_stack.png)
### Why Concordion ? #### When it's broken, the author is the only one who understand
I didn't write that test
- I'm new in the team - I was working on another feature - I'm not a developer
### Why Concordion ? When it's broken ... ####... It's good to know the context #####Developers fix broken tests Developers knows what is broken and can easily fix it #####PO decides to release PO knows what is broken and can easily take a decision
Nice and useful reports
### Summary #### BDD - No misunderstood requirements -> faster development process #### Concordion - Nice reports with useful informations - My tests can be read by anyone - Simple to use - Just one more file (html) - 3 mains instrumentation command to know
### Want more ? ####If I had more time ... - Test Suite with `c:run` - Maven output dir - How to write an extension: Resources extension - Selenium screenshot #### Demo / slides online - https://github.com/sunix/concordion-talk - http://sunix.github.io/concordion-talk/slides/concordion.html #### Concordion website - http://www.concordion.org
##THANK YOU :) Questions ?

/

#