• Nenhum resultado encontrado

Software development

N/A
N/A
Protected

Academic year: 2022

Share "Software development"

Copied!
29
0
0

Texto

(1)

Software development

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

Paulo Borba

Informatics Center

Federal University of Pernambuco

(2)
(3)

Evaluation of the Introduction to Groovy and Grails class

Only 10 answers!

"Tive um péssima experiência tentando ler o cap 3 e 4. Os dois caps falam de ruby e isso se torna muito difícil”

''O material sobre Groovy/Grails deveria ter sido passado antes da aula”

"Bem, acho que aulas desse tipo deveriam ser práticas em laboratório"

(4)

Class structure

Check previous activities

Log into google with your CIn account

Access and answer today’s questions (…)

Discuss class material

what haven’t you understood? what don’t you agree?

what haven’t you liked? what are you missing to perform the project task?

Hands-on testing implementation

(5)

Testing: implementation, maintenance and

execution

(6)

Directly connecting requirements

(scenarios) and tests

(7)

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

(8)

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) }

(9)

Via controllers, then

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

article = Periodico.findByTitle(title)

assert TestDataAndOperations.compatibleTo(

article, title) }

(10)

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() }

(11)

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

(12)

GUI based test, given

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

to LoginPage at LoginPage

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

}

(13)

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() }

(14)

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") } }

}

(15)

Pages, functions

class ArticleCreatePage extends Page {

def fillArticleDetails() {

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

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

} }

(16)

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) }

}

(17)

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

(18)

Principles

Run test with different arguments and state content

boundary cases, focus on coverage

Positive and negative cases

Regression

Balance between unity, integration and acceptance tests

(19)

Application as a state machine

Graph representing states and possible transitions

Behavior desired by the user should appear as paths in this graph (traces), undesired

behavior should not appear

Scenarios should verify that desired traces can be observed by testing the application

(20)

Create interface when little functionality is available

class PeriodicoController { create() {}

save() {}

}

functionality interface

(21)

Checklist

(22)

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

(23)

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()

}

(24)

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" ...

}

(25)

Tests should clean up environment at the end

After() {   ...

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

innerFile.deleteOnExit() }

}

(26)

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 }

(27)

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

...

(28)

Testing research at CIn

Test generation and static analysis tools:

Marcelo e Paulo

Model-based testing: Alexandre Mota, Juliano e Augusto

Test selection and execution: Juliano

(29)

Software development

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

Paulo Borba

Informatics Center

Federal University of Pernambuco

Referências

Documentos relacionados

O questionamento dessa argumentação biológica, e o debate sobre as relações entre homens e mulheres no ponto de vista social e não apenas na distinção dos

Para ω maiores, como discutido anteriormente, as particulas não respondem efetivamente ao campo magnético oscilatório, que além de provocar uma anulação das inte- rações

Antunes (2013) tece algumas classificações de informalidade vivenciados pelos trabalhadores no Brasil. Antes de elencar as denominações é importante definir o

Inerente ao próprio direito de propriedade, a sua função social tem como objetivo regular o desequilí- brio econômico e o social, decorrente da concentração da propriedade,

Entretanto a alta administração da instituição mostra-se interessada na metodologia de cenários prospectivos e disposta a utilizar ferramentas de verificação, como um

Legend: β – transition rate parameter between susceptible and infectious, α – transition rate parameter between infectious and carriers, θ – transition rate

Nevertheless, there is a lack of evidence of exergames training effects on functionality and muscle function in the aged, that can be explained by the absence of exercise

Por sua vez, a propósito do Salmo 148: «Toda a nossa vida presente deve transcorrer no louvor de Deus, porque o louvor de Deus será também a alegria eterna da nossa vida