SlideShare une entreprise Scribd logo
1  sur  24
IME-USP

What Do the
Asserts in a Unit
Test Tell us About
Code Quality?
Mauricio Aniche
Gustavo Oliva
Marco Gerosa

University of São Paulo (USP)
Unit Tests and Code Quality
 Great  synergy between a testable class
  and a well-designed class (Feathers, 2012)
 The write of unit tests can become
  complex as the interactions between
  software components grow out of control
  (McGregor, 2001)
 Agile practitioners state that unit tests are
  a way to validate and improve class
  design (Beck et al, 2001)
Unit Tests and Asserts
 Every    unit test contains three parts
     Set up the scenario
     Invoke the behavior under test
     Validates the expected output
 Assert   instructions
     assertEquals (expected, calculated);
     assertTrue(), assertFalse(), and so on
 No   limits for the number of asserts per test
A little piece of code
class InvoiceTest {
  @Test
  public void shouldCalculateTaxes() {
    // (i) setting up the scenario
    Invoice inv = new Invoice(5000.0);

        // (ii) invoking the behavior
        double tax = inv.calculateTaxes();

        // (iii) validating the output
        assertEquals (5000 ∗ 0.06 , tax );
    }
}
Why would…
…     a test contain more than one assert?
 Is it a smell of bad code/design?
Research Design
 We    selected 22 projects
     19 from ASF
     3 from a Brazilian consultancy
 Data   extraction from all projects
     Code metrics
 Statistical
            Test
 Qualitative Analysis
Hypotheses
   H1: Code tested by only one assert does not
    present lower cyclomatic complexity than
    code tested by more than one assert
   H2: Code tested by only one assert does not
    present fewer lines of code than code tested
    by more than one assert
   H3: Code tested by only one assert does not
    present lower quantity of method invocations
    than code tested by more than one assert
Data Extraction
 Test   code
     Number of asserts per test
     Production method being tested
 Production    code
     Cyclomatic Complexity (McCabe, 1976)
     Number of method invocations (Li and
      Henry, 1993)
     Lines of Code
Heuristic to Extract the
        Production Method
class InvoiceTest {                          class Invoice {
  @Test                                        public double calculateTaxes()
                                               {
  public void shouldCalculateTaxes() {
                                                 // something…
    // (i) setting up the scenario
                                               }
    Invoice inv = new Invoice(5000.0);
                                             }

        // (ii) invoking the behavior
        double tax = inv.calculateTaxes();

        // (iii) validating the output
        assertEquals (5000 ∗ 0.06 , tax );
    }
}
Selected Projects
 Pre-selected all 213 projects from Apache
 Eliminated those because of:
    Minimum test ratio (unit tests / production
     methods >= 0.2)
    Success in production method detection
     algorithm (higher than 50% in all unit tests
     that contain more than 1 assert)
Selected
Projects
Asserts
Distribution
in Selected
Projects
Statistical Test
 Separation   in two different groups
    The same method can appear in both
     groups
    No duplicates
 Wilcoxon   Signed-Rank Test
Results of
the Test
Why more than 1 assert?
 130tests randomly selected
 Qualitative analysis:
    More than one assert for the same object
     (40.4%)
    Different inputs to the same method (38.9%)
    List/Array (9.9%)
    Others (6.8%)
    Extra assert to check if object is not null (3.8%)
“Asserted Objects”
 We   coined the term “asserted objects”
    It counts not the number of asserts in a unit
     test, but the number of different instances
     of objects that are being asserted

     assertEquals(10, obj.getA());
     assertEquals(20, obj.getB());
        Counts as 1 “asserted object”
Distribution of
Asserted
Objects
Results of
the Test
Summary of the Tests
Findings
   Counting the number of asserts in a unit test
    does not give valuable feedback about
    code quality
       But counting the number of asserted objects
        may provide useful information
       However, the difference between both groups
        was not “big”
   A possible explanation:
       Methods that contain higher CC, lines of code,
        and method invocations contains many
        different paths, and developers prefer to write
        all of it in a single unit test, rather than splitting in
        many of them
Threats to Validity
 Many   unit tests variations that are not
  supported by our tool
 The production method detection
  algorithm
 Before/After methods
 The projects’ filtering process
 Integration and system tests
Related Work
 Mostsimilar to our work: Bruntink and van
 Deursen (2006).
    Significant correlation between class
     metrics (fan out, size of a class, response for
     a class) and test metrics (size of the class,
     number of asserts).
Conclusions
 The
    number of asserts does not tell us
 anything about the production code
 quality
    But the number of asserted objects does.
    “More than one asserted object per test”
     smell
 Theneed of replicating the study with a
 larger amount of industry projects
Contact Information
   Mauricio Aniche
    aniche@ime.usp.br / @mauricioaniche
   Gustavo Oliva
    goliva@ime.usp.br / @golivax
   Marco Gerosa
    gerosa@ime.usp.br

Software Engineering & Collaborative Systems
           Research Lab (LAPESSC)
          http://lapessc.ime.usp.br/

Contenu connexe

Tendances

Search-Based Robustness Testing of Data Processing Systems
Search-Based Robustness Testing of Data Processing SystemsSearch-Based Robustness Testing of Data Processing Systems
Search-Based Robustness Testing of Data Processing SystemsLionel Briand
 
Boundary and equivalnce systematic test design
Boundary and equivalnce   systematic test designBoundary and equivalnce   systematic test design
Boundary and equivalnce systematic test designIan McDonald
 
Whitebox testing
Whitebox testingWhitebox testing
Whitebox testingOana Feidi
 
Incremental Reconfiguration of Product Specific Use Case Models for Evolving ...
Incremental Reconfiguration of Product Specific Use Case Models for Evolving ...Incremental Reconfiguration of Product Specific Use Case Models for Evolving ...
Incremental Reconfiguration of Product Specific Use Case Models for Evolving ...Lionel Briand
 
Fundamental Test Design Techniques
Fundamental Test Design TechniquesFundamental Test Design Techniques
Fundamental Test Design TechniquesTechWell
 
White Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhWhite Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhPankaj Thakur
 
Fabrizio pastore TORACLE-2021 @ESEC/FSE 2021
Fabrizio pastore TORACLE-2021 @ESEC/FSE 2021Fabrizio pastore TORACLE-2021 @ESEC/FSE 2021
Fabrizio pastore TORACLE-2021 @ESEC/FSE 2021fabriziopastore
 
Software Quality Testing
Software Quality TestingSoftware Quality Testing
Software Quality TestingKiran Kumar
 
Mining Assumptions for Software Components using Machine Learning
Mining Assumptions for Software Components using Machine LearningMining Assumptions for Software Components using Machine Learning
Mining Assumptions for Software Components using Machine LearningLionel Briand
 
White Box Testing
White Box TestingWhite Box Testing
White Box TestingAlisha Roy
 
Improving Fault Localization for Simulink Models using Search-Based Testing a...
Improving Fault Localization for Simulink Models using Search-Based Testing a...Improving Fault Localization for Simulink Models using Search-Based Testing a...
Improving Fault Localization for Simulink Models using Search-Based Testing a...Lionel Briand
 
Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...
Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...
Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...fabriziopastore
 
Automated Test Suite Generation for Time-Continuous Simulink Models
Automated Test Suite Generation for Time-Continuous Simulink ModelsAutomated Test Suite Generation for Time-Continuous Simulink Models
Automated Test Suite Generation for Time-Continuous Simulink ModelsLionel Briand
 
White Box Testing (Introduction to)
White Box Testing (Introduction to)White Box Testing (Introduction to)
White Box Testing (Introduction to)Henry Muccini
 
System Testing of Timing Requirements based on Use Cases and Timed Automata
System Testing of Timing Requirements based on Use Cases and Timed AutomataSystem Testing of Timing Requirements based on Use Cases and Timed Automata
System Testing of Timing Requirements based on Use Cases and Timed AutomataLionel Briand
 
Can we predict the quality of spectrum-based fault localization?
Can we predict the quality of spectrum-based fault localization?Can we predict the quality of spectrum-based fault localization?
Can we predict the quality of spectrum-based fault localization?Lionel Briand
 

Tendances (20)

Search-Based Robustness Testing of Data Processing Systems
Search-Based Robustness Testing of Data Processing SystemsSearch-Based Robustness Testing of Data Processing Systems
Search-Based Robustness Testing of Data Processing Systems
 
Boundary and equivalnce systematic test design
Boundary and equivalnce   systematic test designBoundary and equivalnce   systematic test design
Boundary and equivalnce systematic test design
 
Whitebox testing
Whitebox testingWhitebox testing
Whitebox testing
 
Incremental Reconfiguration of Product Specific Use Case Models for Evolving ...
Incremental Reconfiguration of Product Specific Use Case Models for Evolving ...Incremental Reconfiguration of Product Specific Use Case Models for Evolving ...
Incremental Reconfiguration of Product Specific Use Case Models for Evolving ...
 
Fundamental Test Design Techniques
Fundamental Test Design TechniquesFundamental Test Design Techniques
Fundamental Test Design Techniques
 
White Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhWhite Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR Chandigarh
 
Fabrizio pastore TORACLE-2021 @ESEC/FSE 2021
Fabrizio pastore TORACLE-2021 @ESEC/FSE 2021Fabrizio pastore TORACLE-2021 @ESEC/FSE 2021
Fabrizio pastore TORACLE-2021 @ESEC/FSE 2021
 
Black Box Testing
Black Box TestingBlack Box Testing
Black Box Testing
 
Software Quality Testing
Software Quality TestingSoftware Quality Testing
Software Quality Testing
 
Mining Assumptions for Software Components using Machine Learning
Mining Assumptions for Software Components using Machine LearningMining Assumptions for Software Components using Machine Learning
Mining Assumptions for Software Components using Machine Learning
 
White Box Testing
White Box TestingWhite Box Testing
White Box Testing
 
Improving Fault Localization for Simulink Models using Search-Based Testing a...
Improving Fault Localization for Simulink Models using Search-Based Testing a...Improving Fault Localization for Simulink Models using Search-Based Testing a...
Improving Fault Localization for Simulink Models using Search-Based Testing a...
 
Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...
Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...
Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...
 
Automated Test Suite Generation for Time-Continuous Simulink Models
Automated Test Suite Generation for Time-Continuous Simulink ModelsAutomated Test Suite Generation for Time-Continuous Simulink Models
Automated Test Suite Generation for Time-Continuous Simulink Models
 
11 whiteboxtesting
11 whiteboxtesting11 whiteboxtesting
11 whiteboxtesting
 
White box testing
White box testingWhite box testing
White box testing
 
White Box Testing (Introduction to)
White Box Testing (Introduction to)White Box Testing (Introduction to)
White Box Testing (Introduction to)
 
Intake 38 5 1
Intake 38 5 1Intake 38 5 1
Intake 38 5 1
 
System Testing of Timing Requirements based on Use Cases and Timed Automata
System Testing of Timing Requirements based on Use Cases and Timed AutomataSystem Testing of Timing Requirements based on Use Cases and Timed Automata
System Testing of Timing Requirements based on Use Cases and Timed Automata
 
Can we predict the quality of spectrum-based fault localization?
Can we predict the quality of spectrum-based fault localization?Can we predict the quality of spectrum-based fault localization?
Can we predict the quality of spectrum-based fault localization?
 

En vedette

A Validated Set of Smells for MVC Architectures - ICSME 2016
A Validated Set of Smells for MVC Architectures - ICSME 2016A Validated Set of Smells for MVC Architectures - ICSME 2016
A Validated Set of Smells for MVC Architectures - ICSME 2016Maurício Aniche
 
Обсуждаем мягкие (ПО) тенденции на секции №9 на конгрессе "Подмосковные вечер...
Обсуждаем мягкие (ПО) тенденции на секции №9 на конгрессе "Подмосковные вечер...Обсуждаем мягкие (ПО) тенденции на секции №9 на конгрессе "Подмосковные вечер...
Обсуждаем мягкие (ПО) тенденции на секции №9 на конгрессе "Подмосковные вечер...Michael Kozloff
 
36. Methods of Production
36. Methods of Production36. Methods of Production
36. Methods of ProductionNBHS
 
Comunica city demo
Comunica city demoComunica city demo
Comunica city demoComunicaCity
 
Selling Approaches Athena Info Consulting
Selling Approaches  Athena Info ConsultingSelling Approaches  Athena Info Consulting
Selling Approaches Athena Info ConsultingNasscom Chennai
 
Guidelines For Glucose Monitoring And Treatment Of Hypoglycemia In Breastfed ...
Guidelines For Glucose Monitoring And Treatment Of Hypoglycemia In Breastfed ...Guidelines For Glucose Monitoring And Treatment Of Hypoglycemia In Breastfed ...
Guidelines For Glucose Monitoring And Treatment Of Hypoglycemia In Breastfed ...Biblioteca Virtual
 
Forever Flowing Ch1.3
Forever Flowing Ch1.3Forever Flowing Ch1.3
Forever Flowing Ch1.3Geminiasp
 
Forever Flowing: Oliver Interlude
Forever Flowing: Oliver InterludeForever Flowing: Oliver Interlude
Forever Flowing: Oliver InterludeGeminiasp
 
Forever Flowing: Simself Interlude
Forever Flowing: Simself InterludeForever Flowing: Simself Interlude
Forever Flowing: Simself InterludeGeminiasp
 
Убьют ли Облака традиционную ВидеоКонференцСвязь (ВКС)?
Убьют ли Облака традиционную ВидеоКонференцСвязь (ВКС)?Убьют ли Облака традиционную ВидеоКонференцСвязь (ВКС)?
Убьют ли Облака традиционную ВидеоКонференцСвязь (ВКС)?Michael Kozloff
 
Lithium - National Instruments Webcast - Social Support Maturity - August, 2012
Lithium - National Instruments Webcast - Social Support Maturity - August, 2012Lithium - National Instruments Webcast - Social Support Maturity - August, 2012
Lithium - National Instruments Webcast - Social Support Maturity - August, 2012Lithium
 
Innovation Webinar Boost your business with enterprise apps
Innovation Webinar  Boost your business with enterprise appsInnovation Webinar  Boost your business with enterprise apps
Innovation Webinar Boost your business with enterprise appsIFS
 
Forever Flowing: The Azure Legacy 3.7
Forever Flowing: The Azure Legacy 3.7Forever Flowing: The Azure Legacy 3.7
Forever Flowing: The Azure Legacy 3.7Geminiasp
 
Бизнес-кейс: методы оценки возврата на инвестиции в технологии виртуальных ПК
Бизнес-кейс: методы оценки возврата на инвестиции в технологии виртуальных ПКБизнес-кейс: методы оценки возврата на инвестиции в технологии виртуальных ПК
Бизнес-кейс: методы оценки возврата на инвестиции в технологии виртуальных ПКMichael Kozloff
 
Agustin Rodriguez About Me
Agustin Rodriguez About MeAgustin Rodriguez About Me
Agustin Rodriguez About Merominacheme
 
My Last Resume 2014
My Last Resume 2014My Last Resume 2014
My Last Resume 2014Maya Rusli
 
Enoxaparin
EnoxaparinEnoxaparin
EnoxaparinHyunsuk
 
RMKR Overview For Linked In June 2009
RMKR Overview For Linked In June 2009RMKR Overview For Linked In June 2009
RMKR Overview For Linked In June 2009Michael Silton
 

En vedette (20)

A Validated Set of Smells for MVC Architectures - ICSME 2016
A Validated Set of Smells for MVC Architectures - ICSME 2016A Validated Set of Smells for MVC Architectures - ICSME 2016
A Validated Set of Smells for MVC Architectures - ICSME 2016
 
Обсуждаем мягкие (ПО) тенденции на секции №9 на конгрессе "Подмосковные вечер...
Обсуждаем мягкие (ПО) тенденции на секции №9 на конгрессе "Подмосковные вечер...Обсуждаем мягкие (ПО) тенденции на секции №9 на конгрессе "Подмосковные вечер...
Обсуждаем мягкие (ПО) тенденции на секции №9 на конгрессе "Подмосковные вечер...
 
36. Methods of Production
36. Methods of Production36. Methods of Production
36. Methods of Production
 
Comunica city demo
Comunica city demoComunica city demo
Comunica city demo
 
Selling Approaches Athena Info Consulting
Selling Approaches  Athena Info ConsultingSelling Approaches  Athena Info Consulting
Selling Approaches Athena Info Consulting
 
Guidelines For Glucose Monitoring And Treatment Of Hypoglycemia In Breastfed ...
Guidelines For Glucose Monitoring And Treatment Of Hypoglycemia In Breastfed ...Guidelines For Glucose Monitoring And Treatment Of Hypoglycemia In Breastfed ...
Guidelines For Glucose Monitoring And Treatment Of Hypoglycemia In Breastfed ...
 
Forever Flowing Ch1.3
Forever Flowing Ch1.3Forever Flowing Ch1.3
Forever Flowing Ch1.3
 
Forever Flowing: Oliver Interlude
Forever Flowing: Oliver InterludeForever Flowing: Oliver Interlude
Forever Flowing: Oliver Interlude
 
Forever Flowing: Simself Interlude
Forever Flowing: Simself InterludeForever Flowing: Simself Interlude
Forever Flowing: Simself Interlude
 
dada
dadadada
dada
 
Убьют ли Облака традиционную ВидеоКонференцСвязь (ВКС)?
Убьют ли Облака традиционную ВидеоКонференцСвязь (ВКС)?Убьют ли Облака традиционную ВидеоКонференцСвязь (ВКС)?
Убьют ли Облака традиционную ВидеоКонференцСвязь (ВКС)?
 
Lithium - National Instruments Webcast - Social Support Maturity - August, 2012
Lithium - National Instruments Webcast - Social Support Maturity - August, 2012Lithium - National Instruments Webcast - Social Support Maturity - August, 2012
Lithium - National Instruments Webcast - Social Support Maturity - August, 2012
 
Innovation Webinar Boost your business with enterprise apps
Innovation Webinar  Boost your business with enterprise appsInnovation Webinar  Boost your business with enterprise apps
Innovation Webinar Boost your business with enterprise apps
 
Forever Flowing: The Azure Legacy 3.7
Forever Flowing: The Azure Legacy 3.7Forever Flowing: The Azure Legacy 3.7
Forever Flowing: The Azure Legacy 3.7
 
Бизнес-кейс: методы оценки возврата на инвестиции в технологии виртуальных ПК
Бизнес-кейс: методы оценки возврата на инвестиции в технологии виртуальных ПКБизнес-кейс: методы оценки возврата на инвестиции в технологии виртуальных ПК
Бизнес-кейс: методы оценки возврата на инвестиции в технологии виртуальных ПК
 
Historia Social De Mexico
Historia Social De MexicoHistoria Social De Mexico
Historia Social De Mexico
 
Agustin Rodriguez About Me
Agustin Rodriguez About MeAgustin Rodriguez About Me
Agustin Rodriguez About Me
 
My Last Resume 2014
My Last Resume 2014My Last Resume 2014
My Last Resume 2014
 
Enoxaparin
EnoxaparinEnoxaparin
Enoxaparin
 
RMKR Overview For Linked In June 2009
RMKR Overview For Linked In June 2009RMKR Overview For Linked In June 2009
RMKR Overview For Linked In June 2009
 

Similaire à What Do the Asserts in a Unit Test Tell Us About Code Quality? (CSMR2013)

Advances in Unit Testing: Theory and Practice
Advances in Unit Testing: Theory and PracticeAdvances in Unit Testing: Theory and Practice
Advances in Unit Testing: Theory and PracticeTao Xie
 
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...acijjournal
 
5.Black Box Testing and Levels of Testing.ppt
5.Black Box Testing and Levels of Testing.ppt5.Black Box Testing and Levels of Testing.ppt
5.Black Box Testing and Levels of Testing.pptSyedAhmad732853
 
Software testing: an introduction - 2017
Software testing: an introduction - 2017Software testing: an introduction - 2017
Software testing: an introduction - 2017XavierDevroey
 
Coding and testing In Software Engineering
Coding and testing In Software EngineeringCoding and testing In Software Engineering
Coding and testing In Software EngineeringSatya Bhushan Verma
 
30 February 2005 QUEUE rants [email protected] DARNEDTestin.docx
30  February 2005  QUEUE rants [email protected] DARNEDTestin.docx30  February 2005  QUEUE rants [email protected] DARNEDTestin.docx
30 February 2005 QUEUE rants [email protected] DARNEDTestin.docxtamicawaysmith
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)Amr E. Mohamed
 
Testing survey by_directions
Testing survey by_directionsTesting survey by_directions
Testing survey by_directionsTao He
 
12 functional-system-testing
12 functional-system-testing12 functional-system-testing
12 functional-system-testingnickynicks76
 
Unit Test Virtualization: Optimizing Testing Time
Unit Test Virtualization: Optimizing Testing TimeUnit Test Virtualization: Optimizing Testing Time
Unit Test Virtualization: Optimizing Testing Timejon_bell
 
Dynamic analysis in Software Testing
Dynamic analysis in Software TestingDynamic analysis in Software Testing
Dynamic analysis in Software TestingSagar Pednekar
 
Assessing Unit Test Quality
Assessing Unit Test QualityAssessing Unit Test Quality
Assessing Unit Test Qualityguest268ee8
 

Similaire à What Do the Asserts in a Unit Test Tell Us About Code Quality? (CSMR2013) (20)

SWE-6 TESTING.pptx
SWE-6 TESTING.pptxSWE-6 TESTING.pptx
SWE-6 TESTING.pptx
 
Unit testing with JUnit
Unit testing with JUnitUnit testing with JUnit
Unit testing with JUnit
 
Advances in Unit Testing: Theory and Practice
Advances in Unit Testing: Theory and PracticeAdvances in Unit Testing: Theory and Practice
Advances in Unit Testing: Theory and Practice
 
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
 
Unit testing - A&BP CC
Unit testing - A&BP CCUnit testing - A&BP CC
Unit testing - A&BP CC
 
5.Black Box Testing and Levels of Testing.ppt
5.Black Box Testing and Levels of Testing.ppt5.Black Box Testing and Levels of Testing.ppt
5.Black Box Testing and Levels of Testing.ppt
 
Software testing: an introduction - 2017
Software testing: an introduction - 2017Software testing: an introduction - 2017
Software testing: an introduction - 2017
 
Unit tests and TDD
Unit tests and TDDUnit tests and TDD
Unit tests and TDD
 
Unit test
Unit testUnit test
Unit test
 
Coding and testing In Software Engineering
Coding and testing In Software EngineeringCoding and testing In Software Engineering
Coding and testing In Software Engineering
 
30 February 2005 QUEUE rants [email protected] DARNEDTestin.docx
30  February 2005  QUEUE rants [email protected] DARNEDTestin.docx30  February 2005  QUEUE rants [email protected] DARNEDTestin.docx
30 February 2005 QUEUE rants [email protected] DARNEDTestin.docx
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
 
Testing survey by_directions
Testing survey by_directionsTesting survey by_directions
Testing survey by_directions
 
12 functional-system-testing
12 functional-system-testing12 functional-system-testing
12 functional-system-testing
 
Workshop unit test
Workshop   unit testWorkshop   unit test
Workshop unit test
 
Testing
TestingTesting
Testing
 
Unit Test Virtualization: Optimizing Testing Time
Unit Test Virtualization: Optimizing Testing TimeUnit Test Virtualization: Optimizing Testing Time
Unit Test Virtualization: Optimizing Testing Time
 
Dynamic analysis in Software Testing
Dynamic analysis in Software TestingDynamic analysis in Software Testing
Dynamic analysis in Software Testing
 
Assessing Unit Test Quality
Assessing Unit Test QualityAssessing Unit Test Quality
Assessing Unit Test Quality
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 

Plus de Maurício Aniche

Can ML help software developers? (TEQnation 2022)
Can ML help software developers? (TEQnation 2022)Can ML help software developers? (TEQnation 2022)
Can ML help software developers? (TEQnation 2022)Maurício Aniche
 
Tracing Back Log Data to its Log Statement: From Research to Practice
Tracing Back Log Data to its Log Statement: From Research to PracticeTracing Back Log Data to its Log Statement: From Research to Practice
Tracing Back Log Data to its Log Statement: From Research to PracticeMaurício Aniche
 
Pragmatic software testing education - SIGCSE 2019
Pragmatic software testing education - SIGCSE 2019Pragmatic software testing education - SIGCSE 2019
Pragmatic software testing education - SIGCSE 2019Maurício Aniche
 
Software Testing with Caipirinhas and Stroopwafels
Software Testing with Caipirinhas and StroopwafelsSoftware Testing with Caipirinhas and Stroopwafels
Software Testing with Caipirinhas and StroopwafelsMaurício Aniche
 
Code smells in MVC applications (Dutch Spring meetup)
Code smells in MVC applications (Dutch Spring meetup)Code smells in MVC applications (Dutch Spring meetup)
Code smells in MVC applications (Dutch Spring meetup)Maurício Aniche
 
A Collaborative Approach to Teach Software Architecture - SIGCSE 2017
A Collaborative Approach to Teach Software Architecture - SIGCSE 2017A Collaborative Approach to Teach Software Architecture - SIGCSE 2017
A Collaborative Approach to Teach Software Architecture - SIGCSE 2017Maurício Aniche
 
Code quality in MVC systems - BENEVOL 2016
Code quality in MVC systems - BENEVOL 2016Code quality in MVC systems - BENEVOL 2016
Code quality in MVC systems - BENEVOL 2016Maurício Aniche
 
SATT: Tailoring Code Metric Thresholds for Different Software Architectures (...
SATT: Tailoring Code Metric Thresholds for Different Software Architectures (...SATT: Tailoring Code Metric Thresholds for Different Software Architectures (...
SATT: Tailoring Code Metric Thresholds for Different Software Architectures (...Maurício Aniche
 
DNAD 2015 - Métricas de código, pra que te quero?
DNAD 2015 - Métricas de código, pra que te quero?DNAD 2015 - Métricas de código, pra que te quero?
DNAD 2015 - Métricas de código, pra que te quero?Maurício Aniche
 
Como eu aprendi que testar software é importante?
Como eu aprendi que testar software é importante?Como eu aprendi que testar software é importante?
Como eu aprendi que testar software é importante?Maurício Aniche
 
Proposta: Métricas e Heurísticas para Detecção de Problemas em Aplicações Web
Proposta: Métricas e Heurísticas para Detecção de Problemas em Aplicações WebProposta: Métricas e Heurísticas para Detecção de Problemas em Aplicações Web
Proposta: Métricas e Heurísticas para Detecção de Problemas em Aplicações WebMaurício Aniche
 
Efeitos da Prática de Revisão de Código na Caelum: Um Estudo Preliminar em Du...
Efeitos da Prática de Revisão de Código na Caelum: Um Estudo Preliminar em Du...Efeitos da Prática de Revisão de Código na Caelum: Um Estudo Preliminar em Du...
Efeitos da Prática de Revisão de Código na Caelum: Um Estudo Preliminar em Du...Maurício Aniche
 
Test-Driven Development serve pra mim?
Test-Driven Development serve pra mim?Test-Driven Development serve pra mim?
Test-Driven Development serve pra mim?Maurício Aniche
 
O que estamos temos feito com mineração de repositório de código no IME?
O que estamos temos feito com mineração de repositório de código no IME?O que estamos temos feito com mineração de repositório de código no IME?
O que estamos temos feito com mineração de repositório de código no IME?Maurício Aniche
 
MetricMiner: Supporting Researchers in Mining Software Repositories - SCAM 2013
MetricMiner: Supporting Researchers in Mining Software Repositories - SCAM 2013MetricMiner: Supporting Researchers in Mining Software Repositories - SCAM 2013
MetricMiner: Supporting Researchers in Mining Software Repositories - SCAM 2013Maurício Aniche
 
Does the Act of Refactoring Really Make Code Simpler? A Preliminary Study - W...
Does the Act of Refactoring Really Make Code Simpler? A Preliminary Study - W...Does the Act of Refactoring Really Make Code Simpler? A Preliminary Study - W...
Does the Act of Refactoring Really Make Code Simpler? A Preliminary Study - W...Maurício Aniche
 
Minicurso sobre Evolução de Software no CBSoft 2011
Minicurso sobre Evolução de Software no CBSoft 2011Minicurso sobre Evolução de Software no CBSoft 2011
Minicurso sobre Evolução de Software no CBSoft 2011Maurício Aniche
 
MTD2014 - Are The Methods In Your DAOs in the Right Place? A Preliminary Study
MTD2014 - Are The Methods In Your DAOs in the Right Place? A Preliminary StudyMTD2014 - Are The Methods In Your DAOs in the Right Place? A Preliminary Study
MTD2014 - Are The Methods In Your DAOs in the Right Place? A Preliminary StudyMaurício Aniche
 
[TDC 2014] Métricas de código, pra que te quero?
[TDC 2014] Métricas de código, pra que te quero?[TDC 2014] Métricas de código, pra que te quero?
[TDC 2014] Métricas de código, pra que te quero?Maurício Aniche
 

Plus de Maurício Aniche (20)

Can ML help software developers? (TEQnation 2022)
Can ML help software developers? (TEQnation 2022)Can ML help software developers? (TEQnation 2022)
Can ML help software developers? (TEQnation 2022)
 
Tracing Back Log Data to its Log Statement: From Research to Practice
Tracing Back Log Data to its Log Statement: From Research to PracticeTracing Back Log Data to its Log Statement: From Research to Practice
Tracing Back Log Data to its Log Statement: From Research to Practice
 
Pragmatic software testing education - SIGCSE 2019
Pragmatic software testing education - SIGCSE 2019Pragmatic software testing education - SIGCSE 2019
Pragmatic software testing education - SIGCSE 2019
 
Test Automation Day 2018
Test Automation Day 2018Test Automation Day 2018
Test Automation Day 2018
 
Software Testing with Caipirinhas and Stroopwafels
Software Testing with Caipirinhas and StroopwafelsSoftware Testing with Caipirinhas and Stroopwafels
Software Testing with Caipirinhas and Stroopwafels
 
Code smells in MVC applications (Dutch Spring meetup)
Code smells in MVC applications (Dutch Spring meetup)Code smells in MVC applications (Dutch Spring meetup)
Code smells in MVC applications (Dutch Spring meetup)
 
A Collaborative Approach to Teach Software Architecture - SIGCSE 2017
A Collaborative Approach to Teach Software Architecture - SIGCSE 2017A Collaborative Approach to Teach Software Architecture - SIGCSE 2017
A Collaborative Approach to Teach Software Architecture - SIGCSE 2017
 
Code quality in MVC systems - BENEVOL 2016
Code quality in MVC systems - BENEVOL 2016Code quality in MVC systems - BENEVOL 2016
Code quality in MVC systems - BENEVOL 2016
 
SATT: Tailoring Code Metric Thresholds for Different Software Architectures (...
SATT: Tailoring Code Metric Thresholds for Different Software Architectures (...SATT: Tailoring Code Metric Thresholds for Different Software Architectures (...
SATT: Tailoring Code Metric Thresholds for Different Software Architectures (...
 
DNAD 2015 - Métricas de código, pra que te quero?
DNAD 2015 - Métricas de código, pra que te quero?DNAD 2015 - Métricas de código, pra que te quero?
DNAD 2015 - Métricas de código, pra que te quero?
 
Como eu aprendi que testar software é importante?
Como eu aprendi que testar software é importante?Como eu aprendi que testar software é importante?
Como eu aprendi que testar software é importante?
 
Proposta: Métricas e Heurísticas para Detecção de Problemas em Aplicações Web
Proposta: Métricas e Heurísticas para Detecção de Problemas em Aplicações WebProposta: Métricas e Heurísticas para Detecção de Problemas em Aplicações Web
Proposta: Métricas e Heurísticas para Detecção de Problemas em Aplicações Web
 
Efeitos da Prática de Revisão de Código na Caelum: Um Estudo Preliminar em Du...
Efeitos da Prática de Revisão de Código na Caelum: Um Estudo Preliminar em Du...Efeitos da Prática de Revisão de Código na Caelum: Um Estudo Preliminar em Du...
Efeitos da Prática de Revisão de Código na Caelum: Um Estudo Preliminar em Du...
 
Test-Driven Development serve pra mim?
Test-Driven Development serve pra mim?Test-Driven Development serve pra mim?
Test-Driven Development serve pra mim?
 
O que estamos temos feito com mineração de repositório de código no IME?
O que estamos temos feito com mineração de repositório de código no IME?O que estamos temos feito com mineração de repositório de código no IME?
O que estamos temos feito com mineração de repositório de código no IME?
 
MetricMiner: Supporting Researchers in Mining Software Repositories - SCAM 2013
MetricMiner: Supporting Researchers in Mining Software Repositories - SCAM 2013MetricMiner: Supporting Researchers in Mining Software Repositories - SCAM 2013
MetricMiner: Supporting Researchers in Mining Software Repositories - SCAM 2013
 
Does the Act of Refactoring Really Make Code Simpler? A Preliminary Study - W...
Does the Act of Refactoring Really Make Code Simpler? A Preliminary Study - W...Does the Act of Refactoring Really Make Code Simpler? A Preliminary Study - W...
Does the Act of Refactoring Really Make Code Simpler? A Preliminary Study - W...
 
Minicurso sobre Evolução de Software no CBSoft 2011
Minicurso sobre Evolução de Software no CBSoft 2011Minicurso sobre Evolução de Software no CBSoft 2011
Minicurso sobre Evolução de Software no CBSoft 2011
 
MTD2014 - Are The Methods In Your DAOs in the Right Place? A Preliminary Study
MTD2014 - Are The Methods In Your DAOs in the Right Place? A Preliminary StudyMTD2014 - Are The Methods In Your DAOs in the Right Place? A Preliminary Study
MTD2014 - Are The Methods In Your DAOs in the Right Place? A Preliminary Study
 
[TDC 2014] Métricas de código, pra que te quero?
[TDC 2014] Métricas de código, pra que te quero?[TDC 2014] Métricas de código, pra que te quero?
[TDC 2014] Métricas de código, pra que te quero?
 

Dernier

UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Dernier (20)

UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

What Do the Asserts in a Unit Test Tell Us About Code Quality? (CSMR2013)

  • 1. IME-USP What Do the Asserts in a Unit Test Tell us About Code Quality? Mauricio Aniche Gustavo Oliva Marco Gerosa University of São Paulo (USP)
  • 2. Unit Tests and Code Quality  Great synergy between a testable class and a well-designed class (Feathers, 2012)  The write of unit tests can become complex as the interactions between software components grow out of control (McGregor, 2001)  Agile practitioners state that unit tests are a way to validate and improve class design (Beck et al, 2001)
  • 3. Unit Tests and Asserts  Every unit test contains three parts  Set up the scenario  Invoke the behavior under test  Validates the expected output  Assert instructions  assertEquals (expected, calculated);  assertTrue(), assertFalse(), and so on  No limits for the number of asserts per test
  • 4. A little piece of code class InvoiceTest { @Test public void shouldCalculateTaxes() { // (i) setting up the scenario Invoice inv = new Invoice(5000.0); // (ii) invoking the behavior double tax = inv.calculateTaxes(); // (iii) validating the output assertEquals (5000 ∗ 0.06 , tax ); } }
  • 5. Why would… … a test contain more than one assert?  Is it a smell of bad code/design?
  • 6. Research Design  We selected 22 projects  19 from ASF  3 from a Brazilian consultancy  Data extraction from all projects  Code metrics  Statistical Test  Qualitative Analysis
  • 7. Hypotheses  H1: Code tested by only one assert does not present lower cyclomatic complexity than code tested by more than one assert  H2: Code tested by only one assert does not present fewer lines of code than code tested by more than one assert  H3: Code tested by only one assert does not present lower quantity of method invocations than code tested by more than one assert
  • 8. Data Extraction  Test code  Number of asserts per test  Production method being tested  Production code  Cyclomatic Complexity (McCabe, 1976)  Number of method invocations (Li and Henry, 1993)  Lines of Code
  • 9. Heuristic to Extract the Production Method class InvoiceTest { class Invoice { @Test public double calculateTaxes() { public void shouldCalculateTaxes() { // something… // (i) setting up the scenario } Invoice inv = new Invoice(5000.0); } // (ii) invoking the behavior double tax = inv.calculateTaxes(); // (iii) validating the output assertEquals (5000 ∗ 0.06 , tax ); } }
  • 10. Selected Projects  Pre-selected all 213 projects from Apache  Eliminated those because of:  Minimum test ratio (unit tests / production methods >= 0.2)  Success in production method detection algorithm (higher than 50% in all unit tests that contain more than 1 assert)
  • 13. Statistical Test  Separation in two different groups  The same method can appear in both groups  No duplicates  Wilcoxon Signed-Rank Test
  • 15. Why more than 1 assert?  130tests randomly selected  Qualitative analysis:  More than one assert for the same object (40.4%)  Different inputs to the same method (38.9%)  List/Array (9.9%)  Others (6.8%)  Extra assert to check if object is not null (3.8%)
  • 16. “Asserted Objects”  We coined the term “asserted objects”  It counts not the number of asserts in a unit test, but the number of different instances of objects that are being asserted assertEquals(10, obj.getA()); assertEquals(20, obj.getB()); Counts as 1 “asserted object”
  • 19. Summary of the Tests
  • 20. Findings  Counting the number of asserts in a unit test does not give valuable feedback about code quality  But counting the number of asserted objects may provide useful information  However, the difference between both groups was not “big”  A possible explanation:  Methods that contain higher CC, lines of code, and method invocations contains many different paths, and developers prefer to write all of it in a single unit test, rather than splitting in many of them
  • 21. Threats to Validity  Many unit tests variations that are not supported by our tool  The production method detection algorithm  Before/After methods  The projects’ filtering process  Integration and system tests
  • 22. Related Work  Mostsimilar to our work: Bruntink and van Deursen (2006).  Significant correlation between class metrics (fan out, size of a class, response for a class) and test metrics (size of the class, number of asserts).
  • 23. Conclusions  The number of asserts does not tell us anything about the production code quality  But the number of asserted objects does.  “More than one asserted object per test” smell  Theneed of replicating the study with a larger amount of industry projects
  • 24. Contact Information  Mauricio Aniche aniche@ime.usp.br / @mauricioaniche  Gustavo Oliva goliva@ime.usp.br / @golivax  Marco Gerosa gerosa@ime.usp.br Software Engineering & Collaborative Systems Research Lab (LAPESSC) http://lapessc.ime.usp.br/

Notes de l'éditeur

  1. É importante dizer o porquê da escolha desse teste estatístico