Please complete the security check to access this website.
Why do I have to complete a CAPTCHA?
Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.
What can I do to prevent this?
Reported by Craig Chapman May 15 at 05:12 PM windows 10.0 visual studio 2017 version 15.6 debugger performance testing-tools visual studio. I have created a simple Class Library project containing a single one-line Nunit test. On one computer it takes 27 seconds to run the test. If you pick Other Languages -> Visual C# -> Test -> Test Project.when you're choosing the project type, Visual Studio will try and use it's own testing framework as far as I can tell. You should pick a normal C# class library project instead and then the instructions in my selected answer will work. C# Nunit tests from VS 2013 (Nunit v2.x), won't show in Test Explorer in VS 2017 (Nunit 3.x) windows 10.0 visual studio 2017 version 15.4 project testing-tools andrey_homsky_us reported May 31 at 02:11 PM.
If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.
If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.
Visual Studio Code supports running and debugging tests for your extension. These tests will run inside a special instance of VS Code named the Extension Development Host, and have full access to the VS Code API. We refer to these tests as integration tests, because they go beyond unit tests that can run without a VS Code instance. This documentation focuses on VS Code integration tests.
Overview
If you are migrating from
vscode
, see migrating from vscode
.If you are using the Yeoman Generator to scaffold an extension, integration tests are already created for you.
Visual Studio For Mac Os
In the generated extension, you can use
npm run test
or yarn test
to run the integration tests that:- Downloads and unzips latest version of VS Code.
- Runs the Mocha tests specified by the extension test runner script.
Alternatively, you can find the configuration for this guide in the helloworld-test-sample. The rest of this document explains these files in the context of the sample:
- The test script (
src/test/runTest.ts
) - The test runner script (
src/test/suite/index.ts
)
The test script
VS Code provides two CLI parameters for running extension tests,
--extensionDevelopmentPath
and --extensionTestsPath
.For example:
The test script (
src/test/runTest.ts
) uses the vscode-test
API to simplify the process of downloading, unzipping, and launching VS Code with extension test parameters:The
vscode-test
API also allows:- Launching VS Code with a specific workspace.
- Downloading a different version of VS Code rather than the latest stable release.
- Launching VS Code with additional CLI parameters.
You can find more API usage examples at microsoft/vscode-test.
The test runner script
When running the extension integration test,
--extensionTestsPath
points to the test runner script (src/test/suite/index.ts
) that programmatically runs the test suite. Below is the test runner script of helloworld-test-sample
that uses Mocha to run the test suite. You can use this as a starting point and customize your setup with Mocha's API. You can also replace Mocha with any other test framework that can be run programmatically.Both the test runner script and the
*.test.js
files have access to the VS Code API.Here is a sample test (src/test/suite/extension.test.ts):
Debugging the tests
Debugging the tests is similar to debugging the extension.
Here is a sample
launch.json
debugger configuration:Tips
Using Insiders version for extension development
Because of VS Code's limitation, if you are using VS Code stable release and try to run the integration test on CLI, it will throw an error:
You can either use VS Code Insiders for development or launch the extension test from the debug launch config that bypasses this limitation.
Disabling other extensions while debugging
When you debug an extension test in VS Code, VS Code uses the globally installed instance of VS Code and will load all installed extensions. You can add
--disable-extensions
configuration to the launch.json
or the launchArgs
option of vscode-test
's runTests
API.Custom setup with vscode-test
Sometimes you might want to run custom setups, such as running
code --install-extension
to install another extension before starting your test. vscode-test
has a more granular API to accommodate that case:Migrating from vscode
The
vscode
module had been the default way of running extension integration tests and is being superseded by vscode-test
. Here's how you can migrate from it:- Remove
vscode
dependency. - Add
vscode-test
dependency. - As the old
vscode
module was also used for downloading VS Code type definition, you need to- Manually install
@types/vscode
that follows yourengine.vscode
inpackage.json
. For example, if yourengine.vscode
is1.30
, install@types/[email protected]
. - Remove
'postinstall': 'node ./node_modules/vscode/bin/install'
frompackage.json
.
- Manually install
- Add a test script. You can use
runTest.ts
in the sample as a starting point. - Point the
test
script inpackage.json
to run the compiled output ofrunTest.ts
. - Add a test runner script. You can use the sample test runner script as a starting point. Notice that
vscode
used to depend onmocha@4
andglob
, and now you need to install them as part of yourdevDependencies
.
Next steps
Nunit Vs Visual Studio Test
- Continuous Integration - Run your extension tests in a Continuous Integration service such as Azure DevOps.