60 likes | 235 Views
BDD. Behaviour Driven Development Desenvolvimento Guiado por Especificações Comportamentais. BDD x TDD. BDD ~~ TDD troca de ”testes” por ”comportamentos” BDD = TDD + fluência + linguagem ubíqua
E N D
BDD Behaviour Driven Development Desenvolvimento Guiado por Especificações Comportamentais
BDD x TDD BDD ~~ TDD troca de ”testes” por ”comportamentos” BDD = TDD + fluência + linguagem ubíqua + Modelo do Domínio
BDD - Estórias Estórias 1: [Test] 2: public void Transfer_to_cash_account() 3: { 4: 5: Account savings = null; 6: Account cash = null; 8: Story transferStory = new Story("Transfer to cash account"); 10: transferStory 11: .AsA("savings account holder") 12: .IWant("to transfer money from my savings account") 13: .SoThat("I can get cash easily from an ATM");
BDD - Estórias 15: transferStory 16: .WithScenario("Savings account is in credit") 18: .Given("my savings account balance is", 100, delegate(int accountBalance) { savings = new Account(accountBalance); }) 19: .And("my cash account balance is", 10, delegate(int accountBalance) { cash = new Account(accountBalance); }) 20: .When("I transfer to cash account", 20, delegate(int transferAmount){savings.TransferTo(cash,transferAmount);}) 21: .Then("my savings account balance should be", 80, delegate(int expectedBalance) { Assert.AreEqual(expectedBalance, savings.Balance); }) 22: .And("my cash account balance should be", 30, delegate(int expectedBalance) { Assert.AreEqual(expectedBalance, cash.Balance); }) 23:
BDD - Estórias e Cenários • Estórias transferStory 32: .WithScenario("Savings account is overdrawn") 33: 34: .Given("my savings account balance is", -20) 35: .And("my cash account balance is", 10) 36: .When("I transfer to cash account", 20) 37: .Then("my savings account balance should be", -20) 38: .And("my cash account balance should be", 10); 39: 40: }