Inline Tests
Yu Liu, Pengyu Nie, Owolabi Legunsen, Milos Gligoric
Abstract
Unit tests are widely used to check source code quality, but they can be too coarse-grained or ill-suited for testing individual program statements. We introduce inline tests to make it easier to check for faults in statements. We motivate inline tests through several language features and a common testing scenario in which inline tests could be beneficial. For example, inline tests can allow a developer to test a regular expression in place. We also define language-agnostic requirements for inline testing frameworks. Lastly, we implement I-Test, the first inline testing framework. I-Test works for Python and Java, and it satisfies most of the requirements. We evaluate I-Test on open-source projects by using it to test 144 statements in 31 Python programs and 37 Java programs. We also perform a user study. All nine user study participants say that inline tests are easy to write and that inline testing is beneficial. The cost of running inline tests is negligible, at 0.007x-0.014x, and our inline tests helped find two faults that have been fixed by the developers. CCS CONCEPTS • Software and its engineering → Software testing and debugging.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Cited by top-tier papers1
Ask how each one uses itBuilds on3
- A study on the lifecycle of flaky testsWing Lam, Kivanç Muslu, Hitesh Sajnani, Suresh ThummalapentaICSE 2020 · 107 citations
- No Strings Attached: An Empirical Study of String-related Software BugsAryaz Eghbali, Michael PradelASE 2020 · 17 citations
- Unifying execution of imperative generators and declarative specificationsPengyu Nie, Marinela Parovic, Zhiqiang Zang, Sarfraz Khurshid et al.OOPSLA 2020 · 7 citations
Related papers
- Block TestsKevin Guan, Pengyue Jiang, Milos Gligoric, Owolabi LegunsenOOPSLA 2026
- Extracting Inline Tests from Unit TestsYu Liu, Pengyu Nie, Anna Guo, Milos Gligoric et al.ISSTA 2023 · 7 citations
- PyNose: A Test Smell Detector For PythonTongjie Wang, Yaroslav Golubev, Oleg Smirnov, Jiawei Li et al.ASE 2021 · 44 citations
- Improving Testing Behavior by Gamifying IntelliJPhilipp Straubinger, Gordon FraserICSE 2024 · 5 citations
- An automatic refactoring framework for replacing test-production inheritance by mocking mechanismXiao Wang, Lu Xiao, Tingting Yu, Anne Woepse et al.FSE 2021 · 15 citations
