Merge pull request #15749 from github/koesie10/update-testing-vscode-docs

Update documentation for testing CodeQL queries in VS Code
This commit is contained in:
Koen Vlaswinkel
2024-02-28 16:29:54 +01:00
committed by GitHub
6 changed files with 13 additions and 9 deletions

View File

@@ -12,27 +12,31 @@ About testing queries in VS Code
To ensure that your CodeQL queries produce the expected results, you can run tests that compare the expected query results with the actual results.
The CodeQL extension automatically prompts VS Code to install the Test Explorer extension as a dependency. The Test Explorer displays any workspace folders with a name ending in ``-tests`` and provides a UI for exploring and running tests in those folders.
The CodeQL extension automatically registers itself with the **Testing** view. The **Testing** view displays all tests found in your current workspace and provides a UI for exploring and running tests in your workspace.
For more information about how CodeQL tests work, see "`Testing custom queries <https://docs.github.com/en/code-security/codeql-cli/using-the-codeql-cli/testing-custom-queries>`__" in the CLI help.
Testing the results of your queries
-----------------------------------
1. Open the Test Explorer view in the sidebar.
1. Open the **Testing** view in the sidebar.
.. image:: ../images/codeql-for-visual-studio-code/open-test-explorer.png
.. image:: ../images/codeql-for-visual-studio-code/open-testing-view.png
:width: 350
:alt: Open the Test Explorer view
:alt: Open the Testing view
2. To run a specific test, hover over the file or folder name and click the play button. To run all tests in your workspace, click the play button at the top of the view. If a test takes too long to run, you can click the stop button at the top of the view to cancel the test.
3. The icons show whether a test passed or failed. If it failed, right-click the failed test and click **CodeQL: Show Test Output Differences** to display the differences between the expected output and the actual output.
3. The icons show whether a test passed or failed. If it failed, click the test in the **Test Results** panel to display the differences between the expected output and the actual output.
.. image:: ../images/codeql-for-visual-studio-code/show-test-diff.png
.. image:: ../images/codeql-for-visual-studio-code/test-results-panel.png
:width: 800
:alt: View the Test Results panel
4. Compare the results. If you want to update the test with the actual output, right-click the test in the **Testing** view and click **Accept Test Output**.
.. image:: ../images/codeql-for-visual-studio-code/accept-test-output.png
:width: 400
:alt: Show test output differences
4. Compare the results. If you want to update the test with the actual output, click **CodeQL: Accept Test Output**.
:alt: Acccept test output in the Testing view
Monitoring the performance of your queries
------------------------------------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB