Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/996821.996838acmconferencesArticle/Chapter ViewAbstractPublication PagespasteConference Proceedingsconference-collections
Article

Mock object creation for test factoring

Published: 07 June 2004 Publication History
  • Get Citation Alerts
  • Abstract

    Test factoring creates fast, focused unit tests from slow system-wide tests; each new unit test exercises only a subset of the functionality exercised by the system tests. Augmenting a test suite with factored unit tests, and prioritizing the tests, should catch errors earlier in a test run.One way to factor a test is to introduce mock objects. If a test exercises a component A, which is designed to issue queries against or mutate another component B, the implementation of B can be replaced by a mock. The mock has two purposes: it checks that A's calls to B are as expected, and it simulates B's behavior in response. Given a system test for A and B, and a record of A's and B's behavior when the system test is run, we would like to automatically generate unit tests for A in which B is mocked. The factored tests can isolate bugs in A from bugs in B and, if B is slow or expensive, improve test performance or cost.This paper motivates test factoring with an illustrative example, proposes a simple procedure for automatically generating mock objects for factored tests, and gives examples of how the procedure can be extended to produce more robust factored tests.

    References

    [1]
    K. Beck. Extreme Programming Explained: Embrace Change. Addison-Wesley, 1999.
    [2]
    M. Fowler. Refactoring: Improving the Design of Existing Code. Addison-Wesley, 2000.
    [3]
    H. K. N. Leung and L. White. Insights into regression testing. In ICSM, pages 60--69, Oct. 1989.
    [4]
    D. Saff and M. D. Ernst. Reducing wasted development time via continuous testing. In ISSRE, pages 281--292, Nov. 2003.
    [5]
    D. Saff and M. D. Ernst. Continuous testing in Eclipse. In 2nd Eclipse Technology Exchange Workshop (eTX), Barcelona, Spain, Mar. 2004.
    [6]
    D. Saff and M. D. Ernst. An experimental evaluation of continuous testing during development. In ISSTA, July 2004.
    [7]
    W. E. Wong, J. R. Horgan, S. London, and H. Agrawal. A study of effective regression testing in practice. In ISSRE, pages 264--274, Nov. 1997.

    Cited By

    View all
    • (2024)Observation-Based Unit Test Generation at MetaCompanion Proceedings of the 32nd ACM International Conference on the Foundations of Software Engineering10.1145/3663529.3663838(173-184)Online publication date: 10-Jul-2024
    • (2024)Automated Infrastructure as Code Program TestingIEEE Transactions on Software Engineering10.1109/TSE.2024.339307050:6(1585-1599)Online publication date: Jun-2024
    • (2023) StubCoder: Automated Generation and Repair of Stub Code for Mock ObjectsACM Transactions on Software Engineering and Methodology10.1145/361717133:1(1-31)Online publication date: 21-Aug-2023
    • Show More Cited By

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    PASTE '04: Proceedings of the 5th ACM SIGPLAN-SIGSOFT workshop on Program analysis for software tools and engineering
    June 2004
    64 pages
    ISBN:1581139101
    DOI:10.1145/996821
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 07 June 2004

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. mock objects
    2. test factoring
    3. unit testing

    Qualifiers

    • Article

    Conference

    PASTE04

    Acceptance Rates

    PASTE '04 Paper Acceptance Rate 10 of 37 submissions, 27%;
    Overall Acceptance Rate 57 of 159 submissions, 36%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)23
    • Downloads (Last 6 weeks)1

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Observation-Based Unit Test Generation at MetaCompanion Proceedings of the 32nd ACM International Conference on the Foundations of Software Engineering10.1145/3663529.3663838(173-184)Online publication date: 10-Jul-2024
    • (2024)Automated Infrastructure as Code Program TestingIEEE Transactions on Software Engineering10.1109/TSE.2024.339307050:6(1585-1599)Online publication date: Jun-2024
    • (2023) StubCoder: Automated Generation and Repair of Stub Code for Mock ObjectsACM Transactions on Software Engineering and Methodology10.1145/361717133:1(1-31)Online publication date: 21-Aug-2023
    • (2022)Example MiningCompanion Proceedings of the 6th International Conference on the Art, Science, and Engineering of Programming10.1145/3532512.3535226(60-66)Online publication date: 21-Mar-2022
    • (2018)OPTIMIZING THE CODE COVERAGE BY CONTROLLING ENVIRONMENTAL DEPENDENCIES IN UNIT TESTINGi-manager’s Journal on Software Engineering10.26634/jse.12.3.1455512:3(8)Online publication date: 2018
    • (2015)Generating TCP/UDP network data for automated unit test generationProceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering10.1145/2786805.2786828(155-165)Online publication date: 30-Aug-2015
    • (2014)Automated unit test generation for classes with environment dependenciesProceedings of the 29th ACM/IEEE International Conference on Automated Software Engineering10.1145/2642937.2642986(79-90)Online publication date: 15-Sep-2014
    • (2014)Discovering product counterfeits in online shopsJournal of Data and Information Quality10.1145/26296055:1-2(1-3)Online publication date: 4-Sep-2014
    • (2014)Generating Test Cases for Programs that Are Coded against Interfaces and AnnotationsACM Transactions on Software Engineering and Methodology10.1145/254413523:3(1-38)Online publication date: 2-Jun-2014
    • (2010)Language-based replay via data flow cutProceedings of the eighteenth ACM SIGSOFT international symposium on Foundations of software engineering10.1145/1882291.1882322(197-206)Online publication date: 7-Nov-2010
    • Show More Cited By

    View Options

    Get Access

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media