Errors in quantum programs are challenging to track down due to the uncertainty of quantum programs. Testing is, therefore, an indispensable method for assuring the quality of quantum software. Existing testing methods focus only on testing quantum programs with quantum circuits or single subroutines and, therefore, cannot effectively test quantum programs with multi-subroutines. In this paper, we first discuss several critical issues that must be considered when testing multi-subroutine quantum programs and point out the limitations and problems with existing testing methods. We then present a novel framework for testing multi-subroutine quantum programs that allow for both unit and integration testing. Our framework includes two novel test coverage criteria for the equivalent class partition of quantum variables to guide our testing tasks and techniques to test quantum programs with several common patterns. We also discuss how to generate test cases based on our framework. To evaluate the effectiveness of our testing framework, we implemented a tool called QSharpTester for testing Q\# programs with multiple subroutines. We used it to conduct experiments on hundreds of mutation programs deriving from seven original Q\# programs. The experimental results show that our testing methods can deal with broader types of quantum programs than existing ones and perform well on almost all faulty mutation programs.
翻译:由于量子程序存在不确定性,其中的错误难以追踪。因此,测试是保证量子软件质量不可或缺的方法。现有测试方法仅关注含量子线路或单一子程序的量子程序,无法有效测试含多个子程序的量子程序。本文首先探讨了测试多子程序量子程序时必须考虑的若干关键问题,并指出现有测试方法的局限与不足。随后,我们提出了一种新颖的测试多子程序量子程序的框架,支持单元测试与集成测试。该框架包含两种基于量子变量等价类划分的新型测试覆盖准则,以指导测试任务与针对若干常见模式的量子程序测试技术。同时,我们讨论了基于该框架生成测试用例的方法。为评估测试框架的有效性,我们实现了名为QSharpTester的工具,用于测试含多个子程序的Q#程序。基于七个原始Q#程序衍生的数百个变异程序进行实验,结果表明:与现有方法相比,我们的测试方法能处理更广泛的量子程序类型,且对几乎所有错误变异程序均表现良好。