SlideShare uma empresa Scribd logo
1 de 53
BDD para projetos
.NET
Por que?
Facilidade
Facilidade
Praticidade
Facilidade
Praticidade
Lingua nativa
Facilidade
Praticidade
Lingua nativa (ou quase isso)
Testes end-to-end
Testes end-to-end
Como assim?
Testes end-to-end
Interface Controller Repositorio
BD
Testes end-to-end
Interface Controller Repositorio
BD
User (browser)
Testes end-to-end
Interface Controller Repositorio
BD
User (browser)
Testa todas as camadas
Ferramentas
Ferramentas?
Ferramentas
Selenium
Ferramentas
Selenium (browser)
Ferramentas
Selenium (browser)
SpecFlow
Ferramentas
Selenium (browser)
SpecFlow (solução BDD)
Ferramentas
Selenium (browser)
SpecFlow (solução BDD)
NUnit
Ferramentas
Selenium (browser)
SpecFlow (solução BDD)
NUnit (framework de testes - asserções)
Sintaxe
Sintaxe
Feature file:
Sintaxe
Feature file:
Feature: Login
In order to access my account
As a user of the website
I want to log into the website
Scenario: Logging in with valid credentials
Given I am at the login page
When I fill in the following form
| field | value |
| Username | xtrumanx |
| Password | P@55w0Rd |
And I click the login button
Then I should be at the home page
Sintaxe
Feature file:
Feature: Login
In order to access my account
As a user of the website
I want to log into the website
Scenario: Logging in with valid credentials
Given I am at the login page
When I fill in the following form
| field | value |
| Username | xtrumanx |
| Password | P@55w0Rd |
And I click the login button
Then I should be at the home page
Feature definition:
Sintaxe
Feature file:
Feature: Login
In order to access my account
As a user of the website
I want to log into the website
Scenario: Logging in with valid credentials
Given I am at the login page
When I fill in the following form
| field | value |
| Username | xtrumanx |
| Password | P@55w0Rd |
And I click the login button
Then I should be at the home page
[Binding]
class LoginStepDefinitions
{
[Given("I am at the login page")]
public void GivenIAmAtTheLoginPage()
{
// TODO
}
}
Feature definition:
Sintaxe
Feature file:
Feature: Login
In order to access my account
As a user of the website
I want to log into the website
Scenario: Logging in with valid credentials
Given I am at the login page
When I fill in the following form
| field | value |
| Username | xtrumanx |
| Password | P@55w0Rd |
And I click the login button
Then I should be at the home page
[Binding]
class LoginStepDefinitions
{
[Given("I am at the login page")]
public void GivenIAmAtTheLoginPage()
{
// TODO
}
}
Feature definition:
Sintaxe
Feature file:
Feature: Login
In order to access my account
As a user of the website
I want to log into the website
Scenario: Logging in with valid credentials
Given I am at the login page
When I fill in the following form
| field | value |
| Username | xtrumanx |
| Password | P@55w0Rd |
And I click the login button
Then I should be at the home page
[Binding]
class LoginStepDefinitions
{
[Given("I am at the login page")]
public void GivenIAmAtTheLoginPage()
{
driver.Navigate.GoToUrl("www.gmail.com")
}
}
Feature definition:
Sintaxe
Sintaxe
Resultado:
Sintaxe
Resultado:
Sintaxe
Sintaxe
Vamos incrementar esse teste!
Sintaxe
Feature file:
Feature: Login
In order to access my account
As a user of the website
I want to log into the website
Scenario: Logging in with valid credentials
Given I am at the login page
When I fill in the following form
| field | value |
| Username | xtrumanx |
| Password | P@55w0Rd |
And I click the login button
Then I should be at the home page
[Binding]
class LoginStepDefinitions
{
[When("I fill in the following form")]
public void
WhenIFillInTheFollowingForm(TechTalk.SpecFlow.Table table)
{
foreach(var row in table.Rows)
{
var textField =
driver.FindElement(By.Id(row["field"]));
if(!textField.Exists)
Assert.Fail("Expected to find a text field with the
name of '{0}'.", row["field"]);
textField.TypeText(row["value"]);
}
}
}
Feature definition:
Sintaxe
Resultado:
Sintaxe
xtrumanx
P@55w0Rd
O que testar?
O que testar?
O que for importante
O que testar?
O que for importante
E porque não tudo?
Testes de aceitação tendem:
Testes de aceitação tendem:
1. Difícil escrita
Testes de aceitação tendem:
1. Difícil escrita
2. Difícil manutenção
Testes de aceitação tendem:
1. Difícil escrita
2. Difícil manutenção
3. Execução lenta
Testes de aceitação tendem:
1. Difícil escrita
2. Difícil manutenção
3. Execução lenta
Testes de aceitação tendem:
1. Difícil escrita
2. Difícil manutenção
3. Execução lenta
Testes de aceitação tendem:
1. Difícil escrita
2. Difícil manutenção
3. Execução lenta
Testes de aceitação tendem:
1. Difícil escrita
2. Difícil manutenção
3. Execução lenta
4. Feedback demorado
Testes de aceitação tendem:
1. Difícil escrita
2. Difícil manutenção
3. Execução lenta
4. Feedback demorado
Cenário ideal:
Cenário ideal:
*quase* ideal
Cenário ideal:
ideal
Por que?
Feedback rápido é importante
Por que?
Feedback rápido é importante
Por que?
Feedback rápido é importante
Por que?
Feedback rápido é importante
Sugestão
Sugestão
http://www.infoq.com/br/presentations/o-que-nao-testar

Mais conteúdo relacionado

Semelhante a BDD in .NET projects

Testes Automatizados e o iOS
Testes Automatizados e o iOSTestes Automatizados e o iOS
Testes Automatizados e o iOS
Ricardo Valeriano
 

Semelhante a BDD in .NET projects (20)

Qualidade de Software: Escrevendo Código Limpo
Qualidade de Software: Escrevendo Código LimpoQualidade de Software: Escrevendo Código Limpo
Qualidade de Software: Escrevendo Código Limpo
 
Seu Cliente no Controle! Testes ágeis
Seu Cliente no Controle! Testes ágeisSeu Cliente no Controle! Testes ágeis
Seu Cliente no Controle! Testes ágeis
 
Mini Curso PHP Twig - PHP Conference 2017
Mini Curso PHP Twig - PHP Conference 2017 Mini Curso PHP Twig - PHP Conference 2017
Mini Curso PHP Twig - PHP Conference 2017
 
Workshop Django
Workshop DjangoWorkshop Django
Workshop Django
 
JQuery Alagoinhas Dev Day - UNEB
JQuery Alagoinhas Dev Day - UNEBJQuery Alagoinhas Dev Day - UNEB
JQuery Alagoinhas Dev Day - UNEB
 
Desenvolvendo com Silverlight para WP7 Mango [Update]
Desenvolvendo com Silverlight para WP7 Mango [Update]Desenvolvendo com Silverlight para WP7 Mango [Update]
Desenvolvendo com Silverlight para WP7 Mango [Update]
 
Wicket 2008
Wicket 2008Wicket 2008
Wicket 2008
 
Criação de aplicações web com python
Criação de aplicações web com pythonCriação de aplicações web com python
Criação de aplicações web com python
 
Python 08
Python 08Python 08
Python 08
 
Play Framework - FLISOL
Play Framework - FLISOLPlay Framework - FLISOL
Play Framework - FLISOL
 
Intrudução ao Behavior Driven Development (BDD) com Ruby on Rails
Intrudução ao Behavior Driven Development (BDD) com Ruby on RailsIntrudução ao Behavior Driven Development (BDD) com Ruby on Rails
Intrudução ao Behavior Driven Development (BDD) com Ruby on Rails
 
Maratona Windows Phone 7
Maratona Windows Phone 7Maratona Windows Phone 7
Maratona Windows Phone 7
 
Testes Automatizados e o iOS
Testes Automatizados e o iOSTestes Automatizados e o iOS
Testes Automatizados e o iOS
 
Boas práticas de Automação de Testes
Boas práticas de Automação de TestesBoas práticas de Automação de Testes
Boas práticas de Automação de Testes
 
Programação Orientada a Testes
Programação Orientada a TestesProgramação Orientada a Testes
Programação Orientada a Testes
 
Explorando a API Rest Jira Cloud
Explorando a API Rest Jira CloudExplorando a API Rest Jira Cloud
Explorando a API Rest Jira Cloud
 
InterCon 2017 - Engenharia de segurança web: Proteja todas as camadas de seu ...
InterCon 2017 - Engenharia de segurança web: Proteja todas as camadas de seu ...InterCon 2017 - Engenharia de segurança web: Proteja todas as camadas de seu ...
InterCon 2017 - Engenharia de segurança web: Proteja todas as camadas de seu ...
 
Treze ferramentas/frameworks para desenvolvimento Android
Treze ferramentas/frameworks para desenvolvimento AndroidTreze ferramentas/frameworks para desenvolvimento Android
Treze ferramentas/frameworks para desenvolvimento Android
 
Treze ferramentas/frameworks para desenvolvimento android
Treze ferramentas/frameworks para desenvolvimento androidTreze ferramentas/frameworks para desenvolvimento android
Treze ferramentas/frameworks para desenvolvimento android
 
Aplicacoes Rapidas Para Web Com Django
Aplicacoes Rapidas Para Web Com DjangoAplicacoes Rapidas Para Web Com Django
Aplicacoes Rapidas Para Web Com Django
 

Último

Último (8)

ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docxATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
 
ATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docx
ATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docxATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docx
ATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docx
 
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docxATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
 
Luís Kitota AWS Discovery Day Ka Solution.pdf
Luís Kitota AWS Discovery Day Ka Solution.pdfLuís Kitota AWS Discovery Day Ka Solution.pdf
Luís Kitota AWS Discovery Day Ka Solution.pdf
 
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docxATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
 
Boas práticas de programação com Object Calisthenics
Boas práticas de programação com Object CalisthenicsBoas práticas de programação com Object Calisthenics
Boas práticas de programação com Object Calisthenics
 
Programação Orientada a Objetos - 4 Pilares.pdf
Programação Orientada a Objetos - 4 Pilares.pdfProgramação Orientada a Objetos - 4 Pilares.pdf
Programação Orientada a Objetos - 4 Pilares.pdf
 
Padrões de Projeto: Proxy e Command com exemplo
Padrões de Projeto: Proxy e Command com exemploPadrões de Projeto: Proxy e Command com exemplo
Padrões de Projeto: Proxy e Command com exemplo
 

BDD in .NET projects