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#程序的数百个变异程序进行了实验。结果表明,我们的测试方法比现有方法能处理更广泛的量子程序类型,且对几乎所有错误变异程序均表现出良好的检测性能。