Characterizing and Refactoring Table-Driven Tests in Go
This program is tentative and subject to change.
Table-driven tests are a widely adopted style in Go, where multiple scenarios are encoded in a single data structure and executed in a loop. Despite its popularity, there is a limited understanding of how table-driven tests are implemented in the real world. This paper presents a pilot study of table-driven tests across five popular open-source Go projects, comprising over 8,000 total tests. Our analysis indicates that between 31.7% and 83.1% of tests in these projects are table-driven, with an overall prevalence of nearly half. From this, we identify a conventional structure for table-driven tests where scenarios are defined as structured data with inputs, outputs, and names, executed in loops containing assertions, and run as subtests for clarity and control. We also observed deviations that hinder readability and execution control, such as missing subtests and scenario names. To address these issues, we introduce an automated refactoring technique that integrates subtests into table-driven tests that lack them. Applied to over 1,100 eligible tests, our approach achieved a 69% success rate while preserving behavior in all but one case. These results highlight both the prevalence of table-driven testing in Go and the feasibility of automated improvements that make tests more maintainable, informative, and standardized.
This program is tentative and subject to change.
Thu 16 AprDisplayed time zone: Brasilia, Distrito Federal, Brazil change
16:00 - 17:30 | Testing and Analysis 13New Ideas and Emerging Results (NIER) / Software Engineering Education and Training (SEET) / Journal-first Papers at Oceania II Chair(s): Lei Zhang University of Maryland Baltimore County | ||
16:00 15mTalk | How to Save My Gas Fees: Understanding and Detecting Real-World Gas Issues in Solidity Programs Journal-first Papers Mengting He The Pennsylvania State University, Shihao Xia The Pennsylvania State University, Boqin Qin China Telecom Cloud Computing Corporation, Nobuko Yoshida University of Oxford, Tingting Yu University of Connecticut, Yiying Zhang University of California San Diego, Linhai Song The Pennsylvania State University | ||
16:15 15mTalk | Reasoning About Bugs in Learners’ Scratch Programs Using Large Language Models Software Engineering Education and Training (SEET) Benedikt Fein University of Passau, Patric Feldmeier University of Passau, Florian Obermueller University of Passau, Gordon Fraser University of Passau DOI Pre-print | ||
16:30 15mTalk | Characterizing and Refactoring Table-Driven Tests in Go New Ideas and Emerging Results (NIER) Max Green Stevens Institute of Technology, Lu Xiao Stevens Institute of Technology, Zhongpeng Lin Uber Technologies Inc. | ||
16:45 15mTalk | Data-aware Static Analysis: Improving Semantic Fault Detection in Machine Learning Code Using Data Characteristics New Ideas and Emerging Results (NIER) Willem Meijer Linköping University, Kristian Sandahl Linköping University, Daniel Varro Linköping University / McGill University | ||
17:00 15mTalk | Towards Automatically Inferring Constraints to Identify Implicit Assumptions in Data Analysis New Ideas and Emerging Results (NIER) Florian Sihler Ulm University, Lars Pfrenger Ulm University, Oliver Gerstl Ulm University, Matthias Tichy Ulm University | ||
17:15 15mTalk | QSolver: A Quantum Constraint Solver New Ideas and Emerging Results (NIER) | ||