SlideShare a Scribd company logo
AutoPUT: An Automated Technique for Retrofitting
Closed Unit Tests into Parameterized Unit Tests
Keita Tsukamoto†, Yuta Maezawa†,
Shinichi Honiden‡
April 12, 2018 1
† Udzuki Inc., Japan
‡ Waseda University, Japan
The 33rd ACM/SIGAPP Symposium On Applied Computing
Pau, France
Outline
• Background
– Test Suite Maintenance
– Parameterized Unit Test
• Challenges: Fully Automated Parameterizing
• Approach: AutoPUT
– Detecting CUTs to be Parameterized
– Generating PUTs from detected CUTs
• Evaluation
• Conclusion
April 12, 2018 2
Background – Test Suite Maintenance
April 12, 2018 3
• Test suites are not static entities[1]
– Developers must keep maintaining test suites
• Adding new tests, modifying existing tests, or delete
unnecessary tests
Test suite maintenance is necessary to build reliable software
Old
Test Suite
New
Tests
Developer
add
New
Test Suite
Ex. adding
new tests
Old
Test Suite
Developer
modify
New
Test Suite
Ex. modifying
existing tests
Existing
Tests
Modified
Tests
[1] L. Pinto et al. “Understanding Myths and Realities of Test-Suite Evolution”, FSE 2012
Background – Test Maintainability
April 12, 2018 4
• Developers need to understand purpose of tests[2]
– Good readability helps developers to maintain test suites[3]
– Simplifying tests increases understandability of tests[4]
Test maintainability ≒ Test understandability
Test Suite
maintain
read Developers
New
Test Suite
Understandability ↑
Test Suite
maintain
read Developers
New
Test Suite
Understanding ↑ Understanding ↓
Understandability ↓
[2] E. Daka et al. “Modeling Readability to Improve Unit Tests”, FSE 2015
[3] B. Zhang et al. “Towards Automatically Generating Descriptive Names for Unit Tests”, ASE 2016
[4] Y. Lei et al. “Minimization of Randomized Unit Test Cases”, ISSRE 2005
Background – Parameterized Unit Test (PUT)
April 12, 2018 5
Unit tests allowing parameters•
Enable to separate parameters and procedures–
Less code and independent of concrete parameters•
Easier to understand than closed unit tests (CUTs)[5]
However, PUTs are rare in the real world projects
[5] G. Fraser et al. “Generating Parameterized Unit Tests”, ISSTA 2011
// no parameters -> CUT
@Test public void testAdd1() {
int expected = 3;
int actual = Adder.add(1, 2);
assertEquals(expected, actual);
}
@Test public void testAdd2() {
int expected = 0;
int actual = Adder.add(1, -1);
assertEquals(expected, actual);
}
// PUT
@Theory public void testAdd(int[] params) {
int expected = params[0];
int actual =
Adder.add(params[1], params[2]);
assertEquals(expected, actual);
}
parameterize
Related Work – Parameterized Unit Tests
April 12, 2018 6
• Generating parameters for PUTs by symbolic execution[6]
Not full solution for practicality problem
PUTs
prepare Unit
Meister
input generate
Developers
Parameters
[6] N. Tillman et al. “Parameterized Unit Tests”, FSE 2005
High coverage
• Parameterizing auto-generated CUTs[5]
EvoStuite
generate
CUTs
parameterized
unit tests
input parameterize
PUTs
Less code than CUTs
Retrofitting existing unit tests is more difficult[5]
• Semi-automated retrofitting CUTs into PUTs[7]
CUTs
read
Pex
promote
parameters retrofit
PUTs
Semi
PUTs
input
Developers
[7] S. Thummalapenta et al. “Retrofitting Unit Tests for Parameterized Unit Testing”, FASE 2011
Who
detects?
Challenges – Fully Automated Retrofitting CUTs
April 12, 2018 7
Developers do not have
sufficient resources to retrofit CUTs
2 challenges for fully automated retrofitting existing CUTs
CUTsCUTs
CUTsCUTs
About 25% of unit tests are easy
to be parameterized[8]
Project #CUT #PUT
Codec 643 24
Compress 867 11
Math 4100 1
But...
[8] D. Saff et al. “Theories in practice: Easy-to-write specifications that catch bugs”, MIT CSAIL Technical Report 2008
Fully automated retrofitting can solve practicality problem
Project
Repository
CUTs to be
parameterized
1. detect 2. generate
PUTs
check
Developers Common procedure and different parameters
Approach – Automated Technique
for Retrofitting CUTs into PUTs (AutoPUT)
April 12, 2018 8
• Addressing two challenges
– Detecting CUTs to be parameterized → Detector
– Generating PUTs from detected CUTs → Generator
AutoPUT can help developers maintain test suites
Developers
1. Detector 2. Generator
@Test
Project
Repository
No
AutoPUT
Degraded?
Coverage
Measuring
@Theory
@DataPoints
@Theory
@DataPoints
Approach – Detecting CUTs to be Parameterized
April 12, 2018 9
• Using *AST-based code-clone detection technique
– CUTs to be parameterized = kind of code clones[8]
– Effective detecting by static program analysis
• Ignoring values of literal nodes, and considering names of
identifiers
Accurately detecting in practical amount of time
*AST = Abstract Syntax Tree
add
compare
add
different procedure
@Test
public void testAdd1 () {
int expected = 3;
int actual = Adder.add(2, 1);
assertEquals(expected, actual);
}
@Test
public void testAdd2() {
int expected = 1;
int actual = Adder.add(-1, 2);
assertEquals(expected, actual);
}
@Test
public void testSub1() {
int expected = 1;
int actual = Subber.sub(2, 1);
assertEquals(expected, actual);
}
sub
AST
Approach – Generating PUTs from detected CUTs
April 12, 2018 10
• Extracting parameters from AST of each CUT
– Parameter nodes = literal nodes, or constant value nodes
• Parameter nodes with inconsistent values in all CUTs → parameters
• Replacing parameter nodes with abstract variables
– Judge each parameter is related to expected outputs or not
Automated generating PUTs in practical amount of time
input expected
Related to expected outputs
→ replaced with `expected`
proceduresparameters
abstract variable
node
CUTA
CUTB
Approach – Requirements for Generated PUTs
April 12, 2018 11
• Retrofitting CUTs often induce degradation[7]
Guaranteeing that degradation does not occur
CUTs
retrofit
PUTs
× Compile Error
× Test Failure
× Decrease in Coverage
• Confirming whether degradation does not occur
– If degradation occurs, AutoPUT excludes the PUT
Generated
PUTs
success? decreases?
Original
CUTs
no
Coverage
Measuring
&
Comparison
yes
yes
Compile
&
Test Execution
PUTs
No degradation
Discard Discard
Evaluation - Experimental Setting
• Subjects
April 12, 2018 12
Project # of Class # of Test Class # of Existing CUTs # of Existing PUTs
BCEL 378 63 112 1
Codec 63 56 643 24
Compress 195 127 867 11
CSV 11 19 286 2
Digester 169 103 218 2
FileUpload 839 19 66 8
Math 847 522 4100 1
• Research Questions
1. Can AutoPUT accurately detect CUTs to be
parameterized in a practical amount of time?
2. Can AutoPUT effectively generate PUTs in a
feasible amount of time?
Evaluation - Results and Discussions (RQ1)
April 12, 2018 13
• Results
– SCC[9]: the-state-of-the-art tool for detecting code-clones
AutoPUT scored higher or the same score than SCC
in a practical amount of time
AutoPUT SCC4 SCC5 SCC6
Precision Recall Precision Recall Precision Recall Precision Recall
Avg. Score 72.5% 55.2% 1.3% 61.5% 2.4% 55.2% 3.8% 44.0%
Total Time 9.3 sec. N/A N/A N/A
[9] H. Sajnani et al. “SourcererCC: Scaling code clone detection to big-code.”,ICSE 2016
• Discussions
– Higher precision score than SCC* and the same recall
score as SCC5
– Spent 9.3 sec. for 7 projects → sufficiently practical
Evaluation - Results and Discussions (RQ2)
April 12, 2018 14
• Results
AutoPUT generated 204 PUTs, reducing the
number of statements by 64.0%, in 8.5 hours
# of Generated PUTs # of Converted CUTs Reduction Ratio Time
204 675 64.0% 8.5 hrs
– Reduction ratio[5]: to
– Time: including coverage measuring time
#statements of PUTs #statements of CUT s
• Discussions
– 204 generated PUTs: 95.3% of PUT candidates
• 4.7% inducing degradation: implementation issue (e.g., Enum-typed
parameters)
– 64.0% reduction of statements that developers must maintain
– Spent 8.5 hours for all PUTs → sufficiently feasible (in a day)
Conclusion
April 12, 2018 15
• Background
– PUT: easier to understand than CUT
• Challenge
– Fully automated CUT-PUT retrofitting
• Approach: AutoPUT
– Detecting CUTs with similar structure
– Identifying parameters and generate PUTs
• Experimental Results
– Generated 204 PUTs in 8.5 Hours
AutoPUT can help developers to maintain test suites
Future Work – Extending AutoPUT
April 12, 2018 16
• Investigating meaningfulness of generated PUTs
– Current: Reducing #CUTs
– Future: To be accepted by actual developers
• Retrofitting PUTs to CUTs
– Current: Unkind error messages from PUTs
– Future: To handle software failures easily
• Combining with symbolic execution
– Current: Guaranteeing no degradation
– Future: To achieve higher coverage
Plan to make AutoPUT more practical and applicable

More Related Content

PDF
Control systems Unit-I (Dr.D.Lenine, RGMCET, Nandyal)
PDF
Generating Automated and Online Test Oracles for Simulink Models with Continu...
PDF
Accenture testingchallenge casestudy Cgs test estimates
PPTX
Certified Reasoning for Automated Verification
PPSX
System Test Evaluation and Review Technique
PDF
Mining Assumptions for Software Components using Machine Learning
PPTX
Clogged Arteries: Discrete Event Simulation Reduces Holds for Telemetry Beds
PDF
Adding unit tests to the database deployment pipeline
Control systems Unit-I (Dr.D.Lenine, RGMCET, Nandyal)
Generating Automated and Online Test Oracles for Simulink Models with Continu...
Accenture testingchallenge casestudy Cgs test estimates
Certified Reasoning for Automated Verification
System Test Evaluation and Review Technique
Mining Assumptions for Software Components using Machine Learning
Clogged Arteries: Discrete Event Simulation Reduces Holds for Telemetry Beds
Adding unit tests to the database deployment pipeline

Similar to SAC 2018: "AutoPUT: An Automated Technique for Retrofitting Closed Unit Tests into Parameterized Unit Tests" (7)

PPTX
Next Generation Developer Testing: Parameterized Testing
PPTX
Not Your Mommas Unit Tests - Parameterized Unit Tests
PDF
Unit testing [4] - Software Testing Techniques (CIS640)
PPT
Software Engineering XUnit Testing and Patterns
PDF
May: Automated Developer Testing: Achievements and Challenges
PDF
Capstone-Project-Apply-Automation-Testing.pdf
PPTX
White-box Unit Test Generation with Microsoft IntelliTest
Next Generation Developer Testing: Parameterized Testing
Not Your Mommas Unit Tests - Parameterized Unit Tests
Unit testing [4] - Software Testing Techniques (CIS640)
Software Engineering XUnit Testing and Patterns
May: Automated Developer Testing: Achievements and Challenges
Capstone-Project-Apply-Automation-Testing.pdf
White-box Unit Test Generation with Microsoft IntelliTest
Ad

Recently uploaded (20)

PPTX
Transform Your Business with a Software ERP System
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PDF
Complete Guide to Website Development in Malaysia for SMEs
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Monitoring Stack: Grafana, Loki & Promtail
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
history of c programming in notes for students .pptx
Transform Your Business with a Software ERP System
Computer Software and OS of computer science of grade 11.pptx
Designing Intelligence for the Shop Floor.pdf
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
Complete Guide to Website Development in Malaysia for SMEs
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Operating system designcfffgfgggggggvggggggggg
Wondershare Filmora 15 Crack With Activation Key [2025
Reimagine Home Health with the Power of Agentic AI​
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Digital Systems & Binary Numbers (comprehensive )
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
L1 - Introduction to python Backend.pptx
Monitoring Stack: Grafana, Loki & Promtail
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Patient Appointment Booking in Odoo with online payment
Adobe Illustrator 28.6 Crack My Vision of Vector Design
history of c programming in notes for students .pptx
Ad

SAC 2018: "AutoPUT: An Automated Technique for Retrofitting Closed Unit Tests into Parameterized Unit Tests"

  • 1. AutoPUT: An Automated Technique for Retrofitting Closed Unit Tests into Parameterized Unit Tests Keita Tsukamoto†, Yuta Maezawa†, Shinichi Honiden‡ April 12, 2018 1 † Udzuki Inc., Japan ‡ Waseda University, Japan The 33rd ACM/SIGAPP Symposium On Applied Computing Pau, France
  • 2. Outline • Background – Test Suite Maintenance – Parameterized Unit Test • Challenges: Fully Automated Parameterizing • Approach: AutoPUT – Detecting CUTs to be Parameterized – Generating PUTs from detected CUTs • Evaluation • Conclusion April 12, 2018 2
  • 3. Background – Test Suite Maintenance April 12, 2018 3 • Test suites are not static entities[1] – Developers must keep maintaining test suites • Adding new tests, modifying existing tests, or delete unnecessary tests Test suite maintenance is necessary to build reliable software Old Test Suite New Tests Developer add New Test Suite Ex. adding new tests Old Test Suite Developer modify New Test Suite Ex. modifying existing tests Existing Tests Modified Tests [1] L. Pinto et al. “Understanding Myths and Realities of Test-Suite Evolution”, FSE 2012
  • 4. Background – Test Maintainability April 12, 2018 4 • Developers need to understand purpose of tests[2] – Good readability helps developers to maintain test suites[3] – Simplifying tests increases understandability of tests[4] Test maintainability ≒ Test understandability Test Suite maintain read Developers New Test Suite Understandability ↑ Test Suite maintain read Developers New Test Suite Understanding ↑ Understanding ↓ Understandability ↓ [2] E. Daka et al. “Modeling Readability to Improve Unit Tests”, FSE 2015 [3] B. Zhang et al. “Towards Automatically Generating Descriptive Names for Unit Tests”, ASE 2016 [4] Y. Lei et al. “Minimization of Randomized Unit Test Cases”, ISSRE 2005
  • 5. Background – Parameterized Unit Test (PUT) April 12, 2018 5 Unit tests allowing parameters• Enable to separate parameters and procedures– Less code and independent of concrete parameters• Easier to understand than closed unit tests (CUTs)[5] However, PUTs are rare in the real world projects [5] G. Fraser et al. “Generating Parameterized Unit Tests”, ISSTA 2011 // no parameters -> CUT @Test public void testAdd1() { int expected = 3; int actual = Adder.add(1, 2); assertEquals(expected, actual); } @Test public void testAdd2() { int expected = 0; int actual = Adder.add(1, -1); assertEquals(expected, actual); } // PUT @Theory public void testAdd(int[] params) { int expected = params[0]; int actual = Adder.add(params[1], params[2]); assertEquals(expected, actual); } parameterize
  • 6. Related Work – Parameterized Unit Tests April 12, 2018 6 • Generating parameters for PUTs by symbolic execution[6] Not full solution for practicality problem PUTs prepare Unit Meister input generate Developers Parameters [6] N. Tillman et al. “Parameterized Unit Tests”, FSE 2005 High coverage • Parameterizing auto-generated CUTs[5] EvoStuite generate CUTs parameterized unit tests input parameterize PUTs Less code than CUTs Retrofitting existing unit tests is more difficult[5] • Semi-automated retrofitting CUTs into PUTs[7] CUTs read Pex promote parameters retrofit PUTs Semi PUTs input Developers [7] S. Thummalapenta et al. “Retrofitting Unit Tests for Parameterized Unit Testing”, FASE 2011 Who detects?
  • 7. Challenges – Fully Automated Retrofitting CUTs April 12, 2018 7 Developers do not have sufficient resources to retrofit CUTs 2 challenges for fully automated retrofitting existing CUTs CUTsCUTs CUTsCUTs About 25% of unit tests are easy to be parameterized[8] Project #CUT #PUT Codec 643 24 Compress 867 11 Math 4100 1 But... [8] D. Saff et al. “Theories in practice: Easy-to-write specifications that catch bugs”, MIT CSAIL Technical Report 2008 Fully automated retrofitting can solve practicality problem Project Repository CUTs to be parameterized 1. detect 2. generate PUTs check Developers Common procedure and different parameters
  • 8. Approach – Automated Technique for Retrofitting CUTs into PUTs (AutoPUT) April 12, 2018 8 • Addressing two challenges – Detecting CUTs to be parameterized → Detector – Generating PUTs from detected CUTs → Generator AutoPUT can help developers maintain test suites Developers 1. Detector 2. Generator @Test Project Repository No AutoPUT Degraded? Coverage Measuring @Theory @DataPoints @Theory @DataPoints
  • 9. Approach – Detecting CUTs to be Parameterized April 12, 2018 9 • Using *AST-based code-clone detection technique – CUTs to be parameterized = kind of code clones[8] – Effective detecting by static program analysis • Ignoring values of literal nodes, and considering names of identifiers Accurately detecting in practical amount of time *AST = Abstract Syntax Tree add compare add different procedure @Test public void testAdd1 () { int expected = 3; int actual = Adder.add(2, 1); assertEquals(expected, actual); } @Test public void testAdd2() { int expected = 1; int actual = Adder.add(-1, 2); assertEquals(expected, actual); } @Test public void testSub1() { int expected = 1; int actual = Subber.sub(2, 1); assertEquals(expected, actual); } sub AST
  • 10. Approach – Generating PUTs from detected CUTs April 12, 2018 10 • Extracting parameters from AST of each CUT – Parameter nodes = literal nodes, or constant value nodes • Parameter nodes with inconsistent values in all CUTs → parameters • Replacing parameter nodes with abstract variables – Judge each parameter is related to expected outputs or not Automated generating PUTs in practical amount of time input expected Related to expected outputs → replaced with `expected` proceduresparameters abstract variable node CUTA CUTB
  • 11. Approach – Requirements for Generated PUTs April 12, 2018 11 • Retrofitting CUTs often induce degradation[7] Guaranteeing that degradation does not occur CUTs retrofit PUTs × Compile Error × Test Failure × Decrease in Coverage • Confirming whether degradation does not occur – If degradation occurs, AutoPUT excludes the PUT Generated PUTs success? decreases? Original CUTs no Coverage Measuring & Comparison yes yes Compile & Test Execution PUTs No degradation Discard Discard
  • 12. Evaluation - Experimental Setting • Subjects April 12, 2018 12 Project # of Class # of Test Class # of Existing CUTs # of Existing PUTs BCEL 378 63 112 1 Codec 63 56 643 24 Compress 195 127 867 11 CSV 11 19 286 2 Digester 169 103 218 2 FileUpload 839 19 66 8 Math 847 522 4100 1 • Research Questions 1. Can AutoPUT accurately detect CUTs to be parameterized in a practical amount of time? 2. Can AutoPUT effectively generate PUTs in a feasible amount of time?
  • 13. Evaluation - Results and Discussions (RQ1) April 12, 2018 13 • Results – SCC[9]: the-state-of-the-art tool for detecting code-clones AutoPUT scored higher or the same score than SCC in a practical amount of time AutoPUT SCC4 SCC5 SCC6 Precision Recall Precision Recall Precision Recall Precision Recall Avg. Score 72.5% 55.2% 1.3% 61.5% 2.4% 55.2% 3.8% 44.0% Total Time 9.3 sec. N/A N/A N/A [9] H. Sajnani et al. “SourcererCC: Scaling code clone detection to big-code.”,ICSE 2016 • Discussions – Higher precision score than SCC* and the same recall score as SCC5 – Spent 9.3 sec. for 7 projects → sufficiently practical
  • 14. Evaluation - Results and Discussions (RQ2) April 12, 2018 14 • Results AutoPUT generated 204 PUTs, reducing the number of statements by 64.0%, in 8.5 hours # of Generated PUTs # of Converted CUTs Reduction Ratio Time 204 675 64.0% 8.5 hrs – Reduction ratio[5]: to – Time: including coverage measuring time #statements of PUTs #statements of CUT s • Discussions – 204 generated PUTs: 95.3% of PUT candidates • 4.7% inducing degradation: implementation issue (e.g., Enum-typed parameters) – 64.0% reduction of statements that developers must maintain – Spent 8.5 hours for all PUTs → sufficiently feasible (in a day)
  • 15. Conclusion April 12, 2018 15 • Background – PUT: easier to understand than CUT • Challenge – Fully automated CUT-PUT retrofitting • Approach: AutoPUT – Detecting CUTs with similar structure – Identifying parameters and generate PUTs • Experimental Results – Generated 204 PUTs in 8.5 Hours AutoPUT can help developers to maintain test suites
  • 16. Future Work – Extending AutoPUT April 12, 2018 16 • Investigating meaningfulness of generated PUTs – Current: Reducing #CUTs – Future: To be accepted by actual developers • Retrofitting PUTs to CUTs – Current: Unkind error messages from PUTs – Future: To handle software failures easily • Combining with symbolic execution – Current: Guaranteeing no degradation – Future: To achieve higher coverage Plan to make AutoPUT more practical and applicable