├── .gitattributes
├── .github
└── workflows
│ └── main.yaml
├── .gitignore
├── Directory.Build.props
├── Directory.Build.targets
├── LICENSE.md
├── NuGet.Config
├── README.md
├── VsixTesting.png
├── VsixTesting.sln
├── appveyor.yml
├── codecov.yml
├── key.snk
├── src
├── VsixTesting.Installer
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ └── launchSettings.json
│ ├── References
│ │ └── Microsoft.VisualStudio.ExtensionManager.dll
│ ├── VsixTesting.Installer.Common.csproj
│ ├── VsixTesting.Installer.csproj
│ ├── VsixTesting.Installer.props
│ └── VsixTesting.Installer.x64.csproj
├── VsixTesting.Invoker
│ ├── 17
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── VsixTesting.Invoker.17.csproj
│ │ └── source.extension.vsixmanifest
│ ├── InvokerPackage.cs
│ ├── InvokerService.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── VsixTesting.Invoker.csproj
│ └── source.extension.vsixmanifest
├── VsixTesting.Xunit
│ ├── Instances.cs
│ ├── Internal
│ │ ├── Diagnostics.cs
│ │ ├── RemoteTestAssemblyRunner.cs
│ │ ├── Utilities
│ │ │ ├── ExceptionRunner.cs
│ │ │ ├── ExceptionTestCase.cs
│ │ │ ├── FakeException.cs
│ │ │ ├── IFinishedMessageExtensions.cs
│ │ │ ├── SerializableRunSummary.cs
│ │ │ └── XunitSerializationInfo.cs
│ │ ├── VsInstanceTestAssemblyRunner.cs
│ │ ├── VsInstanceTestCase.cs
│ │ ├── VsSkippedDataRowTestCase.cs
│ │ ├── VsTestAssemblyRunner.cs
│ │ ├── VsTestCase.cs
│ │ ├── VsTestCaseBase.cs
│ │ ├── VsTestCaseFactory.cs
│ │ ├── VsTestCaseRunner.cs
│ │ ├── VsTestFrameworkExecutor.cs
│ │ ├── VsTestInvoker.cs
│ │ ├── VsTestRunner.cs
│ │ ├── VsTestSettingsUtil.cs
│ │ ├── VsTheoryTestCase.cs
│ │ └── VsTheoryTestCaseRunner.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ └── launchSettings.json
│ ├── VsFactAttribute.cs
│ ├── VsFactDiscoverer.cs
│ ├── VsTestFramework.cs
│ ├── VsTestSettingsAttribute.cs
│ ├── VsTheoryAttribute.cs
│ ├── VsTheoryDiscoverer.cs
│ ├── VsixTesting.Xunit.csproj
│ ├── VsixTesting.Xunit.props
│ └── VsixTesting.Xunit.targets
└── VsixTesting
│ ├── Common
│ ├── IAsyncDisposable.cs
│ ├── ProcessExtensions.cs
│ ├── RunningObjectTable.cs
│ ├── TempFile.cs
│ ├── ThreadUtil.cs
│ └── VersionExtensions.cs
│ ├── GlobalSuppressions.cs
│ ├── IDiagnostics.cs
│ ├── ITestSettings.cs
│ ├── Interop
│ ├── Kernel32.cs
│ ├── Ntdll.cs
│ ├── Ole32.cs
│ ├── Psapi.cs
│ └── User32.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Remote.cs
│ ├── Remoting
│ ├── ChannelUtil.cs
│ └── IRemoteComInvoker.cs
│ ├── Utilities
│ ├── EmbeddedResourceUtil.cs
│ ├── KillProcessJob.cs
│ ├── ProcessUtil.cs
│ ├── RetryMessageFilter.cs
│ └── ScreenshotUtil.cs
│ ├── Vs
│ ├── VersionRange.cs
│ ├── VersionUtil.cs
│ ├── VisualStudioUtil.Installer.cs
│ ├── VisualStudioUtil.cs
│ ├── VsHive.cs
│ ├── VsInstallation.cs
│ └── VsVersion.cs
│ ├── VsInstance.cs
│ ├── VsTestSettings.cs
│ └── VsixTesting.csproj
├── stylecop.json
├── test
├── VsixTesting.Installer.Tests
│ └── VsixTesting.Installer.Tests.csproj
├── VsixTesting.Tests
│ ├── Common
│ │ ├── ThreadUtilTests.cs
│ │ └── VersionExtensions.cs
│ ├── GlobalSuppressions.cs
│ ├── Vs
│ │ ├── VersionRangeTests.cs
│ │ ├── VersionTests.cs
│ │ └── VisualStudioUtilTests.cs
│ └── VsixTesting.Tests.csproj
└── VsixTesting.Xunit.Tests
│ ├── AssemblyTests.cs
│ ├── ClassFixtureTests.cs
│ ├── CollectionFixtureTests.cs
│ ├── InstancesTests.cs
│ ├── Internal
│ ├── ExceptionTestCaseTests.cs
│ ├── VsInstanceTestCaseTests.cs
│ ├── VsSkippedDataRowTestCaseTests.cs
│ └── VsTestCaseTests.cs
│ ├── ProjectReferenceTests.cs
│ ├── Properties
│ └── launchSettings.json
│ ├── Util.cs
│ ├── Utilities
│ └── AsyncTestSyncContextExtensions.cs
│ ├── VsFactTests.cs
│ ├── VsTestCaseFactoryTests.cs
│ ├── VsTheoryTests.cs
│ └── VsixTesting.Xunit.Tests.csproj
└── version.json
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.github/workflows/main.yaml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | build:
7 | if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
8 |
9 | strategy:
10 | matrix:
11 | os: ["windows-2019", "windows-2022"]
12 |
13 | runs-on: ${{ matrix.os }}
14 | env:
15 | CONFIGURATION: Release
16 |
17 | steps:
18 | - uses: actions/checkout@v2
19 | with:
20 | fetch-depth: '0'
21 |
22 | - name: Add msbuild to PATH
23 | uses: microsoft/setup-msbuild@v1.1
24 |
25 | - name: Set Version
26 | run: |
27 | mkdir artifacts
28 | dotnet tool install -g nbgv
29 | nbgv cloud --all-vars
30 |
31 | - name: Restore VsixTesting.Xunit
32 | run: msbuild src/VsixTesting.Xunit /v:m /nologo /t:restore
33 |
34 | - name: Build VsixTesting.Xunit
35 | run: msbuild src/VsixTesting.Xunit /v:m /nologo
36 |
37 | - name: Restore
38 | run: msbuild /v:m /nologo /t:restore
39 |
40 | - name: Build
41 | run: msbuild /v:m /nologo
42 |
43 | - name: Test
44 | run: msbuild /t:test
45 |
46 | - name: Upload nuget packages
47 | if: matrix.os == 'windows-2022'
48 | uses: actions/upload-artifact@v2
49 | with:
50 | name: VsixTesting
51 | path: |
52 | artifacts/*.nupkg
53 |
54 | - name: Upload test results
55 | uses: actions/upload-artifact@v2
56 | with:
57 | name: VsixTesting.TestResults.${{matrix.os}}
58 | path: |
59 | artifacts/*.TestResults.xml
60 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | project.fragment.lock.json
46 | artifacts/
47 |
48 | *_i.c
49 | *_p.c
50 | *_i.h
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.tmp_proj
65 | *.log
66 | *.vspscc
67 | *.vssscc
68 | .builds
69 | *.pidb
70 | *.svclog
71 | *.scc
72 |
73 | # Chutzpah Test files
74 | _Chutzpah*
75 |
76 | # Visual C++ cache files
77 | ipch/
78 | *.aps
79 | *.ncb
80 | *.opendb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 | *.VC.db
85 | *.VC.VC.opendb
86 |
87 | # Visual Studio profiler
88 | *.psess
89 | *.vsp
90 | *.vspx
91 | *.sap
92 |
93 | # TFS 2012 Local Workspace
94 | $tf/
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 | *.DotSettings.user
103 |
104 | # JustCode is a .NET coding add-in
105 | .JustCode
106 |
107 | # TeamCity is a build add-in
108 | _TeamCity*
109 |
110 | # DotCover is a Code Coverage Tool
111 | *.dotCover
112 |
113 | # NCrunch
114 | _NCrunch_*
115 | .*crunch*.local.xml
116 | nCrunchTemp_*
117 |
118 | # MightyMoose
119 | *.mm.*
120 | AutoTest.Net/
121 |
122 | # Web workbench (sass)
123 | .sass-cache/
124 |
125 | # Installshield output folder
126 | [Ee]xpress/
127 |
128 | # DocProject is a documentation generator add-in
129 | DocProject/buildhelp/
130 | DocProject/Help/*.HxT
131 | DocProject/Help/*.HxC
132 | DocProject/Help/*.hhc
133 | DocProject/Help/*.hhk
134 | DocProject/Help/*.hhp
135 | DocProject/Help/Html2
136 | DocProject/Help/html
137 |
138 | # Click-Once directory
139 | publish/
140 |
141 | # Publish Web Output
142 | *.[Pp]ublish.xml
143 | *.azurePubxml
144 | # TODO: Comment the next line if you want to checkin your web deploy settings
145 | # but database connection strings (with potential passwords) will be unencrypted
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
150 | # checkin your Azure Web App publish settings, but sensitive information contained
151 | # in these scripts will be unencrypted
152 | PublishScripts/
153 |
154 | # NuGet Packages
155 | *.nupkg
156 | # The packages folder can be ignored because of Package Restore
157 | **/packages/*
158 | # except build/, which is used as an MSBuild target.
159 | !**/packages/build/
160 | # Uncomment if necessary however generally it will be regenerated when needed
161 | #!**/packages/repositories.config
162 | # NuGet v3's project.json files produces more ignoreable files
163 | *.nuget.props
164 | *.nuget.targets
165 |
166 | # Microsoft Azure Build Output
167 | csx/
168 | *.build.csdef
169 |
170 | # Microsoft Azure Emulator
171 | ecf/
172 | rcf/
173 |
174 | # Windows Store app package directories and files
175 | AppPackages/
176 | BundleArtifacts/
177 | Package.StoreAssociation.xml
178 | _pkginfo.txt
179 |
180 | # Visual Studio cache files
181 | # files ending in .cache can be ignored
182 | *.[Cc]ache
183 | # but keep track of directories ending in .cache
184 | !*.[Cc]ache/
185 |
186 | # Others
187 | ClientBin/
188 | ~$*
189 | *~
190 | *.dbmdl
191 | *.dbproj.schemaview
192 | *.jfm
193 | *.pfx
194 | *.publishsettings
195 | node_modules/
196 | orleans.codegen.cs
197 |
198 | # Since there are multiple workflows, uncomment next line to ignore bower_components
199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200 | #bower_components/
201 |
202 | # RIA/Silverlight projects
203 | Generated_Code/
204 |
205 | # Backup & report files from converting an old project file
206 | # to a newer Visual Studio version. Backup files are not needed,
207 | # because we have git ;-)
208 | _UpgradeReport_Files/
209 | Backup*/
210 | UpgradeLog*.XML
211 | UpgradeLog*.htm
212 |
213 | # SQL Server files
214 | *.mdf
215 | *.ldf
216 |
217 | # Business Intelligence projects
218 | *.rdl.data
219 | *.bim.layout
220 | *.bim_*.settings
221 |
222 | # Microsoft Fakes
223 | FakesAssemblies/
224 |
225 | # GhostDoc plugin setting file
226 | *.GhostDoc.xml
227 |
228 | # Node.js Tools for Visual Studio
229 | .ntvs_analysis.dat
230 |
231 | # Visual Studio 6 build log
232 | *.plg
233 |
234 | # Visual Studio 6 workspace options file
235 | *.opt
236 |
237 | # Visual Studio LightSwitch build output
238 | **/*.HTMLClient/GeneratedArtifacts
239 | **/*.DesktopClient/GeneratedArtifacts
240 | **/*.DesktopClient/ModelManifest.xml
241 | **/*.Server/GeneratedArtifacts
242 | **/*.Server/ModelManifest.xml
243 | _Pvt_Extensions
244 |
245 | # Paket dependency manager
246 | .paket/paket.exe
247 | paket-files/
248 |
249 | # FAKE - F# Make
250 | .fake/
251 |
252 | # JetBrains Rider
253 | .idea/
254 | *.sln.iml
255 |
256 | # CodeRush
257 | .cr/
258 |
259 | # Python Tools for Visual Studio (PTVS)
260 | __pycache__/
261 | *.pyc
262 |
263 | #
264 | Local.targets
265 | gitignore
266 | init.cmd
--------------------------------------------------------------------------------
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | $(MSBuildThisFileDirectory)
4 | Debug
5 |
6 |
7 |
8 | $(SolutionDir)obj\$(MSBuildProjectName)\
9 | $(SolutionDir)bin\$(MSBuildProjectName)\$(Configuration)\
10 | $(SolutionDir)key.snk
11 | $(USERPROFILE)\.nuget\packages\
12 | $(SolutionDir)artifacts
13 | latest
14 | false
15 | false
16 | false
17 | true
18 |
19 |
20 |
21 | Apache-2.0
22 | https://github.com/josetr/VsixTesting
23 | https://github.com/josetr/VsixTesting
24 | git
25 | VisualStudio, Extension, Testing, Xunit, VSIX
26 | © Jose Torres. All Rights Reserved.
27 | Jose Torres
28 | VsixTesting
29 | VsixTesting allows you to easily test your Visual Studio Extensions.
30 |
31 |
32 |
33 | $(DefineConstants);CI
34 |
35 |
36 |
37 |
38 | $(SolutionDir)bin\VsixTesting.Xunit\$(Configuration)
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2.3.1
5 | 4.6.519
6 | 1.0.5
7 | 3.1.2
8 | 1.1.0-beta2-21168-01
9 | 1.2.0.1
10 | $(GlobalPackagesPath)opencover\$(OpenCoverVersion)\tools\opencover.console.exe
11 | $(GlobalPackagesPath)codecov\$(CodeCovVersion)\tools\codecov.exe
12 | $(GlobalPackagesPath)reportgenerator\$(ReportGeneratorVersion)\tools\ReportGenerator.exe
13 | $(GlobalPackagesPath)Microsoft.DiaSymReader.Pdb2Pdb\$(Pdb2PdbVersion)\tools\Pdb2Pdb.exe
14 | $(GlobalPackagesPath)InheritDoc\$(InheritDocVersion)\tools\InheritDoc.exe
15 | true
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | $(SolutionDir)artifacts\
38 | $(SolutionDir)artifacts\
39 | $(TestResultsOutputDirectory)$(AssemblyName).TestResults.xml
40 | $(CoverageOutputDirectory)$(AssemblyName).Coverage.xml
41 | $(CoverageOutputDirectory)$(AssemblyName).Coverage
42 | @(TestAssemblies->'%(FullPath)', ' ') -stoponfail -noshadow -appveyor -diagnostics -xml $(TestResultsOutputXmlPath) -notrait VisualStudio=2012FilterTest
43 |
44 |
45 |
49 |
50 |
60 |
61 |
66 |
67 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | Embedded Resource " + path + " doesn't exist.");
110 | else
111 | {
112 | var item = new XElement("Item");
113 | item.Add(new XAttribute("Name", Path.GetFileName(path)));
114 | item.Add(new XAttribute("CreationTime", File.GetCreationTime(path).Ticks));
115 | item.Add(new XAttribute("LastWriteTime", File.GetLastWriteTime(path).Ticks));
116 | item.Add(new XAttribute("LastAccessTime", File.GetLastAccessTime(path).Ticks));
117 | items.Add(item);
118 | }
119 | }
120 |
121 | new XDocument(items).Save(SaveTo);
122 | ]]>
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2018 Jose Torres.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # VsixTesting
2 | [](http://www.nuget.org/packages/VsixTesting.Xunit/)
3 | [](https://gitter.im/josetr/VsixTesting)
4 | [](https://github.com/josetr/VsixTesting/actions)
5 | [](https://ci.appveyor.com/project/josetr/vsixtesting/branch/master)
6 | [](https://codecov.io/gh/josetr/VsixTesting)
7 | [](https://www.myget.org/feed/vsixtesting/package/nuget/VsixTesting.Xunit)
8 |
9 | VsixTesting allows you to easily test your Visual Studio Extensions.
10 |
11 | 
12 |
13 | It also supports Visual Studio 2019 / 2022.
14 |
15 | ## Getting Started
16 |
17 | The fastest way to get started is cloning the [VsixTestingSamples](https://github.com/josetr/VsixTestingSamples) repo and playing with it.
18 |
19 | `git clone https://github.com/josetr/VsixTestingSamples`
20 |
21 | ## Create the test project
22 |
23 | TestProject.csproj
24 | ```xml
25 |
26 |
27 | net461
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
51 |
52 |
53 | ```
54 |
55 | TestClass.cs
56 | ```csharp
57 | using Microsoft.VisualStudio.Shell;
58 | using Microsoft.VisualStudio.Shell.Interop;
59 | using Xunit;
60 |
61 | namespace Tests
62 | {
63 | public class TestClass
64 | {
65 | [VsFact]
66 | void FactTest()
67 | => Assert.NotNull(Package.GetGlobalService(typeof(SVsWebBrowsingService)));
68 |
69 | [VsTheory]
70 | [InlineData(123)]
71 | void TheoryTest(int n)
72 | {
73 | Assert.NotNull(Package.GetGlobalService(typeof(SVsWebBrowsingService)));
74 | Assert.Equal(123, n);
75 | }
76 | }
77 | }
78 |
79 | ```
80 |
81 | ### Configuring how tests run
82 |
83 | All the settings are located in [ITestSettings](src/VsixTesting/ITestSettings.cs) and are implemented by 3 attributes:
84 |
85 | * `[VsTestSettings]` for classes/collections/assemblies
86 | * `[VsFact]` and `[VsTheory]` for methods
87 |
88 | Intellisense should be used to read the documentation for each property that can be set.
89 |
90 | ## License
91 |
92 | This repository is licensed with the Apache, Version 2.0 license.
93 |
--------------------------------------------------------------------------------
/VsixTesting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/josetr/VsixTesting/11500eb0b91ae5bd06b1448f2392891fd3a67906/VsixTesting.png
--------------------------------------------------------------------------------
/VsixTesting.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27703.2018
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{57DC6192-9049-4023-B6B8-F0587F704BFE}"
7 | ProjectSection(SolutionItems) = preProject
8 | .gitattributes = .gitattributes
9 | .gitignore = .gitignore
10 | appveyor.yml = appveyor.yml
11 | Directory.Build.props = Directory.Build.props
12 | Directory.Build.targets = Directory.Build.targets
13 | key.snk = key.snk
14 | LICENSE.md = LICENSE.md
15 | .github\workflows\main.yaml = .github\workflows\main.yaml
16 | NuGet.Config = NuGet.Config
17 | README.md = README.md
18 | stylecop.json = stylecop.json
19 | version.json = version.json
20 | VsixTesting.png = VsixTesting.png
21 | EndProjectSection
22 | EndProject
23 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VsixTesting.Installer", "src\VsixTesting.Installer\VsixTesting.Installer.csproj", "{51DB3A8A-C551-4D8D-A7A5-FCA2B76DE4B1}"
24 | EndProject
25 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VsixTesting.Xunit", "src\VsixTesting.Xunit\VsixTesting.Xunit.csproj", "{5B2D4187-0A44-4FD1-9B17-4D090F0001D3}"
26 | ProjectSection(ProjectDependencies) = postProject
27 | {1E08940F-AF0E-47F4-AFE6-34DEFF0C44FE} = {1E08940F-AF0E-47F4-AFE6-34DEFF0C44FE}
28 | {51DB3A8A-C551-4D8D-A7A5-FCA2B76DE4B1} = {51DB3A8A-C551-4D8D-A7A5-FCA2B76DE4B1}
29 | EndProjectSection
30 | EndProject
31 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VsixTesting.Invoker", "src\VsixTesting.Invoker\VsixTesting.Invoker.csproj", "{1E08940F-AF0E-47F4-AFE6-34DEFF0C44FE}"
32 | EndProject
33 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VsixTesting", "src\VsixTesting\VsixTesting.csproj", "{D592D582-B012-425E-8B4D-A2067D040363}"
34 | ProjectSection(ProjectDependencies) = postProject
35 | {1E08940F-AF0E-47F4-AFE6-34DEFF0C44FE} = {1E08940F-AF0E-47F4-AFE6-34DEFF0C44FE}
36 | {51DB3A8A-C551-4D8D-A7A5-FCA2B76DE4B1} = {51DB3A8A-C551-4D8D-A7A5-FCA2B76DE4B1}
37 | EndProjectSection
38 | EndProject
39 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VsixTesting.Xunit.Tests", "test\VsixTesting.Xunit.Tests\VsixTesting.Xunit.Tests.csproj", "{7367D06A-C4D7-48B8-8FFC-436568B45618}"
40 | EndProject
41 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VsixTesting.Tests", "test\VsixTesting.Tests\VsixTesting.Tests.csproj", "{BEBF4C01-C29C-49D7-93C3-234273940D1C}"
42 | EndProject
43 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VsixTesting.Installer.Tests", "test\VsixTesting.Installer.Tests\VsixTesting.Installer.Tests.csproj", "{C0291053-3322-41F2-8107-89381C1F67DC}"
44 | EndProject
45 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VsixTesting.Installer.x64", "src\VsixTesting.Installer\VsixTesting.Installer.x64.csproj", "{A2C44214-BB2E-4F86-A3B8-FB5F2ADB5A1E}"
46 | EndProject
47 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VsixTesting.Invoker.17", "src\VsixTesting.Invoker\17\VsixTesting.Invoker.17.csproj", "{1A3C5130-61DB-4DE0-85C0-30847F2807F6}"
48 | EndProject
49 | Global
50 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
51 | Debug|Any CPU = Debug|Any CPU
52 | Release|Any CPU = Release|Any CPU
53 | EndGlobalSection
54 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
55 | {51DB3A8A-C551-4D8D-A7A5-FCA2B76DE4B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
56 | {51DB3A8A-C551-4D8D-A7A5-FCA2B76DE4B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
57 | {51DB3A8A-C551-4D8D-A7A5-FCA2B76DE4B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
58 | {51DB3A8A-C551-4D8D-A7A5-FCA2B76DE4B1}.Release|Any CPU.Build.0 = Release|Any CPU
59 | {5B2D4187-0A44-4FD1-9B17-4D090F0001D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
60 | {5B2D4187-0A44-4FD1-9B17-4D090F0001D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
61 | {5B2D4187-0A44-4FD1-9B17-4D090F0001D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
62 | {5B2D4187-0A44-4FD1-9B17-4D090F0001D3}.Release|Any CPU.Build.0 = Release|Any CPU
63 | {1E08940F-AF0E-47F4-AFE6-34DEFF0C44FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
64 | {1E08940F-AF0E-47F4-AFE6-34DEFF0C44FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
65 | {1E08940F-AF0E-47F4-AFE6-34DEFF0C44FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
66 | {1E08940F-AF0E-47F4-AFE6-34DEFF0C44FE}.Release|Any CPU.Build.0 = Release|Any CPU
67 | {D592D582-B012-425E-8B4D-A2067D040363}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
68 | {D592D582-B012-425E-8B4D-A2067D040363}.Debug|Any CPU.Build.0 = Debug|Any CPU
69 | {D592D582-B012-425E-8B4D-A2067D040363}.Release|Any CPU.ActiveCfg = Release|Any CPU
70 | {D592D582-B012-425E-8B4D-A2067D040363}.Release|Any CPU.Build.0 = Release|Any CPU
71 | {7367D06A-C4D7-48B8-8FFC-436568B45618}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
72 | {7367D06A-C4D7-48B8-8FFC-436568B45618}.Debug|Any CPU.Build.0 = Debug|Any CPU
73 | {7367D06A-C4D7-48B8-8FFC-436568B45618}.Release|Any CPU.ActiveCfg = Release|Any CPU
74 | {7367D06A-C4D7-48B8-8FFC-436568B45618}.Release|Any CPU.Build.0 = Release|Any CPU
75 | {BEBF4C01-C29C-49D7-93C3-234273940D1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
76 | {BEBF4C01-C29C-49D7-93C3-234273940D1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
77 | {BEBF4C01-C29C-49D7-93C3-234273940D1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
78 | {BEBF4C01-C29C-49D7-93C3-234273940D1C}.Release|Any CPU.Build.0 = Release|Any CPU
79 | {C0291053-3322-41F2-8107-89381C1F67DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
80 | {C0291053-3322-41F2-8107-89381C1F67DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
81 | {C0291053-3322-41F2-8107-89381C1F67DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
82 | {C0291053-3322-41F2-8107-89381C1F67DC}.Release|Any CPU.Build.0 = Release|Any CPU
83 | {A2C44214-BB2E-4F86-A3B8-FB5F2ADB5A1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
84 | {A2C44214-BB2E-4F86-A3B8-FB5F2ADB5A1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
85 | {A2C44214-BB2E-4F86-A3B8-FB5F2ADB5A1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
86 | {A2C44214-BB2E-4F86-A3B8-FB5F2ADB5A1E}.Release|Any CPU.Build.0 = Release|Any CPU
87 | {1A3C5130-61DB-4DE0-85C0-30847F2807F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
88 | {1A3C5130-61DB-4DE0-85C0-30847F2807F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
89 | {1A3C5130-61DB-4DE0-85C0-30847F2807F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
90 | {1A3C5130-61DB-4DE0-85C0-30847F2807F6}.Release|Any CPU.Build.0 = Release|Any CPU
91 | EndGlobalSection
92 | GlobalSection(SolutionProperties) = preSolution
93 | HideSolutionNode = FALSE
94 | EndGlobalSection
95 | GlobalSection(ExtensibilityGlobals) = postSolution
96 | SolutionGuid = {EEA30FC1-DE80-4F3A-A71A-FE28650D0700}
97 | EndGlobalSection
98 | EndGlobal
99 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | image: Visual Studio 2017
2 | configuration: Release
3 | platform: Any CPU
4 | version: 0.0.{build}
5 | skip_branch_with_pr: true
6 |
7 | install:
8 | - mkdir artifacts
9 | - dotnet tool install -g nbgv --version 3.4.255
10 | - nbgv cloud --all-vars
11 | - msbuild src/VsixTesting.Xunit /t:restore /v:m /nologo
12 | - msbuild src/VsixTesting.Xunit /v:m /nologo
13 | - msbuild /t:restore /v:m /nologo
14 |
15 | build_script:
16 | - msbuild /v:m /nologo
17 |
18 | deploy:
19 | provider: NuGet
20 | server: https://www.myget.org/F/vsixtesting/api/v2/package
21 | api_key:
22 | secure: 7fpFGKl529yWoO7qD5t+quDen2GSeUfdsuGOYH3zMSI/nwDEY9bvyiOl/xOoaajX
23 | artifact: /.*\.nupkg/
24 |
25 | artifacts:
26 | - path: 'artifacts/*.TestResults.xml'
27 | - path: 'artifacts/*.nupkg'
28 |
29 | test_script:
30 | - msbuild /t:test
31 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | coverage:
2 | status:
3 | patch: no
4 |
--------------------------------------------------------------------------------
/key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/josetr/VsixTesting/11500eb0b91ae5bd06b1448f2392891fd3a67906/key.snk
--------------------------------------------------------------------------------
/src/VsixTesting.Installer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | using System.Runtime.CompilerServices;
4 |
5 | [assembly: InternalsVisibleTo("VsixTesting.Installer.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d55b6b77e75142dc724b2e721fcddb95564623d7404f5c98bd595ca11c8e2ee1bcd63f46c24e446be029895312590edf9eb489e9ad5d10442a3ef87b965cc7f8400d829f68b8c8ee8a2c90901b5fb9d38acb0d82c8aae828390b8ff2d21bea1be6b296c3ba41bc57852c18784c7e6c078f2e48ee9b40af8353023ed6667afbb3")]
6 |
--------------------------------------------------------------------------------
/src/VsixTesting.Installer/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "VsixTesting.Installer.Install": {
4 | "commandName": "Project",
5 | "commandLineArgs": "/ApplicationPath \"$(DevEnvDir)devenv.exe\" /RootSuffix Exp /Install \"$(SolutionDir)bin\\VsixTesting.Invoker\\$(Configuration)\\net452\\VsixTesting.Invoker.vsix\""
6 | },
7 | "VsixTesting.Installer.InstallAndStart": {
8 | "commandName": "Project",
9 | "commandLineArgs": "/ApplicationPath \"$(DevEnvDir)devenv.exe\" /RootSuffix Exp /InstallAndStart \"$(SolutionDir)bin\\VsixTesting.Invoker\\$(Configuration)\\net452\\VsixTesting.Invoker.vsix\""
10 | },
11 | "VsixTesting.Installer.Uninstall": {
12 | "commandName": "Project",
13 | "commandLineArgs": "/ApplicationPath \"$(DevEnvDir)devenv.exe\" /RootSuffix Exp /Uninstall 9eef3d53-333f-4be2-900e-a1f104fc325a"
14 | },
15 | "VsixTesting.Installer.IsProfileInitialized": {
16 | "commandName": "Project",
17 | "commandLineArgs": "/ApplicationPath \"$(DevEnvDir)devenv.exe\" /RootSuffix Exp /IsProfileInitialized"
18 | },
19 | "VsixTesting.Installer.2012.Install": {
20 | "commandName": "Project",
21 | "commandLineArgs": "/ApplicationPath \"C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\IDE\\devenv.exe\" /RootSuffix Exp /Install \"$(SolutionDir)bin\\VsixTesting.Invoker\\$(Configuration)\\net452\\VsixTesting.Invoker.vsix\""
22 | },
23 | "VsixTesting.Installer.2012.InstallAndStart": {
24 | "commandName": "Project",
25 | "commandLineArgs": "/ApplicationPath \"C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\IDE\\devenv.exe\" /RootSuffix Exp /InstallAndStart \"$(SolutionDir)bin\\VsixTesting.Invoker\\$(Configuration)\\net452\\VsixTesting.Invoker.vsix\""
26 | },
27 | "VsixTesting.Installer.2012.Uninstall": {
28 | "commandName": "Project",
29 | "commandLineArgs": "/ApplicationPath \"C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\IDE\\devenv.exe\" /RootSuffix Exp /Uninstall 9eef3d53-333f-4be2-900e-a1f104fc325a"
30 | },
31 | "VsixTesting.Installer.2012.IsProfileInitialized": {
32 | "commandName": "Project",
33 | "commandLineArgs": "/ApplicationPath \"C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\IDE\\devenv.exe\" /RootSuffix Exp /IsProfileInitialized"
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/src/VsixTesting.Installer/References/Microsoft.VisualStudio.ExtensionManager.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/josetr/VsixTesting/11500eb0b91ae5bd06b1448f2392891fd3a67906/src/VsixTesting.Installer/References/Microsoft.VisualStudio.ExtensionManager.dll
--------------------------------------------------------------------------------
/src/VsixTesting.Installer/VsixTesting.Installer.Common.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net452
4 | Exe
5 | true
6 | true
7 | VisualStudio, Extension, Installer, VSIXInstaller
8 | Command Line Utility for installing Visual Studio Extensions.
9 | false
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | References/Microsoft.VisualStudio.ExtensionManager.dll
26 | false
27 | False
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/VsixTesting.Installer/VsixTesting.Installer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(Title) Installer
6 | $(PackageTags), VSIX Installer, Installer
7 | true
8 | true
9 | true
10 | true
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/VsixTesting.Installer/VsixTesting.Installer.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | $(MSBuildThisFileDirectory)../tools/VsixTesting.Installer.exe
4 | $(MSBuildThisFileDirectory)../tools/VsixTesting.Installer.x64.exe
5 |
6 |
--------------------------------------------------------------------------------
/src/VsixTesting.Installer/VsixTesting.Installer.x64.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | false
6 |
7 |
--------------------------------------------------------------------------------
/src/VsixTesting.Invoker/17/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "VsixTesting.Invoker": {
4 | "commandName": "Executable",
5 | "executablePath": "$(DevEnvDir)devenv.exe",
6 | "commandLineArgs": "/rootSuffix Exp"
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/src/VsixTesting.Invoker/17/VsixTesting.Invoker.17.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/VsixTesting.Invoker/17/source.extension.vsixmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | VsixTesting.Invoker
6 | VsixTesting.Invoker
7 | VsixTesting.Invoker
8 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/VsixTesting.Invoker/InvokerPackage.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.Invoker
4 | {
5 | using System;
6 | using Microsoft.VisualStudio;
7 | using Microsoft.VisualStudio.Shell;
8 |
9 | [PackageRegistration(UseManagedResourcesOnly = true)]
10 | [ProvideAutomationObject(AutomationObjectName)]
11 | #if false
12 | [ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExists_string)]
13 | [ProvideAutoLoad(VSConstants.UICONTEXT.NoSolution_string)]
14 | #endif
15 | public sealed class InvokerPackage : Package
16 | {
17 | private const string AutomationObjectName = "VsixTesting.Invoker";
18 | private Lazy automationObject = new Lazy(() => new InvokerService());
19 |
20 | protected sealed override object GetAutomationObject(string name)
21 | {
22 | if (name == AutomationObjectName)
23 | return automationObject.Value;
24 | return base.GetAutomationObject(name);
25 | }
26 |
27 | #if false
28 | protected override void Initialize()
29 | => base.Initialize();
30 | #endif
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/VsixTesting.Invoker/InvokerService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.Invoker
4 | {
5 | using System;
6 | using System.Reflection;
7 |
8 | public class InvokerService
9 | {
10 | public object InvokeMethod(string assemblyPath, string @class, string method, object obj, params object[] arguments)
11 | {
12 | var assembly = Assembly.LoadFrom(assemblyPath);
13 | var assemblyPublicKey = BitConverter.ToString(assembly.GetName().GetPublicKey()).Replace("-", string.Empty);
14 |
15 | if (assemblyPublicKey.Equals("0024000004800000940000000602000000240000525341310004000001000100d55b6b77e75142dc724b2e721fcddb95564623d7404f5c98bd595ca11c8e2ee1bcd63f46c24e446be029895312590edf9eb489e9ad5d10442a3ef87b965cc7f8400d829f68b8c8ee8a2c90901b5fb9d38acb0d82c8aae828390b8ff2d21bea1be6b296c3ba41bc57852c18784c7e6c078f2e48ee9b40af8353023ed6667afbb3", StringComparison.OrdinalIgnoreCase))
16 | {
17 | return assembly
18 | .GetType(@class)
19 | .GetMethod(method, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)
20 | .Invoke(obj, arguments);
21 | }
22 |
23 | return null;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/VsixTesting.Invoker/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "VsixTesting.Invoker": {
4 | "commandName": "Executable",
5 | "executablePath": "$(DevEnvDir)devenv.exe",
6 | "commandLineArgs": "/rootSuffix Exp"
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/src/VsixTesting.Invoker/VsixTesting.Invoker.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | False
7 | net452
8 | false
9 |
10 |
11 |
12 | false
13 |
14 |
15 |
16 | true
17 | true
18 | true
19 | false
20 | false
21 | true
22 | true
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/src/VsixTesting.Invoker/source.extension.vsixmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | VsixTesting.Invoker
6 | VsixTesting.Invoker
7 | VsixTesting.Invoker
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Instances.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting
4 | {
5 | using Xunit;
6 |
7 | internal class Instances
8 | {
9 | [Fact]
10 | public void VisualStudio()
11 | {
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/RemoteTestAssemblyRunner.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 | #pragma warning disable SA1202 // Elements should be ordered by access
3 |
4 | namespace VsixTesting.XunitX.Internal
5 | {
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Linq;
9 | using System.Threading;
10 | using System.Threading.Tasks;
11 | using VsixTesting.XunitX.Internal.Utilities;
12 | using Xunit.Abstractions;
13 | using Xunit.Sdk;
14 |
15 | internal sealed class RemoteTestAssemblyRunner : LongLivedMarshalByRefObject, IDisposable
16 | {
17 | private readonly XunitTestAssemblyRunner runner;
18 |
19 | public RemoteTestAssemblyRunner(ITestAssembly testAssembly, IEnumerable testCases, IMessageSink diagnosticMessageSink, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions, IMessageBus messageBus)
20 | {
21 | runner = new RealTestAssemblyRunner(testAssembly, testCases, diagnosticMessageSink, executionMessageSink, executionOptions, messageBus);
22 | }
23 |
24 | public SerializableRunSummary Run()
25 | {
26 | var result = runner.RunAsync().GetAwaiter().GetResult();
27 | return new SerializableRunSummary
28 | {
29 | Total = result.Total,
30 | Failed = result.Failed,
31 | Skipped = result.Skipped,
32 | Time = result.Time,
33 | };
34 | }
35 |
36 | public void Dispose() => runner.Dispose();
37 |
38 | private class RealTestAssemblyRunner : XunitTestAssemblyRunner
39 | {
40 | private readonly IMessageBus messageBus;
41 |
42 | public RealTestAssemblyRunner(ITestAssembly testAssembly, IEnumerable testCases, IMessageSink diagnosticMessageSink, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions, IMessageBus messageBus)
43 | : base(testAssembly, testCases, diagnosticMessageSink, executionMessageSink, executionOptions)
44 | {
45 | this.messageBus = messageBus;
46 | }
47 |
48 | protected override IMessageBus CreateMessageBus()
49 | {
50 | return messageBus;
51 | }
52 |
53 | protected override Task RunTestCollectionAsync(IMessageBus messageBus, ITestCollection testCollection, IEnumerable testCases, CancellationTokenSource cancellationTokenSource)
54 | {
55 | testCases = testCases.Cast().Select(tc => VsTestCaseBase.DeserializeFromString(tc.SerializeToString()));
56 | return base.RunTestCollectionAsync(messageBus, testCollection, testCases, cancellationTokenSource);
57 | }
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/Utilities/ExceptionRunner.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal.Utilities
4 | {
5 | using System;
6 | using System.Threading;
7 | using System.Threading.Tasks;
8 | using Xunit.Sdk;
9 |
10 | internal class ExceptionRunner : TestCaseRunner
11 | {
12 | private readonly Exception exception;
13 | private readonly string[] exceptionTypes;
14 | private readonly string[] exceptionMessages;
15 | private readonly string[] exceptionStackTraces;
16 | private readonly int[] exceptionParenIndices;
17 | private readonly string output;
18 |
19 | public ExceptionRunner(IXunitTestCase testCase, Exception exception, string output, IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
20 | : base(testCase, messageBus, aggregator, cancellationTokenSource)
21 | {
22 | this.exception = exception;
23 | this.output = output;
24 | }
25 |
26 | public ExceptionRunner(IXunitTestCase testCase, string[] exceptionTypes, string[] exceptionMessages, string[] exceptionStackTraces, int[] exceptionParenIndices, string output, IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
27 | : base(testCase, messageBus, aggregator, cancellationTokenSource)
28 | {
29 | this.exceptionTypes = exceptionTypes;
30 | this.exceptionMessages = exceptionMessages;
31 | this.exceptionStackTraces = exceptionStackTraces;
32 | this.exceptionParenIndices = exceptionParenIndices;
33 | this.output = output;
34 | }
35 |
36 | protected override Task RunTestAsync()
37 | {
38 | var test = new XunitTest(TestCase, TestCase.DisplayName);
39 | var summary = new RunSummary { Total = 1 };
40 |
41 | if (!MessageBus.QueueMessage(new TestStarting(test)))
42 | CancellationTokenSource.Cancel();
43 | else
44 | {
45 | if (!string.IsNullOrEmpty(TestCase.SkipReason))
46 | {
47 | summary.Skipped = 1;
48 |
49 | if (!MessageBus.QueueMessage(new TestSkipped(test, TestCase.SkipReason)))
50 | CancellationTokenSource.Cancel();
51 | }
52 | else
53 | {
54 | summary.Failed = 1;
55 |
56 | if (!MessageBus.QueueMessage(exception != null
57 | ? new TestFailed(test, 0, output, exception)
58 | : new TestFailed(test, 0, output, exceptionTypes, exceptionMessages, exceptionStackTraces, exceptionParenIndices)))
59 | {
60 | CancellationTokenSource.Cancel();
61 | }
62 | }
63 |
64 | if (!MessageBus.QueueMessage(new TestFinished(test, 0, output)))
65 | CancellationTokenSource.Cancel();
66 | }
67 |
68 | return Task.FromResult(summary);
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/Utilities/ExceptionTestCase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal.Utilities
4 | {
5 | using System;
6 | using System.Collections.Generic;
7 | using System.ComponentModel;
8 | using System.Linq;
9 | using System.Threading;
10 | using System.Threading.Tasks;
11 | using Vs;
12 | using Xunit.Abstractions;
13 | using Xunit.Sdk;
14 |
15 | internal class ExceptionTestCase : XunitTestCase
16 | {
17 | [EditorBrowsable(EditorBrowsableState.Never)]
18 | [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")]
19 | public ExceptionTestCase()
20 | {
21 | }
22 |
23 | public ExceptionTestCase(Exception exception, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod)
24 | : base(diagnosticMessageSink, defaultMethodDisplay, testMethod)
25 | {
26 | var finfo = ExceptionUtility.ConvertExceptionToFailureInformation(exception);
27 | Types = finfo.ExceptionTypes;
28 | Messages = finfo.Messages;
29 | StackTraces = finfo.StackTraces;
30 | ParentIndices = finfo.ExceptionParentIndices;
31 | }
32 |
33 | internal string[] Types { get; private set; }
34 | internal string[] Messages { get; private set; }
35 | internal string[] StackTraces { get; private set; }
36 | internal int[] ParentIndices { get; private set; }
37 |
38 | public override void Serialize(IXunitSerializationInfo data)
39 | {
40 | base.Serialize(data);
41 | data.AddValue("ExceptionTypes", Types);
42 | data.AddValue("ExceptionMessages", Messages);
43 | data.AddValue("ExceptionStackTraces", StackTraces);
44 | data.AddValue("ExceptionParentIndices", ParentIndices);
45 | }
46 |
47 | public override void Deserialize(IXunitSerializationInfo data)
48 | {
49 | base.Deserialize(data);
50 | Types = data.GetValue("ExceptionTypes");
51 | Messages = data.GetValue("ExceptionMessages");
52 | StackTraces = data.GetValue("ExceptionStackTraces");
53 | ParentIndices = data.GetValue("ExceptionParentIndices");
54 | }
55 |
56 | public override Task RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
57 | {
58 | return new ExceptionRunner(this, Types, Messages, StackTraces, ParentIndices, string.Empty, messageBus, aggregator, cancellationTokenSource).RunAsync();
59 | }
60 |
61 | protected override void Initialize()
62 | {
63 | base.Initialize();
64 |
65 | try
66 | {
67 | var testSettings = VsTestSettingsUtil.FromTestMethod(TestMethod);
68 | var year = VersionUtil.GetYear(testSettings.SupportedVersionRanges.OrderBy(r => r.Minimum).First().Minimum);
69 | Traits[VsTestCaseBase.TraitKey] = new List(new[] { year + testSettings.RootSuffix });
70 | }
71 | catch
72 | {
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/Utilities/FakeException.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal.Utilities
4 | {
5 | using System;
6 |
7 | [Serializable]
8 | internal class FakeException : Exception
9 | {
10 | public FakeException()
11 | {
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/Utilities/IFinishedMessageExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal.Utilities
4 | {
5 | using Xunit.Abstractions;
6 | using Xunit.Sdk;
7 |
8 | internal static class IFinishedMessageExtensions
9 | {
10 | public static RunSummary ToRunSummary(this IFinishedMessage message)
11 | {
12 | return new RunSummary
13 | {
14 | Total = message.TestsRun,
15 | Failed = message.TestsFailed,
16 | Skipped = message.TestsSkipped,
17 | Time = message.ExecutionTime,
18 | };
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/Utilities/SerializableRunSummary.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal.Utilities
4 | {
5 | using System;
6 | using Xunit.Sdk;
7 |
8 | [Serializable]
9 | internal class SerializableRunSummary
10 | {
11 | public int Total { get; set; }
12 | public int Failed { get; set; }
13 | public int Skipped { get; set; }
14 | public decimal Time { get; set; }
15 |
16 | public static implicit operator RunSummary(SerializableRunSummary summary) => new RunSummary
17 | {
18 | Total = summary.Total,
19 | Failed = summary.Failed,
20 | Skipped = summary.Skipped,
21 | Time = summary.Time,
22 | };
23 | }
24 | }
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/VsInstanceTestCase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal
4 | {
5 | using System;
6 | using System.Collections.Generic;
7 | using System.ComponentModel;
8 | using System.Diagnostics;
9 | using System.Linq;
10 | using System.Threading;
11 | using System.Threading.Tasks;
12 | using Common;
13 | using Vs;
14 | using VsixTesting.Utilities;
15 | using VsixTesting.XunitX.Internal.Utilities;
16 | using Xunit.Abstractions;
17 | using Xunit.Sdk;
18 |
19 | internal class VsInstanceTestCase : VsTestCaseBase
20 | {
21 | [EditorBrowsable(EditorBrowsableState.Never)]
22 | [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")]
23 | public VsInstanceTestCase()
24 | {
25 | }
26 |
27 | public VsInstanceTestCase(string instanceId, string applicationPath, string rootSuffix, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod, object[] testMethodArguments = null)
28 | : base(instanceId, diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments)
29 | {
30 | ApplicationPath = applicationPath;
31 | RootSuffix = rootSuffix;
32 | DebugMixedMode = false;
33 | ExtensionDirectories = new HashSet();
34 | }
35 |
36 | public string ApplicationPath { get; private set; }
37 | public string RootSuffix { get; private set; }
38 | public bool DebugMixedMode { get; private set; }
39 | public HashSet ExtensionDirectories { get; private set; }
40 |
41 | public override void Serialize(IXunitSerializationInfo info)
42 | {
43 | base.Serialize(info);
44 | info.AddValue(nameof(ApplicationPath), ApplicationPath);
45 | info.AddValue(nameof(RootSuffix), RootSuffix);
46 | info.AddValue(nameof(DebugMixedMode), DebugMixedMode);
47 | info.AddValue(nameof(ExtensionDirectories), string.Join(";", ExtensionDirectories));
48 | }
49 |
50 | public override void Deserialize(IXunitSerializationInfo info)
51 | {
52 | base.Deserialize(info);
53 | ApplicationPath = info.GetValue(nameof(ApplicationPath));
54 | RootSuffix = info.GetValue(nameof(RootSuffix));
55 | DebugMixedMode = info.GetValue(nameof(DebugMixedMode));
56 | ExtensionDirectories = new HashSet(info.GetValue(nameof(ExtensionDirectories)).Split(';'));
57 | }
58 |
59 | public override Task RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
60 | => new ExceptionRunner(this, new NotImplementedException(), string.Empty, messageBus, aggregator, cancellationTokenSource).RunAsync();
61 |
62 | public async Task LaunchAndDebug(IMessageBus messageBus, CancellationTokenSource cancellationTokenSource)
63 | {
64 | await ThreadUtil.RunOnStaThreadAsync(async () =>
65 | {
66 | using (var retryFilter = new RetryMessageFilter())
67 | {
68 | var diagnostics = new VisualDiagnostics(this, DiagnosticMessageSink, messageBus, cancellationTokenSource);
69 | var extensionsToInstall = VsInstance.GetExtensionsToInstall(ExtensionDirectories);
70 | var installation = VisualStudioUtil.FindInstallations().First(i => i.ApplicationPath == ApplicationPath);
71 | var hive = new VsHive(installation, RootSuffix);
72 | await VsInstance.Prepare(hive, extensionsToInstall, resetSettings: false, diagnostics, installInvoker: false);
73 | var process = await diagnostics.RunAsync("Launching Instance", () => Task.FromResult(VisualStudioUtil.StartProcess(hive)));
74 | if (Debugger.IsAttached)
75 | await VsInstance.AttachDebugger(process, DebugMixedMode, diagnostics);
76 | }
77 | });
78 | }
79 |
80 | public void MergeSettings(ITestSettings settings)
81 | {
82 | ExtensionDirectories.Add(settings.ExtensionsDirectory);
83 | if (settings.DebugMixedMode)
84 | DebugMixedMode = true;
85 | }
86 |
87 | protected override string GetDisplayName(IAttributeInfo factAttribute, string displayName)
88 | => $"{TraitKey} [{TraitValue}]";
89 |
90 | protected override string GetUniqueID()
91 | => base.GetUniqueID() + "-" + InstanceId;
92 | }
93 | }
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/VsSkippedDataRowTestCase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal
4 | {
5 | using System;
6 | using System.ComponentModel;
7 | using Xunit.Abstractions;
8 | using Xunit.Sdk;
9 |
10 | internal class VsSkippedDataRowTestCase : VsTestCaseBase
11 | {
12 | private string skipReason;
13 |
14 | [EditorBrowsable(EditorBrowsableState.Never)]
15 | [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")]
16 | public VsSkippedDataRowTestCase()
17 | {
18 | }
19 |
20 | public VsSkippedDataRowTestCase(string instanceId, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod, string skipReason, object[] testMethodArguments = null)
21 | : base(instanceId, diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments)
22 | {
23 | this.skipReason = skipReason;
24 | }
25 |
26 | public override void Serialize(IXunitSerializationInfo info)
27 | {
28 | base.Serialize(info);
29 | info.AddValue("SkipReason", skipReason);
30 | }
31 |
32 | public override void Deserialize(IXunitSerializationInfo info)
33 | {
34 | base.Deserialize(info);
35 | skipReason = info.GetValue("SkipReason");
36 | }
37 |
38 | protected override string GetSkipReason(IAttributeInfo factAttribute)
39 | => skipReason;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/VsTestAssemblyRunner.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal
4 | {
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Threading;
8 | using System.Threading.Tasks;
9 | using Common;
10 | using VsixTesting.Utilities;
11 | using Xunit.Abstractions;
12 | using Xunit.Sdk;
13 |
14 | internal class VsTestAssemblyRunner : XunitTestAssemblyRunner
15 | {
16 | public VsTestAssemblyRunner(ITestAssembly testAssembly, IEnumerable testCases, IMessageSink diagnosticMessageSink, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions)
17 | : base(testAssembly, testCases, diagnosticMessageSink, executionMessageSink, executionOptions)
18 | {
19 | }
20 |
21 | private IEnumerable LocalTestCases => TestCases.Except(TestCases.OfType());
22 | private IEnumerable RemoteTestCases => TestCases.OfType().Except(TestCases.OfType());
23 |
24 | protected override async Task RunTestCollectionsAsync(IMessageBus messageBus, CancellationTokenSource cancellationTokenSource)
25 | {
26 | var result = await Local_RunTestCasesAsync(LocalTestCases, messageBus, cancellationTokenSource);
27 |
28 | foreach (var remoteTestCases in RemoteTestCases.GroupBy(tc => tc.InstanceId).OrderBy(g => g.Key))
29 | result.Aggregate(await Remote_RunTestCasesAsync(remoteTestCases.Key, remoteTestCases, messageBus, cancellationTokenSource));
30 |
31 | foreach (var instanceTestCase in TestCases.OfType())
32 | {
33 | if (!RemoteTestCases.Any(tc => tc.InstanceId == instanceTestCase.InstanceId))
34 | await instanceTestCase.LaunchAndDebug(messageBus, cancellationTokenSource);
35 | }
36 |
37 | return result;
38 | }
39 |
40 | private async Task Local_RunTestCasesAsync(IEnumerable testCases, IMessageBus messageBus, CancellationTokenSource cancellationTokenSource)
41 | {
42 | var allTestCases = TestCases;
43 | TestCases = testCases;
44 | var result = await base.RunTestCollectionsAsync(messageBus, cancellationTokenSource);
45 | TestCases = allTestCases;
46 | return result;
47 | }
48 |
49 | private async Task Remote_RunTestCasesAsync(string instanceId, IEnumerable testCases, IMessageBus messageBus, CancellationTokenSource cancellationTokenSource)
50 | {
51 | if (testCases.All(tc => !string.IsNullOrEmpty(tc.SkipReason)))
52 | return await Local_RunTestCasesAsync(testCases, messageBus, cancellationTokenSource);
53 |
54 | var instanceTestCase = TestCases.OfType().FirstOrDefault(tc => tc.InstanceId == instanceId);
55 |
56 | return await ThreadUtil.RunOnStaThreadAsync(async () =>
57 | {
58 | var runner = new VsInstanceTestAssemblyRunner(TestAssembly, testCases, instanceTestCase, DiagnosticMessageSink, ExecutionMessageSink, ExecutionOptions, () => CreateMessageBus(), Aggregator);
59 |
60 | try
61 | {
62 | using (var retryFilter = new RetryMessageFilter())
63 | {
64 | return await runner.RunAsync(cancellationTokenSource);
65 | }
66 | }
67 | finally
68 | {
69 | await runner.DisposeAsync();
70 | }
71 | });
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/VsTestCase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal
4 | {
5 | using System;
6 | using System.ComponentModel;
7 | using System.Threading;
8 | using System.Threading.Tasks;
9 | using Xunit.Abstractions;
10 | using Xunit.Sdk;
11 |
12 | internal class VsTestCase : VsTestCaseBase
13 | {
14 | [EditorBrowsable(EditorBrowsableState.Never)]
15 | [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")]
16 | public VsTestCase()
17 | {
18 | }
19 |
20 | public VsTestCase(string instanceId, string instancePath, VsTestSettings testSettings, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod, object[] testMethodArguments = null)
21 | : base(instanceId, diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments)
22 | {
23 | InstancePath = instancePath;
24 | Settings = testSettings;
25 | }
26 |
27 | public string InstancePath { get; private set; }
28 | public VsTestSettings Settings { get; private set; }
29 |
30 | public override Task RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
31 | => new VsTestCaseRunner(this, DisplayName, SkipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, cancellationTokenSource).RunAsync();
32 |
33 | public override void Serialize(IXunitSerializationInfo info)
34 | {
35 | base.Serialize(info);
36 | info.AddValue(nameof(InstancePath), InstancePath);
37 | }
38 |
39 | public override void Deserialize(IXunitSerializationInfo info)
40 | {
41 | base.Deserialize(info);
42 | InstancePath = info.GetValue(nameof(InstancePath));
43 | Settings = VsTestSettingsUtil.FromTestMethod(TestMethod);
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/VsTestCaseBase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal
4 | {
5 | using System;
6 | using System.Collections.Generic;
7 | using System.ComponentModel;
8 | using Xunit.Abstractions;
9 | using Xunit.Internal;
10 | using Xunit.Sdk;
11 |
12 | internal class VsTestCaseBase : XunitTestCase
13 | {
14 | [EditorBrowsable(EditorBrowsableState.Never)]
15 | [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")]
16 | public VsTestCaseBase()
17 | {
18 | }
19 |
20 | public VsTestCaseBase(string instanceId, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod, object[] testMethodArguments = null)
21 | : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments)
22 | {
23 | InstanceId = instanceId;
24 | }
25 |
26 | public string InstanceId { get; private set; }
27 | internal static string TraitKey => "VisualStudio";
28 | protected string TraitValue => InstanceId.Replace(" ", string.Empty);
29 |
30 | public override void Serialize(IXunitSerializationInfo info)
31 | {
32 | base.Serialize(info);
33 | info.AddValue(nameof(InstanceId), InstanceId);
34 | }
35 |
36 | public override void Deserialize(IXunitSerializationInfo info)
37 | {
38 | base.Deserialize(info);
39 | InstanceId = info.GetValue(nameof(InstanceId));
40 | }
41 |
42 | public string SerializeToString()
43 | {
44 | var triple = new XunitSerializationTriple(nameof(VsTestCaseBase), this, GetType());
45 | return XunitSerializationInfo.SerializeTriple(triple);
46 | }
47 |
48 | public static VsTestCaseBase DeserializeFromString(string value)
49 | {
50 | var triple = XunitSerializationInfo.DeserializeTriple(value);
51 | return (VsTestCaseBase)triple.Value;
52 | }
53 |
54 | protected override string GetDisplayName(IAttributeInfo factAttribute, string displayName)
55 | => base.GetDisplayName(factAttribute, displayName) + " - " + InstanceId;
56 |
57 | protected override string GetUniqueID()
58 | => base.GetUniqueID() + "-" + InstanceId;
59 |
60 | protected override void Initialize()
61 | {
62 | base.Initialize();
63 | Traits[TraitKey] = new List(new[] { TraitValue });
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/VsTestCaseRunner.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal
4 | {
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Reflection;
8 | using System.Threading;
9 | using Xunit.Abstractions;
10 | using Xunit.Sdk;
11 |
12 | internal class VsTestCaseRunner : XunitTestCaseRunner
13 | {
14 | public VsTestCaseRunner(IXunitTestCase testCase, string displayName, string skipReason, object[] constructorArguments, object[] testMethodArguments, IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
15 | : base(testCase, displayName, skipReason, constructorArguments, testMethodArguments, messageBus, aggregator, cancellationTokenSource)
16 | {
17 | }
18 |
19 | protected override XunitTestRunner CreateTestRunner(ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, IReadOnlyList beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
20 | => new VsTestRunner(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource);
21 | }
22 | }
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/VsTestFrameworkExecutor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal
4 | {
5 | using System.Collections.Generic;
6 | using System.Reflection;
7 | using Xunit.Abstractions;
8 | using Xunit.Sdk;
9 |
10 | internal class VsTestFrameworkExecutor : XunitTestFrameworkExecutor
11 | {
12 | public VsTestFrameworkExecutor(AssemblyName assemblyName, ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink)
13 | : base(assemblyName, sourceInformationProvider, diagnosticMessageSink)
14 | {
15 | }
16 |
17 | protected override async void RunTestCases(IEnumerable testCases, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions)
18 | {
19 | using (var assemblyRunner = new VsTestAssemblyRunner(TestAssembly, testCases, DiagnosticMessageSink, executionMessageSink, executionOptions))
20 | await assemblyRunner.RunAsync();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/VsTestInvoker.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal
4 | {
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Diagnostics;
8 | using System.IO;
9 | using System.Reflection;
10 | using System.Threading;
11 | using System.Windows;
12 | using VsixTesting.Utilities;
13 | using VsixTesting.XunitX.Internal.Utilities;
14 | using Xunit.Abstractions;
15 | using Xunit.Sdk;
16 |
17 | internal class VsTestInvoker : XunitTestInvoker
18 | {
19 | public VsTestInvoker(ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, IReadOnlyList beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
20 | : base(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, beforeAfterAttributes, aggregator, cancellationTokenSource)
21 | {
22 | }
23 |
24 | protected VsTestSettings Settings => ((VsTestCase)TestCase).Settings;
25 |
26 | protected override object CallTestMethod(object testClassInstance)
27 | {
28 | try
29 | {
30 | return TestMethod.Invoke(testClassInstance, TestMethodArguments);
31 | }
32 | catch (Exception e)
33 | {
34 | if (Settings.TakeScreenshotOnFailure)
35 | {
36 | try
37 | {
38 | TakeScreenShot(Test.DisplayName);
39 | }
40 | catch (Exception exception)
41 | {
42 | Aggregator.Add(exception);
43 | }
44 | }
45 |
46 | if (e is TargetInvocationException && e.InnerException is FakeException)
47 | return null;
48 |
49 | throw;
50 | }
51 | }
52 |
53 | private void TakeScreenShot(string name)
54 | {
55 | try
56 | {
57 | var safename = string.Join("_", name.Split(Path.GetInvalidFileNameChars()));
58 | var date = DateTime.Now.ToString("yyyy-MM-dd hh.mm.ss");
59 | var path = Path.Combine(Settings.ScreenshotsDirectory, $"{date} {safename}.png");
60 |
61 | Directory.CreateDirectory(Path.GetDirectoryName(path));
62 | ScreenshotUtil.CaptureWindow(Process.GetCurrentProcess().MainWindowHandle, path);
63 | }
64 | catch (Exception e)
65 | {
66 | Aggregator.Add(new Exception("Failed saving screenshot", e));
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/VsTestRunner.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal
4 | {
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Reflection;
8 | using System.Threading;
9 | using System.Threading.Tasks;
10 | using System.Windows;
11 | using System.Windows.Threading;
12 | using Xunit.Abstractions;
13 | using Xunit.Sdk;
14 |
15 | internal class VsTestRunner : XunitTestRunner
16 | {
17 | public VsTestRunner(ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, IReadOnlyList beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
18 | : base(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource)
19 | {
20 | }
21 |
22 | protected new VsTestCase TestCase => (VsTestCase)base.TestCase;
23 |
24 | protected override Task InvokeTestMethodAsync(ExceptionAggregator aggregator)
25 | {
26 | var result = TestCase.Settings.UIThread
27 | ? InvokeOnUIThreadAsync(aggregator)
28 | : InvokeAsync(aggregator);
29 |
30 | return result;
31 | }
32 |
33 | private Task InvokeOnUIThreadAsync(ExceptionAggregator aggregator)
34 | {
35 | var tcs = new TaskCompletionSource();
36 |
37 | Application.Current.Dispatcher.BeginInvoke(
38 | new Action(async () =>
39 | {
40 | try
41 | {
42 | var result = await InvokeAsync(aggregator);
43 | tcs.SetResult(result);
44 | }
45 | catch (Exception e)
46 | {
47 | tcs.SetException(e);
48 | }
49 | }), DispatcherPriority.Background);
50 |
51 | return tcs.Task;
52 | }
53 |
54 | private Task InvokeAsync(ExceptionAggregator aggregator)
55 | => new VsTestInvoker(Test, MessageBus, TestClass, ConstructorArguments, TestMethod, TestMethodArguments, BeforeAfterAttributes, aggregator, CancellationTokenSource).RunAsync();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/VsixTesting.Xunit/Internal/VsTestSettingsUtil.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Jose Torres. All rights reserved. Licensed under the Apache License, Version 2.0. See LICENSE.md file in the project root for full license information.
2 |
3 | namespace VsixTesting.XunitX.Internal
4 | {
5 | using System;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Reflection;
9 | using VsixTesting;
10 | using Xunit.Abstractions;
11 | using Xunit.Sdk;
12 |
13 | internal class VsTestSettingsUtil
14 | {
15 | public static VsTestSettings FromTestMethod(ITestMethod testMethod)
16 | {
17 | if (testMethod == null)
18 | throw new ArgumentNullException(nameof(TestMethod));
19 |
20 | var defaultDirectory = Path.GetDirectoryName(testMethod.TestClass.TestCollection.TestAssembly.Assembly.AssemblyPath);
21 | var defaults = VsTestSettings.Defaults;
22 |
23 | return new VsTestSettings()
24 | {
25 | Version = GetTestAttributeArgument(
26 | nameof(ITestSettings.Version), defaults.Version),
27 |
28 | RootSuffix = GetTestAttributeArgument(
29 | nameof(ITestSettings.RootSuffix), defaults.RootSuffix),
30 |
31 | DebugMixedMode = GetTestAttributeArgument(
32 | nameof(ITestSettings.DebugMixedMode), defaults.DebugMixedMode),
33 |
34 | SecureChannel = GetTestAttributeArgument(
35 | nameof(ITestSettings.SecureChannel), defaults.SecureChannel),
36 |
37 | ExtensionsDirectory = NormalizeDirectory(
38 | GetTestAttributeArgument(
39 | nameof(ITestSettings.ExtensionsDirectory),
40 | defaults.ExtensionsDirectory)),
41 |
42 | ScreenshotsDirectory = NormalizeDirectory(
43 | GetTestAttributeArgument(
44 | nameof(ITestSettings.ScreenshotsDirectory),
45 | defaults.ScreenshotsDirectory)),
46 |
47 | UIThread = GetTestAttributeArgument(
48 | nameof(ITestSettings.UIThread), defaults.UIThread),
49 |
50 | ReuseInstance = GetTestAttributeArgument(
51 | nameof(ITestSettings.ReuseInstance), defaults.ReuseInstance),
52 |
53 | TakeScreenshotOnFailure = GetTestAttributeArgument(
54 | nameof(ITestSettings.TakeScreenshotOnFailure), defaults.TakeScreenshotOnFailure),
55 | };
56 |
57 | TValue GetTestAttributeArgument(string argumentName, TValue defaultValue)
58 | {
59 | var methodAttr = testMethod.Method.GetCustomAttributes(typeof(ITestSettings)).FirstOrDefault();
60 | if (methodAttr?.GetNamedArgument