Escolar Documentos
Profissional Documentos
Cultura Documentos
Teste de Software
TDD: Test Driven Development
I Assertiva (assertion):
Mecanismo que permite verificar o comportamento do teste unitário.
Retorna valores true ou false (correspondência ao resultado esperado).
Falhas na assertiva são em geral sinalizadas por meio de exceções.
public c l a s s I d e n t i f i e r {
p u b l i c boolean v a l i d a t e I d e n t i f i e r ( S t r i n g s ) {
char achar ; boolean v a l i d _ i d ; v a l i d _ i d = t r u e ;
achar = s . charAt ( 0 ) ; v a l i d _ i d = v a l i d _ s ( achar ) ;
i f ( s . length ( ) > 1) {
achar = s . charAt ( 1 ) ; i n t i = 1 ;
while ( i < s . l e n g t h ( ) − 1 ) {
achar = s . charAt ( i ) ;
i f ( ! v a l i d _ f ( achar ) ) { v a l i d _ i d = f a l s e ; } i ++;
}
}
i f ( v a l i d _ i d && ( s . l e n g t h ( ) >= 1 ) && ( s . l e n g t h ( ) <= 6 ) )
{ return true ; } else { return f a l s e ; }
}
p u b l i c boolean v a l i d _ s ( char ch ) {
i f ( ( ( ch >= ’A ’ ) && ( ch <= ’Z ’ ) ) || ( ( ch >= ’ a ’ ) && ( ch <= ’ z ’ ) ) )
{ return true ; } else { return f a l s e ; }
}
p u b l i c boolean v a l i d _ f ( char ch ) {
i f ( ( ( ch >= ’A ’ ) && ( ch <= ’Z ’ ) ) || ( ( ch >= ’ a ’ ) && ( ch <= ’ z ’ ) ) ||
( ( ch >= ’ 0 ’ ) && ( ch <= ’ 9 ’ ) ) )
{ return true ; } else { return f a l s e ; }
}
}
Teste Estrutural 5/24
JUnit
public c l a s s IdentifierMain {
p u b l i c s t a t i c void main ( S t r i n g [ ] a r g s ) {
i f ( a r g s . l e n g t h == 0 ) {
System . out . p r i n t l n ( " Usage : i d e n t i f i e r . I d e n t i f i e r [ s t r i n g ] " ) ;
}
else {
I d e n t i f i e r id = new I d e n t i f i e r ( ) ;
i f ( id . v a l i d a t e I d e n t i f i e r ( args [ 0 ] ) ) {
System . out . p r i n t l n ( " Valid " ) ;
}
else {
System . out . p r i n t l n ( " I n v a l i d " ) ;
}
}
}
}
$ javac IdentifierMain.java
public c l a s s HelloJUnit {
@Test
p u b l i c void f i r s t T e s t ( ) {
f a i l ( " T e s t e incompleto ! ! ! ! " ) ;
}
}
Teste Estrutural 6/24
JUnit
FAILURES ! ! !
T e s t s run : 1 , Failures : 1
public c l a s s HelloJunit2 {
@Test
p u b l i c void v a l i d a t e 1 ( ) {
I d e n t i f i e r id = new I d e n t i f i e r ( ) ;
boolean r e s u l t = id . v a l i d a t e I d e n t i f i e r ( " abc " ) ;
a s s e r t E q u a l s ( tr ue , r e s u l t ) ;
}
@Test
p u b l i c void v a l i d a t e 2 ( ) {
I d e n t i f i e r id = new I d e n t i f i e r ( ) ;
boolean r e s u l t = id . v a l i d a t e I d e n t i f i e r ( " 1de " ) ;
assertEquals ( false , result ) ;
}
}
OK ( 2 t e s t s )
public c l a s s I d e n t i f i e r {
p u b l i c boolean v a l i d a t e I d e n t i f i e r ( S t r i n g s ) {
char achar ;
boolean v a l i d _ i d = f a l s e ;
i f ( ( s ! = n u l l ) && ( s . l e n g t h ( ) > 0 ) ) {
achar = s . charAt ( 0 ) ;
v a l i d _ i d = v a l i d _ s ( achar ) ;
i f ( s . length ( ) > 1) {
achar = s . charAt ( 1 ) ;
int i = 1;
while ( i < s . l e n g t h ( ) − 1 ) {
achar = s . charAt ( i ) ;
i f ( ! v a l i d _ f ( achar ) )
valid_id = false ;
i ++;
}
}
}
...
Teste Estrutural 7/24
JUnit
Vincenzi, A. M. R., Delamaro, M. E., Dias Neto, A. C., Fabbri, S. C. P. F., Jino, M., and
Maldonado, J. C. (2018).
Automatização de teste de software com ferramentas de software livre.
Elseiver.
Page 3: https:
//www.forbes.com/sites/alexanderlavin/2019/06/17/beyond-black-box-ai/
Page 2: https://medium.com/@vinicius_roc/
testes-automatizados-em-arquiteturas-orientada-a-servi%C3%
A7os-soa-a892c82811f3
Page 2: http://ithare.com/
testing-my-personal-take-on-testing-including-unit-testing-and-atddbdd/
Page 3: https://martinfowler.com/bliki/TestPyramid.html
Page 4: https://www.slideshare.net/igorvavrish/unit-testing-framework
Page 5: https://medium.com/default-to-open/
property-based-testing-in-kotlin-part-1-56929927b8b8
Page 6: https://meissarunner.com/
Page 7: https://medium.com/@victorsteven/
understanding-unit-and-integrationtesting-in-golang-ba60becb778d
Page 8: https://realpython.com/django-pytest-fixtures/
Page 9: https://pedrorijo.com/blog/intro-mutation/
Page 41:
https://www.epicgames.com/store/en-US/product/before-we-leave/home
Page 43: https:
//www.codeaffine.com/2014/08/18/junit-in-a-nutshell-test-structure/
Page 44: https://subscription.packtpub.com/book/web_development/
9781787285736/1/ch01lvl1sec10/testing-frameworks-for-the-jvm
Page 48:
https://www.zoltanraffai.com/blog/checked-and-unchecked-exceptions/
Page 49:
https://medium.com/techtron/functional-errors-handling-1d1b4688769d
Page : http://www.rebellionrider.com/
the-most-innovative-ways-to-utilize-python-slice/
Page 51: https://br.linkedin.com/learning/
robot-framework-test-automation-level-1-selenium?trk=seo_pp_d_cymbii_
m015_learning
Page 52: https://br.123rf.com/photo_19713801_car%C3%
A1ter-alaranjado-dos-desenhos-animados-correr-com-grande-engrenagem-bra
html
Page 54: https://imgur.com/gallery/TUO5ls1
Page 56:
https://blog.maddevs.io/mad-fake-slack-945ea810a778?gi=858b6447433
Page 58: https://medium.com/edureka/
selenium-framework-data-keyword-hybrid-frameworks-ea8d4f4ce99f