Code Monkey home page Code Monkey logo

visualstudio-testhost's Introduction

VisualStudio-TestHost

Join the chat at https://gitter.im/Microsoft/VisualStudio-TestHost

Infrastructure for executing interactive UI tests in Visual Studio.

Quick Start

The latest release will install the required components into all supported versions of Visual Studio. After installing a new version of Visual Studio, you will need to reinstall the test host.

Test settings files are used to specify the version of Visual Studio to launch. Example file

Add the [HostType("VSTestHost")] attribute to your unit tests, and your test will now launch VS and run within its process. The VS instance will be reused between tests, so make sure you clean everything up regardless of whether your test passes or fails. In PTVS we use a helper class with IDisposable to ensure that failed tests do not affect later ones.

Use the VSTestContext static class to access the global service provider and DTE objects of the running Visual Studio instance. You can obtain a UI automation object with AutomationElement.FromHandle(VSTestContext.DTE.MainWindow.HWnd).

For information about how this extension works, see the Developer Guide.

Supported Versions

The following versions of Visual Studio may be used as test targets:

  • Visual Studio 2015 Community and higher
  • Visual Studio Express 2015 for Web or Desktop
  • Visual Studio 2013 Community and higher
  • Visual Studio Express 2013 for Web or Desktop with Update 2
  • Visual Studio 2012 Professional and higher

The following versions of Visual Studio may be used to launch tests:

  • Visual Studio 2015 Community and higher
  • Visual Studio 2013 Community and higher

(The difference in support is due to changes in the unit test framework. If possible, tests should be launched with the same version as the test target.)

Test Settings

These settings should be specified in a .testsettings file or with the TestProperty attribute before launching tests.

Setting Description Values
VSApplication The registry key name "VisualStudio", "WDExpress", "VWDExpress", "Mock"
VSExecutable The executable name or path "devenv", "wdexpress", "vwdexpress"
VSVersion The version number "11.0", "12.0", "14.0" or blank (match tester)
VSHive The hive name "Exp" or "Default"
VSLaunchTimeoutInSeconds The number of seconds to wait for launch Any number, or blank (30s)
VSDebugMixedMode Use native debugging for tests "True", "False" or blank
VSReuseInstance Reuse of the same VS instance for distinct tests "True", "False" or blank (reuse)
ScreenCapture Directory to capture screenshots into Blank (do not capture) or a relative path
ScreenCaptureInterval Milliseconds between screenshots Any number, or blank (1000ms)

If VSApplication is set to Mock, no instance of Visual Studio will be launched and tests will be run in the current process. In this case, the VSTestContext.IsMock property will be true and VSTestContext.ServiceProvider should be set by your test run initializer.

When screen capture is enabled, only unique screenshots are retained, and all screenshots are deleted when a test passes.

visualstudio-testhost's People

Contributors

capfei avatar gitter-badger avatar sailro avatar sharwell avatar zooba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

visualstudio-testhost's Issues

Port helper class from PTVS

For PTVS we use helper classes for interacting with Visual Studio.

We should port the core pieces of this functionality into VSTestHost so that people do not need to reimplement it themselves.

Skip log-in screen when running a test in a brand-new hive?

Whenever you launch Visual Studio in a new hive, you get this screen:
image

Is there any way for an integration test to skip this or otherwise automate pressing the "Not now, maybe later" link? It's been a bit of a pain to have to do this on every new machine your tests run on. Perhaps VisualStudio-TestHost should even do this by default?

Installation in PrivateAssemblies

Why is this package installed in the IDE installation's PrivateAssemblies folder rather than in the user's AppData folder where other VSIX packages get installed?

How can I use this library to write automated integration test?

I would like to know if possible how I can use this tool to perform some integration testing for a visual studio extension. I will need to write end to end tests from the time a user starts interacting with the visual studio extension, including UI tests. I have checked for any documentation online with no success.

Support per-test VS launch settings

Currently we load VS settings from the run settings (*.testsettings file), but properties can also be applied to individual tests:

[TestMethod]
[TestProperty("VSVersion", "12.0")]
[HostType("VSTestHost")]

We should add the logic required to re-evaluate the required VS instance for each test based on the test properties, restarting the instance if necessary.

I don't think it's possible to re-order tests to group ones with matching properties, so having lots of different tests in the same class may not be a good idea for performance, but for small projects it'll be more convenient than dealing with multiple separate files.

Create Gitter room

Can you create a gitter.im room for this repository by any chance, similar to what the roslyn/corefx/coreclr teams have done?

Test host causes activity log error when starting SQL Server Management Studio

This version of SQL Server Management Studio:
https://msdn.microsoft.com/en-us/library/mt238290.aspx

If you have VS Test Host Adapter 1.0.4 installed, you'll get this on startup:

---------------------------
Microsoft SQL Server Management Studio
---------------------------
The 'VSTestHostPackage' package did not load correctly.



The problem may have been caused by a configuration change or by the installation of another extension. You can get more information by examining the file 'C:\Users\huvalo\AppData\Roaming\Microsoft\AppEnv\14.0\ActivityLog.xml'.



Restarting Visual Studio could help resolve this issue.



Continue to show this error message?
---------------------------
Yes   No   
---------------------------

From activity log:

  <entry>
    <record>55</record>
    <time>2016/10/27 21:21:23.855</time>
    <type>Information</type>
    <source>VisualStudio</source>
    <description>Entering function CVsPackageInfo::HrInstantiatePackage</description>
    <guid>{4A7E4285-12F6-4CEB-B878-F029A43A5315}</guid>
  </entry>
  <entry>
    <record>56</record>
    <time>2016/10/27 21:21:23.855</time>
    <type>Warning</type>
    <source>VisualStudio</source>
    <description>Appid denied the loading of package</description>
    <guid>{4A7E4285-12F6-4CEB-B878-F029A43A5315}</guid>
  </entry>

The test adapter ('Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') required to execute this test could not be loaded.

When I try to run the simple tests of the attached solution, I always get:

The test adapter ('Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') required to execute this test could not be loaded.

image

UnitTestProject2.zip

My VS version is:

image

Issue launching a test in VS 2017 - "Failed to launch devenv.exe"

I'm experiencing the issue described in Issue #36 (now closed). After following the patch instructions on that issue, I get the following test result output (VS is never launched):

TestContext Messages: Launching VisualStudio: "...\Microsoft Visual Studio 15.0\Common7\IDE\devenv.exe" Failed to launch devenv.exe (VisualStudio, 15.0) Restarting VS Launching VisualStudio: "...\Microsoft Visual Studio 15.0\Common7\IDE\devenv.exe" Failed to launch devenv.exe (VisualStudio, 15.0)

I have carefully followed the instructions to create the symbolic links and am using the right .testsettings file, but I am still seeing this as the result of my test runs (tried my own project and the example at the start of this issue):

Anyone have any ideas for what I can try / where I can look?

Intellisense errors with 1.0.2

After upgrading from v1.0.1 to 1.0.2:

  • With VS2013 everything is fine
  • With VS2015: our solution builds OK, tests are OK but VS display intellisense errors:

CS0234 The type or namespace name 'VSTestHost' does not exist in the namespace 'Microsoft.VisualStudioTools' (are you missing an assembly reference?)

image

image

image

Perhaps a Roslyn bug ?

"HostType" could not be found after execution of PowerShell install script

Hello, I just tried to use this extension but within Unittest-files I only get the following errors:

Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'HostTypeAttribute' could not be found (are you missing a using directive or an assembly reference?) UnitTestProject5 C:\temp\UnitTestProject5\UnitTestProject5\UnitTest1.cs 10 Active Error CS0246 The type or namespace name 'HostType' could not be found (are you missing a using directive or an assembly reference?) UnitTestProject5 C:\temp\UnitTestProject5\UnitTestProject5\UnitTest1.cs 10 Active

Have a look on the screenshot.
Within PowerShell not install error occur.
The testsettings files are provided VS' install directory, the dlls are there as well.

But in VS the HostType is unknown.

What should I do?

2018-08-20 12_16_23-c__program files x86 _microsoft visual studio_2017_professional_common7_ide_com

2018-08-20 12_14_39-c__program files x86 _microsoft visual studio_2017_professional

missing types in unittest-project

powershellinstallof-vstesthost

Looks installed:
installed extensions

Screen capture while running tests

Automatically capture the screens of the test machine so when errors occur on headless devices we can see what was happening.

Bonus points to only keep images that changed from the previous one, to only keep images from failed tests, and/or to use some form of delta compression between frames.

Best practices for cross-version testing

What is the recommended practice for testing an extension in Visual Studio 2010 or 2012, using Visual Studio 2013 or 2015 to launch the tests? I'm looking for guidance regarding automation of the following items:

  1. Deploying the extension to the correct version of Visual Studio
  2. Selecting the .testsettings file which matches that environment
  3. Running tests outside the debugger
  4. Running tests in the debugger

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.