SlideShare uma empresa Scribd logo
1 de 49
Baixar para ler offline
Automatically
RepairingTest Cases
for Evolving Method Declarations
Mehdi Mirzaaghaei
Fabrizio Pastore
Mauro Pezzè
Università
della
Svizzera
italiana
http://swiss-landmarks.ch/panos/Lugano9.jpg
Software evolves
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance
};
}
Software evolves
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance
};
}
Software evolves
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance
};
}
Software evolves
public class .....
public class AccountUtil {
	 private double dailyInterestRate = 0.00005;
	 private int interestTerm=365;
	
	 public double interest(BankAccount account
return account.getBalance()
*dailyInterestRate*interestTerm;
	 }
...
public class AccountFactory {
	 public static BankAccount create( AccountContext ctx, boolean special ){
	 	 BankAccount account = new BankAcccount( ctx.amount );
	 	 if ( special ){
	 	 	 account.setInterestRate(0.0001);
	 	 }
	 ...
public class .....
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance
};
}
Software evolves
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance
};
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
	 balance += money.centsValue;
	 }
	 public int getBalance(){
return balance;
};
}
Original classes are modified
public class .....
public class .....
Test cases need maintenance
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance
};
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
	 balance += money.centsValue;
	 }
	 public int getBalance(){
return balance;
};
}
Compilation error:
Method deposit(Money) in the type
BankAccount is not applicable for
the arguments (int)
changes in method declarations:
23% changes
that impact on compilation
changes in method declarations:
23% changes
that impact on compilation
> 80% in maintenance releases
changes in method declarations:
23% changes
that impact on compilation
> 80% in maintenance releases
Automatic Repair to Save Effort
AutomaticTest Repair
[Memon et. al. 2008, Grechanik 2009 ]
Repair GUI tests
Well suited only for GUI tests
AutomaticTest Repair
[Memon et. al. 2008, Grechanik 2009 ]
Repair GUI tests Repair Oracles
[B. Daniel et al 2010]
testInterest(){
...
assertEquals( 50, result );
}
FAILURE: expected 50, found: 40
assertEquals( 40, result );
Well suited only for GUI tests Focus on oracles only
AutomaticTest Repair
[Memon et. al. 2008, Grechanik 2009 ]
Repair GUI tests
Refactoring Techniques
[ReBa, Eclipse]
Repair Oracles
[B. Daniel et al 2010]
testInterest(){
...
assertEquals( 50, result );
}
FAILURE: expected 50, found: 40
assertEquals( 40, result );
//calculate one year interest
result = account.interest();
result = account.interest( 0 );
Well suited only for GUI tests Focus on oracles only
Prevent only some compilation errors
AutomaticTest Repair
TestCareAssistant
repairs test case compilation errors
• Parameter add
• Parameter type change • Return type change
• Parameter remove
caused by method declaration changes
TestCareAssistant
repairs test case compilation errors
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals(500, account.getBalance());
• Parameter add
• Parameter type change • Return type change
• Parameter remove
caused by method declaration changes
TestCareAssistant
repairs test case compilation errors
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals(500, account.getBalance());
Replace:
int amount = 500;
with:
Money amount = new Money(500);
account.deposit(amount);
• Parameter add
• Parameter type change • Return type change
• Parameter remove
caused by method declaration changes
TestCareAssistant
repairs test case compilation errors
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals(500, account.getBalance());
testDeposit(){
BankAccount account = new BankAccount();
Money amount = new Money(500);
account.deposit(amount);
assertEquals(500, account.getBalance());
Replace:
int amount = 500;
with:
Money amount = new Money(500);
account.deposit(amount);
• Parameter add
• Parameter type change • Return type change
• Parameter remove
caused by method declaration changes
TestCareAssistant
repairs test case compilation errors
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals(500, account.getBalance());
testDeposit(){
BankAccount account = new BankAccount();
Money amount = new Money(500);
account.deposit(amount);
assertEquals(500, account.getBalance());
Replace:
int amount = 500;
with:
Money amount = new Money(500);
account.deposit(amount);
• Parameter add
• Parameter type change • Return type change
• Parameter remove
caused by method declaration changes
TestCareAssistant
repairs test case compilation errors
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals(500, account.getBalance());
testDeposit(){
BankAccount account = new BankAccount();
Money amount = new Money(500);
account.deposit(amount);
assertEquals(500, account.getBalance());
Replace:
int amount = 500;
with:
Money amount = new Money(500);
account.deposit(amount);
• Parameter add
• Parameter type change • Return type change
• Parameter remove
caused by method declaration changes
TestCareAssistant
repairs test case compilation errors
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals(500, account.getBalance());
testDeposit(){
BankAccount account = new BankAccount();
Money amount = new Money(500);
account.deposit(amount);
assertEquals(500, account.getBalance());
Replace:
int amount = 500;
with:
Money amount = new Money(500);
account.deposit(amount);
• Parameter add
• Parameter type change • Return type change
• Parameter remove
caused by method declaration changes
Repair parameter type change
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance;
}
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
balance += money.CentsValue;
	 }
	 public int getBalance(){
return balance;
}
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
Version 0 Version 1
Which parameter to initialize?
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance;
}
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
balance += money.CentsValue;
	 }
	 public int getBalance(){
return balance;
}
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
Version 0 Version 1
Which parameter to initialize?
Use code diff to identify the parameter1
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance;
}
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
balance += money.CentsValue;
	 }
	 public int getBalance(){
return balance;
}
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
Version 0 Version 1
How to initialize a complex object?
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance;
}
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
balance += money.centsValue;
	 }
	 public int getBalance(){
return balance;
}
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
Version 0 Version 1
How to initialize a complex object?
Find first uses of parameter fields inVersion12
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance;
}
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
balance += money.centsValue;
	 }
	 public int getBalance(){
return balance;
}
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
Version 0 Version 1
How to determine fields values?
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance;
}
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
balance += money.centsValue;
	 }
	 public int getBalance(){
return balance;
}
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
Version 0 Version 1
How to determine fields values?
Diff to identify corresponding variable inVersion 03
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance;
}
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
balance += money.centsValue;
	 }
	 public int getBalance(){
return balance;
}
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
Version 0 Version 1
What was the original value?
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance;
}
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
balance += money.CentsValue;
	 }
	 public int getBalance(){
return balance;
}
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
Version 0 Version 1
What was the original value?
Analyze the def-use chain of the variable back to
the definition in the test4
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance;
}
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
balance += money.CentsValue;
	 }
	 public int getBalance(){
return balance;
}
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
Version 0 Version 1
What was the original value?
Analyze the def-use chain of the variable back to
the definition in the test4
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance;
}
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
balance += money.CentsValue;
	 }
	 public int getBalance(){
return balance;
}
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
Version 0 Version 1
How can we repair the test?
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance;
}
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
balance += money.centsValue;
	 }
	 public int getBalance(){
return balance;
}
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
Version 0 Version 1
How can we repair the test?
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance;
}
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
balance += money.centsValue;
	 }
	 public int getBalance(){
return balance;
}
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
Version 0 Version 1
How can we repair the test?
Instantiate the new object,
use original values to initialize fields5
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance;
}
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
balance += money.centsValue;
	 }
	 public int getBalance(){
return balance;
}
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
Version 0 Version 1
How can we repair the test?
Instantiate the new object,
use original values to initialize fields5
Replace:
int amount = 500;
with:
Money amount = new Money(500);
account.deposit(amount);
public class BankAccount {
	 private int balance;
	 public void deposit(int cents){
	 balance += cents;
	 }
	 public int getBalance(){
return balance;
}
}
public class BankAccount {
	 private int balance;
	 public void deposit(Money money){
balance += money.centsValue;
	 }
	 public int getBalance(){
return balance;
}
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals( 500, account.getBalance());
}
Version 0 Version 1
To what extentTestCareAssistant can
fix test cases automatically?
To what extentTestCareAssistant can
fix test cases automatically?
• Repair 22 test cases of 6 open source systems
• Continuum, Geronimo, xml-security, PMD, POI, Shindig
• 24 compilation errors caused by different changes
• 9 parameter types changed, 8 parameters added, 3 parameters
removed, 4 return types changed
To what extentTestCareAssistant can
fix test cases automatically?
Results Total Repaired %
Test Cases 22 16 72
Compilation Errors 24 18 75
Values Initialized 36 29 80
• Repair 22 test cases of 6 open source systems
• Continuum, Geronimo, xml-security, PMD, POI, Shindig
• 24 compilation errors caused by different changes
• 9 parameter types changed, 8 parameters added, 3 parameters
removed, 4 return types changed
To what extentTestCareAssistant can
fix test cases automatically?
Results Total Repaired %
Test Cases 22 16 72
Compilation Errors 24 18 75
Values Initialized 36 29 80
• Repair 22 test cases of 6 open source systems
• Continuum, Geronimo, xml-security, PMD, POI, Shindig
• 24 compilation errors caused by different changes
• 9 parameter types changed, 8 parameters added, 3 parameters
removed, 4 return types changed
To what extentTestCareAssistant can
fix test cases automatically?
• Static data flow analysis not always effective
• Use of complex data structures, e.g. hash tables
• Changes in method logic
• Changes in interfaces
Results Total Repaired %
Test Cases 22 16 72
Compilation Errors 24 18 75
Conclusions
public class BankAccount {
	 public void deposit(int cents){
	 balance += cents;
	 }
}
public class BankAccount {
	 public void deposit(Money money){
balance += money.CentsValue;
	 }
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals(500, account.getBalance());
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals(500, account.getBalance());
Conclusions
public class BankAccount {
	 public void deposit(int cents){
	 balance += cents;
	 }
}
public class BankAccount {
	 public void deposit(Money money){
balance += money.CentsValue;
	 }
}
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals(500, account.getBalance());
testDeposit(){
BankAccount account = new BankAccount();
Money amount = new Money(500);
account.deposit(amount);
assertEquals(500, account.getBalance());
Conclusions
public class BankAccount {
	 public void deposit(int cents){
	 balance += cents;
	 }
}
public class BankAccount {
	 public void deposit(Money money){
balance += money.CentsValue;
	 }
}
Replace:
int amount = 500;
with:
Money amount = new Money(500);
account.deposit(amount);
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals(500, account.getBalance());
testDeposit(){
BankAccount account = new BankAccount();
Money amount = new Money(500);
account.deposit(amount);
assertEquals(500, account.getBalance());
TestCareAssistant
Future Work
CopticChronology EthiopicChronology
Chronology
+ withUTC()
TestCopticUTC(){
....
assertEquals("AM",
copticChronology.withUTC() );
}
Future Work
CopticChronology EthiopicChronology
Chronology
+ withUTC()
TestCopticUTC(){
....
assertEquals("AM",
copticChronology.withUTC() );
}
TestEthiopicUTC(){
....
assertEquals("EE",
ethiopicChronology.withUTC()
}
CopticChronology EthiopicChronology
Chronology
+ withUTC()
Future Work
CopticChronology EthiopicChronology
Chronology
+ withUTC()
TestCopticUTC(){
....
assertEquals("AM",
copticChronology.withUTC() );
}
TestEthiopicUTC(){
....
assertEquals("EE",
ethiopicChronology.withUTC()
}
CopticChronology EthiopicChronology
Chronology
+ withUTC()
Future Work
CopticChronology EthiopicChronology
Chronology
+ withUTC()
TestCopticUTC(){
....
assertEquals("AM",
copticChronology.withUTC() );
}
TestEthiopicUTC(){
....
assertEquals("EE",
ethiopicChronology.withUTC()
}
CopticChronology EthiopicChronology
Chronology
+ withUTC()
AutomateTest Generation by Identifying and
ImplementingTest Adaptation Patterns
Questions?
public class BankAccount {
	 public void deposit(int cents){
	 balance += cents;
	 }
}
public class BankAccount {
	 public void deposit(Money money){
balance += money.CentsValue;
	 }
}
Replace:
int amount = 500;
with:
Money amount = new Money(500);
account.deposit(amount);
testDeposit(){
BankAccount account = new BankAccount();
int amount = 500;
account.deposit(amount);
assertEquals(500, account.getBalance());
testDeposit(){
BankAccount account = new BankAccount();
Money amount = new Money(500);
account.deposit(amount);
assertEquals(500, account.getBalance());
TestCareAssistant

Mais conteúdo relacionado

Mais procurados

VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEDarwin Durand
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns projectAayush Mittal
 
Dompletion: DOM-Aware JavaScript Code Completion
Dompletion: DOM-Aware JavaScript Code CompletionDompletion: DOM-Aware JavaScript Code Completion
Dompletion: DOM-Aware JavaScript Code CompletionSALT Lab @ UBC
 
Mutation Analysis for JavaScript Web Applicaiton Testing SEKE2013
Mutation Analysis for JavaScript Web Applicaiton Testing  SEKE2013Mutation Analysis for JavaScript Web Applicaiton Testing  SEKE2013
Mutation Analysis for JavaScript Web Applicaiton Testing SEKE2013nkazuki
 
How Reactive do we need to be
How Reactive do we need to beHow Reactive do we need to be
How Reactive do we need to beJana Karceska
 
Oops lab manual2
Oops lab manual2Oops lab manual2
Oops lab manual2Mouna Guru
 
The biggest lies about react hooks
The biggest lies about react hooksThe biggest lies about react hooks
The biggest lies about react hooksMarios Fakiolas
 
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERINSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERDarwin Durand
 
Promise: async programming hero
Promise: async programming heroPromise: async programming hero
Promise: async programming heroThe Software House
 
Developer Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duoDeveloper Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duoThe Software House
 
Beautiful java script
Beautiful java scriptBeautiful java script
Beautiful java scriptÜrgo Ringo
 
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...sriram sarwan
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent codeDror Helper
 

Mais procurados (19)

Writing Good Tests
Writing Good TestsWriting Good Tests
Writing Good Tests
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns project
 
MaintainStaffTable
MaintainStaffTableMaintainStaffTable
MaintainStaffTable
 
Dompletion: DOM-Aware JavaScript Code Completion
Dompletion: DOM-Aware JavaScript Code CompletionDompletion: DOM-Aware JavaScript Code Completion
Dompletion: DOM-Aware JavaScript Code Completion
 
Mutation Analysis for JavaScript Web Applicaiton Testing SEKE2013
Mutation Analysis for JavaScript Web Applicaiton Testing  SEKE2013Mutation Analysis for JavaScript Web Applicaiton Testing  SEKE2013
Mutation Analysis for JavaScript Web Applicaiton Testing SEKE2013
 
How Reactive do we need to be
How Reactive do we need to beHow Reactive do we need to be
How Reactive do we need to be
 
Oops lab manual2
Oops lab manual2Oops lab manual2
Oops lab manual2
 
Clojure workshop
Clojure workshopClojure workshop
Clojure workshop
 
The biggest lies about react hooks
The biggest lies about react hooksThe biggest lies about react hooks
The biggest lies about react hooks
 
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERINSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
 
Java 2
Java 2Java 2
Java 2
 
Promise: async programming hero
Promise: async programming heroPromise: async programming hero
Promise: async programming hero
 
Practical
PracticalPractical
Practical
 
Developer Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duoDeveloper Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duo
 
Beautiful java script
Beautiful java scriptBeautiful java script
Beautiful java script
 
A Test of Strength
A Test of StrengthA Test of Strength
A Test of Strength
 
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...
Cbsecomputersciencecclass12boardproject bankmanagmentsystem-180703065625-conv...
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
 

Destaque

ORASI Consulting Group Servicios
  ORASI Consulting Group Servicios  ORASI Consulting Group Servicios
ORASI Consulting Group ServiciosUniversidad de Lima
 
GESTAR II - Aaa4 mat aluno
GESTAR II - Aaa4 mat alunoGESTAR II - Aaa4 mat aluno
GESTAR II - Aaa4 mat alunoAna Almeida
 
2011 Redin e Silveira - a condição camponesa revisitada - revista isegoria
2011   Redin e Silveira - a condição camponesa revisitada - revista isegoria2011   Redin e Silveira - a condição camponesa revisitada - revista isegoria
2011 Redin e Silveira - a condição camponesa revisitada - revista isegoriaEzequiel Redin
 
Stemi2009
Stemi2009Stemi2009
Stemi2009Raj k
 
Gothic art
Gothic artGothic art
Gothic artnowadeba
 
[R Mortimer] Uma Linda Ideia A Ser Imitada Som
[R Mortimer] Uma Linda Ideia A Ser Imitada Som[R Mortimer] Uma Linda Ideia A Ser Imitada Som
[R Mortimer] Uma Linda Ideia A Ser Imitada SomDennia
 

Destaque (7)

ORASI Consulting Group Servicios
  ORASI Consulting Group Servicios  ORASI Consulting Group Servicios
ORASI Consulting Group Servicios
 
WorldCat Search API
WorldCat Search APIWorldCat Search API
WorldCat Search API
 
GESTAR II - Aaa4 mat aluno
GESTAR II - Aaa4 mat alunoGESTAR II - Aaa4 mat aluno
GESTAR II - Aaa4 mat aluno
 
2011 Redin e Silveira - a condição camponesa revisitada - revista isegoria
2011   Redin e Silveira - a condição camponesa revisitada - revista isegoria2011   Redin e Silveira - a condição camponesa revisitada - revista isegoria
2011 Redin e Silveira - a condição camponesa revisitada - revista isegoria
 
Stemi2009
Stemi2009Stemi2009
Stemi2009
 
Gothic art
Gothic artGothic art
Gothic art
 
[R Mortimer] Uma Linda Ideia A Ser Imitada Som
[R Mortimer] Uma Linda Ideia A Ser Imitada Som[R Mortimer] Uma Linda Ideia A Ser Imitada Som
[R Mortimer] Uma Linda Ideia A Ser Imitada Som
 

Semelhante a Automatically Repairing Test Cases for Evolving Method Declarations

Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right wayThibaud Desodt
 
Practical approach for testing your software with php unit
Practical approach for testing your software with php unitPractical approach for testing your software with php unit
Practical approach for testing your software with php unitMario Bittencourt
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design ExamplesTareq Hasan
 
1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the orgAbbyWhyte974
 
1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the orgMartineMccracken314
 
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdfC++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdfJUSTSTYLISH3B2MOHALI
 
How to write clean tests
How to write clean testsHow to write clean tests
How to write clean testsDanylenko Max
 
Change to oop formatimport java.util.Scanner;import java.io.;.pdf
Change to oop formatimport java.util.Scanner;import java.io.;.pdfChange to oop formatimport java.util.Scanner;import java.io.;.pdf
Change to oop formatimport java.util.Scanner;import java.io.;.pdfMAYANKBANSAL1981
 
Tmpj3 01 201181102muhammad_tohir
Tmpj3 01 201181102muhammad_tohirTmpj3 01 201181102muhammad_tohir
Tmpj3 01 201181102muhammad_tohirpencari buku
 
Bank Program in JavaBelow is my code(havent finished, but it be .pdf
Bank Program in JavaBelow is my code(havent finished, but it be .pdfBank Program in JavaBelow is my code(havent finished, but it be .pdf
Bank Program in JavaBelow is my code(havent finished, but it be .pdfizabellejaeden956
 
Bdd for-dso-1227123516572504-8
Bdd for-dso-1227123516572504-8Bdd for-dso-1227123516572504-8
Bdd for-dso-1227123516572504-8Frédéric Delorme
 
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdfAccount.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdfanujmkt
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd marchRajeev Sharan
 
I need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdfI need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdfrajeshjangid1865
 
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdfimport java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdfKUNALHARCHANDANI1
 
The java class Account that simultes the Account class.pdf
   The java class Account that simultes  the Account class.pdf   The java class Account that simultes  the Account class.pdf
The java class Account that simultes the Account class.pdfakshay1213
 
Droid on Chain - Berry Ventura Lev, Kik
Droid on Chain - Berry Ventura Lev, KikDroid on Chain - Berry Ventura Lev, Kik
Droid on Chain - Berry Ventura Lev, KikDroidConTLV
 
Write a banking program that simulates the operation of your local ba.docx
 Write a banking program that simulates the operation of your local ba.docx Write a banking program that simulates the operation of your local ba.docx
Write a banking program that simulates the operation of your local ba.docxajoy21
 
Code quailty metrics demystified
Code quailty metrics demystifiedCode quailty metrics demystified
Code quailty metrics demystifiedJeroen Resoort
 

Semelhante a Automatically Repairing Test Cases for Evolving Method Declarations (20)

Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right way
 
Practical approach for testing your software with php unit
Practical approach for testing your software with php unitPractical approach for testing your software with php unit
Practical approach for testing your software with php unit
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design Examples
 
1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org
 
1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org1-What are the opportunities and threats that could impact the org
1-What are the opportunities and threats that could impact the org
 
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdfC++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
 
How to write clean tests
How to write clean testsHow to write clean tests
How to write clean tests
 
Change to oop formatimport java.util.Scanner;import java.io.;.pdf
Change to oop formatimport java.util.Scanner;import java.io.;.pdfChange to oop formatimport java.util.Scanner;import java.io.;.pdf
Change to oop formatimport java.util.Scanner;import java.io.;.pdf
 
TDD, BDD and mocks
TDD, BDD and mocksTDD, BDD and mocks
TDD, BDD and mocks
 
Tmpj3 01 201181102muhammad_tohir
Tmpj3 01 201181102muhammad_tohirTmpj3 01 201181102muhammad_tohir
Tmpj3 01 201181102muhammad_tohir
 
Bank Program in JavaBelow is my code(havent finished, but it be .pdf
Bank Program in JavaBelow is my code(havent finished, but it be .pdfBank Program in JavaBelow is my code(havent finished, but it be .pdf
Bank Program in JavaBelow is my code(havent finished, but it be .pdf
 
Bdd for-dso-1227123516572504-8
Bdd for-dso-1227123516572504-8Bdd for-dso-1227123516572504-8
Bdd for-dso-1227123516572504-8
 
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdfAccount.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd march
 
I need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdfI need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdf
 
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdfimport java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
 
The java class Account that simultes the Account class.pdf
   The java class Account that simultes  the Account class.pdf   The java class Account that simultes  the Account class.pdf
The java class Account that simultes the Account class.pdf
 
Droid on Chain - Berry Ventura Lev, Kik
Droid on Chain - Berry Ventura Lev, KikDroid on Chain - Berry Ventura Lev, Kik
Droid on Chain - Berry Ventura Lev, Kik
 
Write a banking program that simulates the operation of your local ba.docx
 Write a banking program that simulates the operation of your local ba.docx Write a banking program that simulates the operation of your local ba.docx
Write a banking program that simulates the operation of your local ba.docx
 
Code quailty metrics demystified
Code quailty metrics demystifiedCode quailty metrics demystified
Code quailty metrics demystified
 

Mais de ICSM 2010

A tree kernel based approach for clone detection
A tree kernel based approach for clone detectionA tree kernel based approach for clone detection
A tree kernel based approach for clone detectionICSM 2010
 
Scalable Semantic Web-based Source Code Search Infrastructure
Scalable Semantic Web-based Source Code Search InfrastructureScalable Semantic Web-based Source Code Search Infrastructure
Scalable Semantic Web-based Source Code Search InfrastructureICSM 2010
 
2D and 3D Visualizations In Wikidev2.0 M. Fokaefs, D. Serrano, B. Tansey and ...
2D and 3D Visualizations In Wikidev2.0 M. Fokaefs, D. Serrano, B. Tansey and ...2D and 3D Visualizations In Wikidev2.0 M. Fokaefs, D. Serrano, B. Tansey and ...
2D and 3D Visualizations In Wikidev2.0 M. Fokaefs, D. Serrano, B. Tansey and ...ICSM 2010
 
Wiki dev nlp
Wiki dev nlpWiki dev nlp
Wiki dev nlpICSM 2010
 
iFL: An Interactive Environment for Understanding Feature Implementations
iFL: An Interactive Environment for Understanding Feature ImplementationsiFL: An Interactive Environment for Understanding Feature Implementations
iFL: An Interactive Environment for Understanding Feature ImplementationsICSM 2010
 
Using Clone Detection to Identify Bugs in Concurrent Software
Using Clone Detection to Identify Bugs in Concurrent SoftwareUsing Clone Detection to Identify Bugs in Concurrent Software
Using Clone Detection to Identify Bugs in Concurrent SoftwareICSM 2010
 
Physical and Conceptual Identifier Dispersion: Measures and Relation to Fault...
Physical and Conceptual Identifier Dispersion: Measures and Relation to Fault...Physical and Conceptual Identifier Dispersion: Measures and Relation to Fault...
Physical and Conceptual Identifier Dispersion: Measures and Relation to Fault...ICSM 2010
 
Automated Identification of Cross-browser Issues in Web Applications
Automated Identification of Cross-browser Issues in Web ApplicationsAutomated Identification of Cross-browser Issues in Web Applications
Automated Identification of Cross-browser Issues in Web ApplicationsICSM 2010
 
Reverse Engineering Object-Oriented Distributed Systems
Reverse Engineering Object-Oriented Distributed SystemsReverse Engineering Object-Oriented Distributed Systems
Reverse Engineering Object-Oriented Distributed SystemsICSM 2010
 
Software asset management
Software asset managementSoftware asset management
Software asset managementICSM 2010
 
Successfulresearch 100915022614-phpapp01
Successfulresearch 100915022614-phpapp01Successfulresearch 100915022614-phpapp01
Successfulresearch 100915022614-phpapp01ICSM 2010
 
Enabling multi tenancy(An Industrial Experience Report)
Enabling multi tenancy(An Industrial Experience Report)Enabling multi tenancy(An Industrial Experience Report)
Enabling multi tenancy(An Industrial Experience Report)ICSM 2010
 
Ponsini automatic slides
Ponsini automatic slidesPonsini automatic slides
Ponsini automatic slidesICSM 2010
 
Studying the impact of dependency network measures on software quality
Studying the impact of dependency network measures on software quality	Studying the impact of dependency network measures on software quality
Studying the impact of dependency network measures on software quality ICSM 2010
 
Icsm2010 Announcement
Icsm2010 AnnouncementIcsm2010 Announcement
Icsm2010 AnnouncementICSM 2010
 

Mais de ICSM 2010 (15)

A tree kernel based approach for clone detection
A tree kernel based approach for clone detectionA tree kernel based approach for clone detection
A tree kernel based approach for clone detection
 
Scalable Semantic Web-based Source Code Search Infrastructure
Scalable Semantic Web-based Source Code Search InfrastructureScalable Semantic Web-based Source Code Search Infrastructure
Scalable Semantic Web-based Source Code Search Infrastructure
 
2D and 3D Visualizations In Wikidev2.0 M. Fokaefs, D. Serrano, B. Tansey and ...
2D and 3D Visualizations In Wikidev2.0 M. Fokaefs, D. Serrano, B. Tansey and ...2D and 3D Visualizations In Wikidev2.0 M. Fokaefs, D. Serrano, B. Tansey and ...
2D and 3D Visualizations In Wikidev2.0 M. Fokaefs, D. Serrano, B. Tansey and ...
 
Wiki dev nlp
Wiki dev nlpWiki dev nlp
Wiki dev nlp
 
iFL: An Interactive Environment for Understanding Feature Implementations
iFL: An Interactive Environment for Understanding Feature ImplementationsiFL: An Interactive Environment for Understanding Feature Implementations
iFL: An Interactive Environment for Understanding Feature Implementations
 
Using Clone Detection to Identify Bugs in Concurrent Software
Using Clone Detection to Identify Bugs in Concurrent SoftwareUsing Clone Detection to Identify Bugs in Concurrent Software
Using Clone Detection to Identify Bugs in Concurrent Software
 
Physical and Conceptual Identifier Dispersion: Measures and Relation to Fault...
Physical and Conceptual Identifier Dispersion: Measures and Relation to Fault...Physical and Conceptual Identifier Dispersion: Measures and Relation to Fault...
Physical and Conceptual Identifier Dispersion: Measures and Relation to Fault...
 
Automated Identification of Cross-browser Issues in Web Applications
Automated Identification of Cross-browser Issues in Web ApplicationsAutomated Identification of Cross-browser Issues in Web Applications
Automated Identification of Cross-browser Issues in Web Applications
 
Reverse Engineering Object-Oriented Distributed Systems
Reverse Engineering Object-Oriented Distributed SystemsReverse Engineering Object-Oriented Distributed Systems
Reverse Engineering Object-Oriented Distributed Systems
 
Software asset management
Software asset managementSoftware asset management
Software asset management
 
Successfulresearch 100915022614-phpapp01
Successfulresearch 100915022614-phpapp01Successfulresearch 100915022614-phpapp01
Successfulresearch 100915022614-phpapp01
 
Enabling multi tenancy(An Industrial Experience Report)
Enabling multi tenancy(An Industrial Experience Report)Enabling multi tenancy(An Industrial Experience Report)
Enabling multi tenancy(An Industrial Experience Report)
 
Ponsini automatic slides
Ponsini automatic slidesPonsini automatic slides
Ponsini automatic slides
 
Studying the impact of dependency network measures on software quality
Studying the impact of dependency network measures on software quality	Studying the impact of dependency network measures on software quality
Studying the impact of dependency network measures on software quality
 
Icsm2010 Announcement
Icsm2010 AnnouncementIcsm2010 Announcement
Icsm2010 Announcement
 

Automatically Repairing Test Cases for Evolving Method Declarations

  • 1. Automatically RepairingTest Cases for Evolving Method Declarations Mehdi Mirzaaghaei Fabrizio Pastore Mauro Pezzè Università della Svizzera italiana http://swiss-landmarks.ch/panos/Lugano9.jpg
  • 3. public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance }; } Software evolves
  • 4. testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance }; } Software evolves
  • 5. testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance }; } Software evolves
  • 6. public class ..... public class AccountUtil { private double dailyInterestRate = 0.00005; private int interestTerm=365; public double interest(BankAccount account return account.getBalance() *dailyInterestRate*interestTerm; } ... public class AccountFactory { public static BankAccount create( AccountContext ctx, boolean special ){ BankAccount account = new BankAcccount( ctx.amount ); if ( special ){ account.setInterestRate(0.0001); } ... public class ..... testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance }; } Software evolves
  • 7. public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance }; } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.centsValue; } public int getBalance(){ return balance; }; } Original classes are modified
  • 8. public class ..... public class ..... Test cases need maintenance testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance }; } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.centsValue; } public int getBalance(){ return balance; }; } Compilation error: Method deposit(Money) in the type BankAccount is not applicable for the arguments (int)
  • 9. changes in method declarations: 23% changes that impact on compilation
  • 10. changes in method declarations: 23% changes that impact on compilation > 80% in maintenance releases
  • 11. changes in method declarations: 23% changes that impact on compilation > 80% in maintenance releases Automatic Repair to Save Effort
  • 13. [Memon et. al. 2008, Grechanik 2009 ] Repair GUI tests Well suited only for GUI tests AutomaticTest Repair
  • 14. [Memon et. al. 2008, Grechanik 2009 ] Repair GUI tests Repair Oracles [B. Daniel et al 2010] testInterest(){ ... assertEquals( 50, result ); } FAILURE: expected 50, found: 40 assertEquals( 40, result ); Well suited only for GUI tests Focus on oracles only AutomaticTest Repair
  • 15. [Memon et. al. 2008, Grechanik 2009 ] Repair GUI tests Refactoring Techniques [ReBa, Eclipse] Repair Oracles [B. Daniel et al 2010] testInterest(){ ... assertEquals( 50, result ); } FAILURE: expected 50, found: 40 assertEquals( 40, result ); //calculate one year interest result = account.interest(); result = account.interest( 0 ); Well suited only for GUI tests Focus on oracles only Prevent only some compilation errors AutomaticTest Repair
  • 16. TestCareAssistant repairs test case compilation errors • Parameter add • Parameter type change • Return type change • Parameter remove caused by method declaration changes
  • 17. TestCareAssistant repairs test case compilation errors testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals(500, account.getBalance()); • Parameter add • Parameter type change • Return type change • Parameter remove caused by method declaration changes
  • 18. TestCareAssistant repairs test case compilation errors testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals(500, account.getBalance()); Replace: int amount = 500; with: Money amount = new Money(500); account.deposit(amount); • Parameter add • Parameter type change • Return type change • Parameter remove caused by method declaration changes
  • 19. TestCareAssistant repairs test case compilation errors testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals(500, account.getBalance()); testDeposit(){ BankAccount account = new BankAccount(); Money amount = new Money(500); account.deposit(amount); assertEquals(500, account.getBalance()); Replace: int amount = 500; with: Money amount = new Money(500); account.deposit(amount); • Parameter add • Parameter type change • Return type change • Parameter remove caused by method declaration changes
  • 20. TestCareAssistant repairs test case compilation errors testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals(500, account.getBalance()); testDeposit(){ BankAccount account = new BankAccount(); Money amount = new Money(500); account.deposit(amount); assertEquals(500, account.getBalance()); Replace: int amount = 500; with: Money amount = new Money(500); account.deposit(amount); • Parameter add • Parameter type change • Return type change • Parameter remove caused by method declaration changes
  • 21. TestCareAssistant repairs test case compilation errors testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals(500, account.getBalance()); testDeposit(){ BankAccount account = new BankAccount(); Money amount = new Money(500); account.deposit(amount); assertEquals(500, account.getBalance()); Replace: int amount = 500; with: Money amount = new Money(500); account.deposit(amount); • Parameter add • Parameter type change • Return type change • Parameter remove caused by method declaration changes
  • 22. TestCareAssistant repairs test case compilation errors testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals(500, account.getBalance()); testDeposit(){ BankAccount account = new BankAccount(); Money amount = new Money(500); account.deposit(amount); assertEquals(500, account.getBalance()); Replace: int amount = 500; with: Money amount = new Money(500); account.deposit(amount); • Parameter add • Parameter type change • Return type change • Parameter remove caused by method declaration changes
  • 23. Repair parameter type change public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance; } } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.CentsValue; } public int getBalance(){ return balance; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } Version 0 Version 1
  • 24. Which parameter to initialize? public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance; } } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.CentsValue; } public int getBalance(){ return balance; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } Version 0 Version 1
  • 25. Which parameter to initialize? Use code diff to identify the parameter1 public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance; } } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.CentsValue; } public int getBalance(){ return balance; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } Version 0 Version 1
  • 26. How to initialize a complex object? public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance; } } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.centsValue; } public int getBalance(){ return balance; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } Version 0 Version 1
  • 27. How to initialize a complex object? Find first uses of parameter fields inVersion12 public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance; } } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.centsValue; } public int getBalance(){ return balance; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } Version 0 Version 1
  • 28. How to determine fields values? public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance; } } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.centsValue; } public int getBalance(){ return balance; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } Version 0 Version 1
  • 29. How to determine fields values? Diff to identify corresponding variable inVersion 03 public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance; } } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.centsValue; } public int getBalance(){ return balance; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } Version 0 Version 1
  • 30. What was the original value? public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance; } } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.CentsValue; } public int getBalance(){ return balance; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } Version 0 Version 1
  • 31. What was the original value? Analyze the def-use chain of the variable back to the definition in the test4 public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance; } } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.CentsValue; } public int getBalance(){ return balance; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } Version 0 Version 1
  • 32. What was the original value? Analyze the def-use chain of the variable back to the definition in the test4 public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance; } } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.CentsValue; } public int getBalance(){ return balance; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } Version 0 Version 1
  • 33. How can we repair the test? public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance; } } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.centsValue; } public int getBalance(){ return balance; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } Version 0 Version 1
  • 34. How can we repair the test? public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance; } } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.centsValue; } public int getBalance(){ return balance; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } Version 0 Version 1
  • 35. How can we repair the test? Instantiate the new object, use original values to initialize fields5 public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance; } } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.centsValue; } public int getBalance(){ return balance; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } Version 0 Version 1
  • 36. How can we repair the test? Instantiate the new object, use original values to initialize fields5 Replace: int amount = 500; with: Money amount = new Money(500); account.deposit(amount); public class BankAccount { private int balance; public void deposit(int cents){ balance += cents; } public int getBalance(){ return balance; } } public class BankAccount { private int balance; public void deposit(Money money){ balance += money.centsValue; } public int getBalance(){ return balance; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals( 500, account.getBalance()); } Version 0 Version 1
  • 37. To what extentTestCareAssistant can fix test cases automatically?
  • 38. To what extentTestCareAssistant can fix test cases automatically? • Repair 22 test cases of 6 open source systems • Continuum, Geronimo, xml-security, PMD, POI, Shindig • 24 compilation errors caused by different changes • 9 parameter types changed, 8 parameters added, 3 parameters removed, 4 return types changed
  • 39. To what extentTestCareAssistant can fix test cases automatically? Results Total Repaired % Test Cases 22 16 72 Compilation Errors 24 18 75 Values Initialized 36 29 80 • Repair 22 test cases of 6 open source systems • Continuum, Geronimo, xml-security, PMD, POI, Shindig • 24 compilation errors caused by different changes • 9 parameter types changed, 8 parameters added, 3 parameters removed, 4 return types changed
  • 40. To what extentTestCareAssistant can fix test cases automatically? Results Total Repaired % Test Cases 22 16 72 Compilation Errors 24 18 75 Values Initialized 36 29 80 • Repair 22 test cases of 6 open source systems • Continuum, Geronimo, xml-security, PMD, POI, Shindig • 24 compilation errors caused by different changes • 9 parameter types changed, 8 parameters added, 3 parameters removed, 4 return types changed
  • 41. To what extentTestCareAssistant can fix test cases automatically? • Static data flow analysis not always effective • Use of complex data structures, e.g. hash tables • Changes in method logic • Changes in interfaces Results Total Repaired % Test Cases 22 16 72 Compilation Errors 24 18 75
  • 42. Conclusions public class BankAccount { public void deposit(int cents){ balance += cents; } } public class BankAccount { public void deposit(Money money){ balance += money.CentsValue; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals(500, account.getBalance()); testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals(500, account.getBalance());
  • 43. Conclusions public class BankAccount { public void deposit(int cents){ balance += cents; } } public class BankAccount { public void deposit(Money money){ balance += money.CentsValue; } } testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals(500, account.getBalance()); testDeposit(){ BankAccount account = new BankAccount(); Money amount = new Money(500); account.deposit(amount); assertEquals(500, account.getBalance());
  • 44. Conclusions public class BankAccount { public void deposit(int cents){ balance += cents; } } public class BankAccount { public void deposit(Money money){ balance += money.CentsValue; } } Replace: int amount = 500; with: Money amount = new Money(500); account.deposit(amount); testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals(500, account.getBalance()); testDeposit(){ BankAccount account = new BankAccount(); Money amount = new Money(500); account.deposit(amount); assertEquals(500, account.getBalance()); TestCareAssistant
  • 45. Future Work CopticChronology EthiopicChronology Chronology + withUTC() TestCopticUTC(){ .... assertEquals("AM", copticChronology.withUTC() ); }
  • 46. Future Work CopticChronology EthiopicChronology Chronology + withUTC() TestCopticUTC(){ .... assertEquals("AM", copticChronology.withUTC() ); } TestEthiopicUTC(){ .... assertEquals("EE", ethiopicChronology.withUTC() } CopticChronology EthiopicChronology Chronology + withUTC()
  • 47. Future Work CopticChronology EthiopicChronology Chronology + withUTC() TestCopticUTC(){ .... assertEquals("AM", copticChronology.withUTC() ); } TestEthiopicUTC(){ .... assertEquals("EE", ethiopicChronology.withUTC() } CopticChronology EthiopicChronology Chronology + withUTC()
  • 48. Future Work CopticChronology EthiopicChronology Chronology + withUTC() TestCopticUTC(){ .... assertEquals("AM", copticChronology.withUTC() ); } TestEthiopicUTC(){ .... assertEquals("EE", ethiopicChronology.withUTC() } CopticChronology EthiopicChronology Chronology + withUTC() AutomateTest Generation by Identifying and ImplementingTest Adaptation Patterns
  • 49. Questions? public class BankAccount { public void deposit(int cents){ balance += cents; } } public class BankAccount { public void deposit(Money money){ balance += money.CentsValue; } } Replace: int amount = 500; with: Money amount = new Money(500); account.deposit(amount); testDeposit(){ BankAccount account = new BankAccount(); int amount = 500; account.deposit(amount); assertEquals(500, account.getBalance()); testDeposit(){ BankAccount account = new BankAccount(); Money amount = new Money(500); account.deposit(amount); assertEquals(500, account.getBalance()); TestCareAssistant