jBhave + Serenity
*
Criar um pequeno caso de teste automatizado
com o objetivo de fomentar o uso do jBehave e
das ferramentas para a automação de tese de
software, assim como discutir os padrões de
projeto em automação de teste.
*
*Criando um projeto com jbehave + Serenity
*Criando story
*Gerando os steps
*Executar um caso de teste e visualizar os
relatórios de teste gerados pelo Serenity
<!-- https://mvnrepository.com/artifact/net.serenity-
bdd/serenity-jbehave-archetype -->
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-jbehave-archetype</artifactId>
<version>1.2.0</version>
</dependency>
*Help > Install New Software...
*Add the new site
location http://jbehave.org/reference/eclipse
/updates/
*Select JBehave Eclipse feature and follow
standard Eclipse installation procedure
*Título
*Narrativa
Search for definitions
In order to understand a
word that I don't know
As a user
I want to be able to
look up the meaning of
the word
Titulo
Narrativa:
Cenário1
Cenário2
...
CenárioN
Lookup a definition
Narrative:
In order to talk better
As an English student
I want to look up word definitions
Scenario: Looking up the definition of 'apple'
Given the user is on the Wikionary home page
When the user looks up the definition of the word 'apple'
Then they should see the definition 'A common, round fruit produced by
the tree Malus domestica, cultivated in temperate climates.'
Scenario: Looking up the definition of 'pear'
Given the user is on the Wikionary home page
When the user looks up the definition of the word 'pear'
Then they should see the definition 'An edible fruit produced by the
pear tree, similar to an apple but elongated towards the stem.'
Given Pré-Condição
When Procedimento
Then Resultado esperado
Scenario: Conjunto de passo/procedimentos
Scenario: Sum of two numbers
Given a calculator
When I add 2 and 2
Then the outcome should 4
Scenario: Show shipping cost for an
item in the shopping cart
Given I have searched for docking
station
And I have selected a matching item
When I add it to the cart
Then the shipping cost should be
included in the total price
Scenario: Search for an available product
Given I am on the home page of the virtual store
When I look for the shirt item
Then I should see the option women's shirt
When I click on the option for women's shirts
Then I should see the message Search Result:
shirts
Scenario: login in the system
Given I am on the login page
When I put maria in the login lable
And I put 123456 in the password lable
And I click in the login button
Then I should have access to the system
Scenario: Sum of two numbers
Given a calculator
When I add 2 and 2
Then the outcome should 4
And I should see the message
Do you want to make a new sum
Scenario: login or password incorrect
Given I am on the login page
When I put <login> in the login labale
And I put <password> in the password labale
And I click in the login button
Then I should see the message invalid login or
password!
Examples:
|login|password|
|LoginCorreto|SenhaIncorreta |
|LoginIncorreto|SenhaCorreta |
||SenhaCorreta |
|LoginIncorreto||
PageObject
Steps.serenit / EndSteps
Steps
Story
public class AcceptanceTestSuite extends SerenityStories {
private final Locale defaultlanguage = new Locale("pt");
@Override
public Configuration configuration(){
Configuration configuration = super.configuration();
Keywords keywords = new LocalizedKeywords(defaultlanguage);
configuration.useKeywords(keywords)
.useStoryParser(new RegexStoryParser(keywords))
.useStoryLoader(new UTF8StoryLoader())
.storyReporterBuilder().withKeywords(keywords);
return configuration;
}
}
*Jessica nunes jessica@usto.re
*Marina Viana marina@usto.re
*Rafael Jordão rafael@usto.re
*Este foi um material desenvolvido pelo time de
teste da Ustore

Jbehave + serenity

  • 1.
  • 2.
    * Criar um pequenocaso de teste automatizado com o objetivo de fomentar o uso do jBehave e das ferramentas para a automação de tese de software, assim como discutir os padrões de projeto em automação de teste.
  • 3.
    * *Criando um projetocom jbehave + Serenity *Criando story *Gerando os steps *Executar um caso de teste e visualizar os relatórios de teste gerados pelo Serenity
  • 4.
  • 5.
    *Help > InstallNew Software... *Add the new site location http://jbehave.org/reference/eclipse /updates/ *Select JBehave Eclipse feature and follow standard Eclipse installation procedure
  • 7.
    *Título *Narrativa Search for definitions Inorder to understand a word that I don't know As a user I want to be able to look up the meaning of the word
  • 9.
  • 10.
    Lookup a definition Narrative: Inorder to talk better As an English student I want to look up word definitions Scenario: Looking up the definition of 'apple' Given the user is on the Wikionary home page When the user looks up the definition of the word 'apple' Then they should see the definition 'A common, round fruit produced by the tree Malus domestica, cultivated in temperate climates.' Scenario: Looking up the definition of 'pear' Given the user is on the Wikionary home page When the user looks up the definition of the word 'pear' Then they should see the definition 'An edible fruit produced by the pear tree, similar to an apple but elongated towards the stem.'
  • 11.
    Given Pré-Condição When Procedimento ThenResultado esperado Scenario: Conjunto de passo/procedimentos
  • 12.
    Scenario: Sum oftwo numbers Given a calculator When I add 2 and 2 Then the outcome should 4
  • 13.
    Scenario: Show shippingcost for an item in the shopping cart Given I have searched for docking station And I have selected a matching item When I add it to the cart Then the shipping cost should be included in the total price
  • 14.
    Scenario: Search foran available product Given I am on the home page of the virtual store When I look for the shirt item Then I should see the option women's shirt When I click on the option for women's shirts Then I should see the message Search Result: shirts
  • 15.
    Scenario: login inthe system Given I am on the login page When I put maria in the login lable And I put 123456 in the password lable And I click in the login button Then I should have access to the system
  • 16.
    Scenario: Sum oftwo numbers Given a calculator When I add 2 and 2 Then the outcome should 4 And I should see the message Do you want to make a new sum
  • 17.
    Scenario: login orpassword incorrect Given I am on the login page When I put <login> in the login labale And I put <password> in the password labale And I click in the login button Then I should see the message invalid login or password! Examples: |login|password| |LoginCorreto|SenhaIncorreta | |LoginIncorreto|SenhaCorreta | ||SenhaCorreta | |LoginIncorreto||
  • 18.
  • 19.
    public class AcceptanceTestSuiteextends SerenityStories { private final Locale defaultlanguage = new Locale("pt"); @Override public Configuration configuration(){ Configuration configuration = super.configuration(); Keywords keywords = new LocalizedKeywords(defaultlanguage); configuration.useKeywords(keywords) .useStoryParser(new RegexStoryParser(keywords)) .useStoryLoader(new UTF8StoryLoader()) .storyReporterBuilder().withKeywords(keywords); return configuration; } }
  • 20.
    *Jessica nunes jessica@usto.re *MarinaViana marina@usto.re *Rafael Jordão rafael@usto.re *Este foi um material desenvolvido pelo time de teste da Ustore

Editor's Notes

  • #5 https://mvnrepository.com/artifact/net.serenity-bdd/serenity-jbehave-archetype
  • #20 import java.util.Locale; import net.serenitybdd.jbehave.SerenityStories; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.configuration.Keywords; import org.jbehave.core.i18n.LocalizedKeywords; import org.jbehave.core.parsers.RegexStoryParser; import net.serenitybdd.jbehave.UTF8StoryLoader;