Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Latest commit

 

History

History
61 lines (45 loc) · 2.9 KB

File metadata and controls

61 lines (45 loc) · 2.9 KB

Unit Testing Sample

This sample set illustrates techniques for testing the correctness of the circuits and computing metrics describing circuits such as number of qubits used, gate counts and depth. We implement, test and compute metrics for the circuits from the following categories

Each file illustrating the category is accompanied with the file ending "Tests" with test for the circuits. The list of the test files is below:

Operations and functions from the Q# standard library used for testing

The correctness of all the programs in this sample is tested using functionality from the Q# standard library:

  • AssertOperationsEqualReferenced
  • AssertOperationsEqualInPlace
  • AssertQubitState

Test harness

This sample uses Microsoft.Quantum.Xunit extension to xUnit.net framework to automatically discover Q# tests. The tests are all the operations with signature "() => ()" with suffix "Test". The test harness located in QuantumSimulatorTestTargets.cs.

Metrics calculation

In addition to testing the correctness of the circuit we also compute their metrics such as gate counts, depth and number of qubit used. Metrics calculation is illustrated in files ending "Metrics":

File MetricCalculationUtils.cs contains the function that creates QCTraceSimulator configured for metric calculation.

Sample dependencies

This samples uses Microsoft.Quantum.Canon library and depends on the following NuGet packages:

  • Microsoft.Quantum.Development.Kit: Q# runtime framework
  • Microsoft.Quantum.Xunit: xUnit.net extension for discovering Q# tests
  • xunit: xUnit.net testing framework for .NET