• Nenhum resultado encontrado

Software development

N/A
N/A
Protected

Academic year: 2022

Share "Software development"

Copied!
22
0
0

Texto

(1)

Software development

phmb@cin.ufpe.br ◈ twitter.com/pauloborba

Paulo Borba

Informatics Center

Federal University of Pernambuco

(2)

Testing: implementation, maintenance and

execution

(3)

Directly connecting requirements

(scenarios) and tests

(4)

Feature scenarios

Scenario: new article

Given the system has no article entitled

"A theory of software product line refinement"

When I create the article "A theory of software

product line refinement" with file name "TCS.pdf"

Then the article "A theory of software product line refinement" is properly stored by the system

(5)

Via controllers, given and when

Given(~'^the system has no article

entitled "([^"]*)"$') { String title ->

article = Periodico.findByTitle(title) assert article == null

}

When(~'^I create the article "([^"]*)" with file

name "([^"]*)"$') { String title, filename ->

TestDataAndOperations.createArticle(title, filename) }

(6)

Via controllers, then

Then(~'^the article "([^"]*)" is properly stored by the system$') { String title ->

article = Periodico.findByTitle(title)

assert TestDataAndOperations.compatibleTo(

article, title) }

(7)

Auxiliary classes

static public void createArticle(String title, filename) { def cont = new PeriodicoController()

cont.params << TestData.findArticleByTitle(title) << [file: filename]

cont.request.setContent(new byte[1000]) cont.create()

cont.save()

cont.response.reset() }

(8)

GUI based scenario

Scenario: new article web

Given I am at the publications menu When I select the "Article" option

And I select the new article option Then I can fill the article details

(9)

GUI based test, given

Given(~'^I am at the publications menu$') { ->

to LoginPage at LoginPage

page.add("admin","adminadmin") at PublicationsPage

}

(10)

GUI based test, when and then

When(~'^I select the "([^"]*)" option$') { String o ->

at PublicationsPage page.select(o)

}

Then(~'^I can fill the article details$') { ->

at ArticleCreatePage

page.fillArticleDetails() }

(11)

Pages, content

class ArticleCreatePage extends Page { static url = "periodico/create"

static at = { …

title ==~ gp.msg("default.create.label",…) journal != null

}

static content = { journal { $("input", id: "journal") } }

… }

(12)

Pages, functions

class ArticleCreatePage extends Page { …

def fillArticleDetails() {

$("form").title = "A theory of …"

$("form").journal = "Theoretical Computer …"…

} }

(13)

Pages, more functions

class PublicationsPage extends Page { …

def select(String s) {

$('div', id: 'status').find('a', text: s).click() }

def getLink(String linkName) {

$('div#status a', text: linkName) }

}

(14)

Practices

Parametrize tests

Each test can run independently of the others, assuming a fresh application instance

Passing state between steps

Before pushing (sometimes committing), make sure all tests pass

Executed 200 tests without a single error or failure

(15)

Create interface when little functionality is available

class PeriodicoController { create() {}

save() {}

}

functionality interface

(16)

Test behavior should strictly conform to scenario semantics

When(~'^I select to view "([^"]*)" in resulting list$') { String title ->

at ArticlesPage

page.selectViewArticle(title) at ArticleShowPage

} first and third command are

not implied by the scenario step semantics

(17)

Avoid ambiguities due to similar step sentences

Then(~'^I can fill the article details$') {->

at ArticleCreatePage

page.fillArticleDetails() }

Then(~'^I can fill the tool details$') { ->

at FerramentaCreatePage page.fillToolDetails()

}

(18)

Do not duplicate test code

def fillLoginDataOnly(...) {

$("form").username = username $("form").password = password }

def fillLoginDataAndSubmit(...) {

$("form").username = username $("form").password = password $("form").signIn().click()

} class ResearchGroupPage extends Page {

static url = "researchGroup/list" ...

}

class ResearchGroupListPage extends Page { static url = "researchGroup/list" ...

}

(19)

Tests should clean up environment at the end

After() {   ...

def uploadsFolder = new File(...) uploadsFolder.listFiles().each { innerFile ->

innerFile.deleteOnExit() }

}

(20)

Do not mix GUI and controller tests:

they simulate different application instances

Given(~'^I am at the articles page and the article "([^"]*)"

is stored in the system with file name "([^"]*)"$') { String title, filename ->

...

TestDataAndOperations.createArticle(title, filename) article = Periodico.findByTitle(title)

assert article != null to ArticlesPage

at ArticlesPage }

(21)

Tests should be plataform (including browser) and language independent

class ArticleCreatePage extends Page { static url = "article/create"

static at = {

def gp = new GetPageTitle()

def a = gp.msg("...article.label")

def t = gp.msg("...create.label", [a]) title ==~ t

...

(22)

Software development

phmb@cin.ufpe.br ◈ twitter.com/pauloborba

Paulo Borba

Informatics Center

Federal University of Pernambuco

Referências

Documentos relacionados

Como procedimento cirúrgico em equinos, a glossectomia parcial já foi descrita por diferentes autores para o tratamento de lacerações linguais (HAGUE; HONNAS, 1998; BARBER,

incertos ou em rápida transformação, como pesquisas, mas pode reduzir a capacidade de fornecer um planejamento de longo prazo.. Assinale a alternativa que preenche corretamente as

os servidores que ingressarem no serviço público a partir da sua instituição, os benefícios previdenciários concedidos pelos regimes próprios dos servidores ficarão

As flores foram emasculadas na pré-antese e polinizadas manualmente com pólen oriundo de cultivares diferentes (flores da cultivar Misty foram polinizadas com pólen

Esta importância, também, foi destacada pela equipe de execução deste contrato e pelo cliente, que pelo fato do contrato possuir atividades semelhantes às atividades

As necessidades básicas da população são atendidas pelos criminosos em troca do silêncio e da cumplicidade (SILVEIRA, 2008, p.109). Como levantado pelo autor, a ausência

Outros aspectos que podem ser citados como evidências da consistência do resultado com o quadro atual do setor são: a presença das empresas 2 e 17 (Bom Preço e G. Barbosa), do