53
BDD para projetos .NET

BDD in .NET projects

Embed Size (px)

DESCRIPTION

Talk presented to Atlântico Team.

Citation preview

Page 1: BDD in .NET projects

BDD para projetos .NET

Page 2: BDD in .NET projects

Por que?

Page 3: BDD in .NET projects

Facilidade

Page 4: BDD in .NET projects

Facilidade

Praticidade

Page 5: BDD in .NET projects

Facilidade

Praticidade

Lingua nativa

Page 6: BDD in .NET projects

Facilidade

PraticidadeLingua nativa (ou

quase isso)

Page 7: BDD in .NET projects

Testes end-to-end

Page 8: BDD in .NET projects

Testes end-to-end

Como assim?

Page 9: BDD in .NET projects

Testes end-to-end

Interface Controller RepositorioBD

Page 10: BDD in .NET projects

Testes end-to-end

Interface Controller RepositorioBD

User (browser)

Page 11: BDD in .NET projects

Testes end-to-end

Interface Controller RepositorioBD

User (browser)

Testa todas as camadas

Page 12: BDD in .NET projects

Ferramentas

Page 13: BDD in .NET projects

Ferramentas?

Page 14: BDD in .NET projects

FerramentasSelenium

Page 15: BDD in .NET projects

FerramentasSelenium (browser)

Page 16: BDD in .NET projects

FerramentasSelenium (browser)

SpecFlow

Page 17: BDD in .NET projects

FerramentasSelenium (browser)SpecFlow (solução

BDD)

Page 18: BDD in .NET projects

FerramentasSelenium (browser)SpecFlow (solução

BDD)NUnit

Page 19: BDD in .NET projects

FerramentasSelenium (browser)SpecFlow (solução

BDD)NUnit (framework de testes - asserções)

Page 20: BDD in .NET projects

Sintaxe

Page 21: BDD in .NET projects

SintaxeFeature

file:

Page 22: BDD in .NET projects

SintaxeFeature

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

Page 23: BDD in .NET projects

SintaxeFeature

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:

Page 24: BDD in .NET projects

SintaxeFeature

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:

Page 25: BDD in .NET projects

SintaxeFeature

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:

Page 26: BDD in .NET projects

SintaxeFeature

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:

Page 27: BDD in .NET projects

Sintaxe

Page 28: BDD in .NET projects

SintaxeResultado:

Page 29: BDD in .NET projects

SintaxeResultado:Sintaxe

Page 30: BDD in .NET projects

SintaxeVamos incrementar esse teste!

Page 31: BDD in .NET projects

SintaxeFeature

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:

Page 32: BDD in .NET projects

SintaxeResultado:Sintaxe

xtrumanx

P@55w0Rd

Page 33: BDD in .NET projects

O que testar?

Page 34: BDD in .NET projects

O que testar?O que for

importante

Page 35: BDD in .NET projects

O que testar?O que for

importanteE porque não tudo?

Page 36: BDD in .NET projects

Testes de aceitação tendem:

Page 37: BDD in .NET projects

Testes de aceitação tendem:

1. Difícil escrita

Page 38: BDD in .NET projects

Testes de aceitação tendem:

1. Difícil escrita2. Difícil manutenção

Page 39: BDD in .NET projects

Testes de aceitação tendem:

1. Difícil escrita2. Difícil manutenção

3. Execução lenta

Page 40: BDD in .NET projects

Testes de aceitação tendem:

1. Difícil escrita2. Difícil manutenção3. Execução lenta

Page 41: BDD in .NET projects

Testes de aceitação tendem:

1. Difícil escrita2. Difícil manutenção3. Execução lenta

Page 42: BDD in .NET projects

Testes de aceitação tendem:

1. Difícil escrita2. Difícil manutenção3. Execução lenta

Page 43: BDD in .NET projects

Testes de aceitação tendem:

1. Difícil escrita2. Difícil manutenção3. Execução lenta

4. Feedback demorado

Page 44: BDD in .NET projects

Testes de aceitação tendem:

1. Difícil escrita2. Difícil manutenção3. Execução lenta

4. Feedback demorado

Page 45: BDD in .NET projects

Cenário ideal:

Page 46: BDD in .NET projects

Cenário ideal:

*quase* ideal

Page 47: BDD in .NET projects

Cenário ideal:

ideal

Page 48: BDD in .NET projects

Por que?Feedback rápido é

importante

Page 49: BDD in .NET projects

Por que?Feedback rápido é

importante

Page 50: BDD in .NET projects

Por que?Feedback rápido é

importante

Page 51: BDD in .NET projects

Por que?Feedback rápido é

importante

Page 52: BDD in .NET projects

Sugestão

Page 53: BDD in .NET projects

Sugestãohttp://www.infoq.com/br/presentations/o-que-nao-testar