Merge lp:~b-tfrje-j/nunit-vs-adapter/TFSAdaption into lp:nunit-vs-adapter

Proposed by Terje Sandstrom
Status: Merged
Merged at revision: 69
Proposed branch: lp:~b-tfrje-j/nunit-vs-adapter/TFSAdaption
Merge into: lp:nunit-vs-adapter
Diff against target: 1108 lines (+695/-302)
11 files modified
NUnitTestAdapter.vssscc (+10/-0)
src/NUnitTestAdapter/NUnitTestAdapter.csproj (+96/-98)
src/NUnitTestAdapter/NUnitTestAdapter.csproj.vspscc (+10/-0)
src/NUnitTestAdapter/NUnitTestExecutor.cs (+63/-55)
src/NUnitTestAdapter/TFSTestFilter.cs (+200/-0)
src/NUnitTestAdapterInstall/NUnitTestAdapterInstall.csproj.vspscc (+10/-0)
src/NUnitTestAdapterInstall/source.extension.vsixmanifest (+1/-1)
src/NUnitTestAdapterTests/Fakes/FakeRunContext.cs (+63/-57)
src/NUnitTestAdapterTests/NUnitTestAdapterTests.csproj (+96/-91)
src/NUnitTestAdapterTests/NUnitTestAdapterTests.csproj.vspscc (+10/-0)
src/NUnitTestAdapterTests/TestTFSBuild.cs (+136/-0)
To merge this branch: bzr merge lp:~b-tfrje-j/nunit-vs-adapter/TFSAdaption
Reviewer Review Type Date Requested Status
Charlie Poole Needs Fixing
Review via email: mp+140273@code.launchpad.net

Description of the change

Added code to implement Test Case Filtering as defined by TFS Build Test Runner. See linked bug for details.
Implemented mapping between NUnit Category and TFS TestCategory term, and NUnit Priority and TFS Priority.
FullyQualifiedName should also work for filtering.
Code made independent on using RTM or Update 1 version.

To post a comment you must log in.
Revision history for this message
Charlie Poole (charlie.poole) wrote :

This is a preliminary review based on reading the code. I have a few comments and questions and then I'll do an actual merge and check it out more closely.

1. You say you implemented mapping between "NUnit Priority" and TFS Priority. There is no NUnit Priority... can you explain?

2. Have you tested against RTM as well as Update 1?

3. The target framework for the adapter has been changed to .NET 4. I suspect this will prevent users from running tests targeting .NET 2.0 under 2.0. Have you tried this?

4. Some changes are hard to review in the diff because methods were moved to a new location and show up as entirely deleted and added. Nothing to do about it at this point, but something to remember.

5. Reading the code, it becomes obvious that we need to distinguish between NUnit and TFS filters by their name. I'll do some name changes when I merge it.

Charlie

review: Needs Information
Revision history for this message
Charlie Poole (charlie.poole) wrote :

I merged the changes into my working directory and built and ran it using VS2012 RTM. Found some issues:

1. TestFilterTests wouldn't compile because it uses the Traits property of TestCase and the Trait type. This needs to be done via reflection to maintain compatibility with RTM. See NavigationDataTests.cs for an example. I commented out the two tests affected in order to proceed further.

2. Discovery turns up 87 tests but no tests are run. An NullReferenceException is thrown in NUnitTestExecutor.AddTestCasesToMap() at line 148. Reversed order of two lines in the RunAssembly method as you suggested and got past that problem.

3. Now I have 15 failing tests in TestExecutionTests due to TestFixtureSetUp failure. It appears to occur when initializing the TFSFilter.

4. As a final test, I changed the target for the adapter project back to .NET 3.5. It won't compile. I assume that's why you changed it to target 4.0, but that won't do when running tests that target .NET 2.0 under 2.0. That was an early bug back when I had originally targeted .NET 4.5.

Charlie

review: Needs Fixing
41. By Terje Sandstrom

FIxed some issues

42. By Terje Sandstrom

Fixed minor issues

43. By Terje Sandstrom

Fixed reflection

Revision history for this message
Terje Sandstrom (b-tfrje-j) wrote :

I now pushed up version 43 with the issues below resolved.
The changed files you need to merge over is TFSTestFilter.cs and TestTFSBuild.cs

1. TestTFSBuild – changed use of Trait and TraitCollection to do this using reflection.
a. I have also added two more tests to cover the reflection code better.
2. TFSTestFilter.cs: Changed the methods TraitContains and PropertyValueProvider. The first now uses reflection, same way as you did, - I skipped the expression tree, it was just too much pain – and running on the build server I don’t think that performance overhead matters much. From the TFS log I can’t see anything significant there either. In a later update we can change this to use expression trees to gain some more speed.
a. The change in PropertyValueProvider is to allow for multiple traits with the same trait name. The spec says it should be allowed, and now it does. One of the new unit tests checks that it works.

I also switched the FW to 3.5 on the project and it compiled as it should. Also tested it on TFS build server Update 1

44. By Terje Sandstrom

Added check for RTM to tests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NUnitTestAdapter.sln'
2Binary files NUnitTestAdapter.sln 2012-02-15 18:56:30 +0000 and NUnitTestAdapter.sln 2012-12-20 20:51:21 +0000 differ
3=== added file 'NUnitTestAdapter.vssscc'
4--- NUnitTestAdapter.vssscc 1970-01-01 00:00:00 +0000
5+++ NUnitTestAdapter.vssscc 2012-12-20 20:51:21 +0000
6@@ -0,0 +1,10 @@
7+""
8+{
9+"FILE_VERSION" = "9237"
10+"ENLISTMENT_CHOICE" = "NEVER"
11+"PROJECT_FILE_RELATIVE_PATH" = ""
12+"NUMBER_OF_EXCLUDED_FILES" = "0"
13+"ORIGINAL_PROJECT_FILE_PATH" = ""
14+"NUMBER_OF_NESTED_PROJECTS" = "0"
15+"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT"
16+}
17
18=== modified file 'src/NUnitTestAdapter/NUnitTestAdapter.csproj'
19--- src/NUnitTestAdapter/NUnitTestAdapter.csproj 2012-12-18 04:26:03 +0000
20+++ src/NUnitTestAdapter/NUnitTestAdapter.csproj 2012-12-20 20:51:21 +0000
21@@ -1,99 +1,97 @@
22-<?xml version="1.0" encoding="utf-8"?>
23-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
24- <PropertyGroup>
25- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
26- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
27- <ProductVersion>8.0.30703</ProductVersion>
28- <SchemaVersion>2.0</SchemaVersion>
29- <ProjectGuid>{8A85E26A-C706-48B1-BC36-06EBDE3EFD25}</ProjectGuid>
30- <OutputType>Library</OutputType>
31- <AppDesignerFolder>Properties</AppDesignerFolder>
32- <RootNamespace>NUnit.VisualStudio.TestAdapter</RootNamespace>
33- <AssemblyName>NUnit.VisualStudio.TestAdapter</AssemblyName>
34- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
35- <FileAlignment>512</FileAlignment>
36- <TargetFrameworkProfile />
37- </PropertyGroup>
38- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
39- <DebugSymbols>true</DebugSymbols>
40- <DebugType>full</DebugType>
41- <Optimize>false</Optimize>
42- <OutputPath>bin\Debug\</OutputPath>
43- <DefineConstants>TRACE;DEBUG</DefineConstants>
44- <ErrorReport>prompt</ErrorReport>
45- <WarningLevel>4</WarningLevel>
46- <Prefer32Bit>false</Prefer32Bit>
47- </PropertyGroup>
48- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
49- <DebugType>pdbonly</DebugType>
50- <Optimize>true</Optimize>
51- <OutputPath>bin\Release\</OutputPath>
52- <DefineConstants>TRACE</DefineConstants>
53- <ErrorReport>prompt</ErrorReport>
54- <WarningLevel>4</WarningLevel>
55- <Prefer32Bit>false</Prefer32Bit>
56- </PropertyGroup>
57- <PropertyGroup>
58- <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
59- </PropertyGroup>
60- <PropertyGroup>
61- <SignAssembly>true</SignAssembly>
62- </PropertyGroup>
63- <PropertyGroup>
64- <AssemblyOriginatorKeyFile>NUnitAdapter.snk</AssemblyOriginatorKeyFile>
65- </PropertyGroup>
66- <PropertyGroup>
67- <DelaySign>false</DelaySign>
68- </PropertyGroup>
69- <ItemGroup>
70- <Reference Include="Microsoft.VisualStudio.TestPlatform.ObjectModel">
71- <HintPath>C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll</HintPath>
72- </Reference>
73- <Reference Include="nunit.core, Version=2.6.2.12295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
74- <SpecificVersion>False</SpecificVersion>
75- <HintPath>..\..\lib\nunit.core.dll</HintPath>
76- </Reference>
77- <Reference Include="nunit.core.interfaces, Version=2.6.2.12295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
78- <SpecificVersion>False</SpecificVersion>
79- <HintPath>..\..\lib\nunit.core.interfaces.dll</HintPath>
80- </Reference>
81- <Reference Include="nunit.util, Version=2.6.2.12295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
82- <SpecificVersion>False</SpecificVersion>
83- <HintPath>..\..\lib\nunit.util.dll</HintPath>
84- </Reference>
85- <Reference Include="System" />
86- <Reference Include="System.Data" />
87- <Reference Include="System.Xml" />
88- </ItemGroup>
89- <ItemGroup>
90- <Compile Include="Internal\Stackframe.cs" />
91- <Compile Include="Internal\StackframeParser.cs" />
92- <Compile Include="Internal\Stacktrace.cs" />
93- <Compile Include="NUnitEventListener.cs" />
94- <Compile Include="NUnitTestAdapter.cs" />
95- <Compile Include="NUnitTestDiscoverer.cs" />
96- <Compile Include="NUnitTestExecutor.cs" />
97- <Compile Include="Properties\AssemblyInfo.cs" />
98- <Compile Include="StackTraceFilter.cs" />
99- <Compile Include="TestConverter.cs" />
100- <Compile Include="TestRunFilter.cs" />
101- </ItemGroup>
102- <ItemGroup>
103- <WCFMetadata Include="Service References\" />
104- </ItemGroup>
105- <ItemGroup>
106- <None Include="NUnitAdapter.snk" />
107- </ItemGroup>
108- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
109- <PropertyGroup>
110- <PostBuildEvent>
111- </PostBuildEvent>
112- </PropertyGroup>
113- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
114- Other similar extension points exist, see Microsoft.Common.targets.
115- <Target Name="BeforeBuild">
116- </Target>
117- <Target Name="AfterBuild">
118- </Target>
119- -->
120+<?xml version="1.0" encoding="utf-8"?>
121+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
122+ <PropertyGroup>
123+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
124+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
125+ <ProductVersion>8.0.30703</ProductVersion>
126+ <SchemaVersion>2.0</SchemaVersion>
127+ <ProjectGuid>{8A85E26A-C706-48B1-BC36-06EBDE3EFD25}</ProjectGuid>
128+ <OutputType>Library</OutputType>
129+ <AppDesignerFolder>Properties</AppDesignerFolder>
130+ <RootNamespace>NUnit.VisualStudio.TestAdapter</RootNamespace>
131+ <AssemblyName>NUnit.VisualStudio.TestAdapter</AssemblyName>
132+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
133+ <FileAlignment>512</FileAlignment>
134+ <TargetFrameworkProfile />
135+ <SccProjectName>SAK</SccProjectName>
136+ <SccLocalPath>SAK</SccLocalPath>
137+ <SccAuxPath>SAK</SccAuxPath>
138+ <SccProvider>SAK</SccProvider>
139+ </PropertyGroup>
140+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
141+ <DebugSymbols>true</DebugSymbols>
142+ <DebugType>full</DebugType>
143+ <Optimize>false</Optimize>
144+ <OutputPath>bin\Debug\</OutputPath>
145+ <DefineConstants>TRACE;DEBUG</DefineConstants>
146+ <ErrorReport>prompt</ErrorReport>
147+ <WarningLevel>4</WarningLevel>
148+ <Prefer32Bit>false</Prefer32Bit>
149+ </PropertyGroup>
150+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
151+ <DebugType>pdbonly</DebugType>
152+ <Optimize>true</Optimize>
153+ <OutputPath>bin\Release\</OutputPath>
154+ <DefineConstants>TRACE</DefineConstants>
155+ <ErrorReport>prompt</ErrorReport>
156+ <WarningLevel>4</WarningLevel>
157+ <Prefer32Bit>false</Prefer32Bit>
158+ </PropertyGroup>
159+ <PropertyGroup>
160+ <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
161+ </PropertyGroup>
162+ <PropertyGroup>
163+ <SignAssembly>true</SignAssembly>
164+ </PropertyGroup>
165+ <PropertyGroup>
166+ <AssemblyOriginatorKeyFile>NUnitAdapter.snk</AssemblyOriginatorKeyFile>
167+ </PropertyGroup>
168+ <PropertyGroup>
169+ <DelaySign>false</DelaySign>
170+ </PropertyGroup>
171+ <ItemGroup>
172+ <Reference Include="Microsoft.VisualStudio.TestPlatform.ObjectModel">
173+ <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll</HintPath>
174+ </Reference>
175+ <Reference Include="nunit.core, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
176+ <SpecificVersion>False</SpecificVersion>
177+ <HintPath>..\..\lib\nunit.core.dll</HintPath>
178+ </Reference>
179+ <Reference Include="nunit.core.interfaces, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
180+ <SpecificVersion>False</SpecificVersion>
181+ <HintPath>..\..\lib\nunit.core.interfaces.dll</HintPath>
182+ </Reference>
183+ <Reference Include="nunit.util, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
184+ <SpecificVersion>False</SpecificVersion>
185+ <HintPath>..\..\lib\nunit.util.dll</HintPath>
186+ </Reference>
187+ <Reference Include="System" />
188+ <Reference Include="System.Data" />
189+ <Reference Include="System.Xml" />
190+ </ItemGroup>
191+ <ItemGroup>
192+ <Compile Include="Internal\Stackframe.cs" />
193+ <Compile Include="Internal\StackframeParser.cs" />
194+ <Compile Include="Internal\Stacktrace.cs" />
195+ <Compile Include="NUnitEventListener.cs" />
196+ <Compile Include="NUnitTestAdapter.cs" />
197+ <Compile Include="NUnitTestDiscoverer.cs" />
198+ <Compile Include="NUnitTestExecutor.cs" />
199+ <Compile Include="Properties\AssemblyInfo.cs" />
200+ <Compile Include="StackTraceFilter.cs" />
201+ <Compile Include="TestConverter.cs" />
202+ <Compile Include="TestRunFilter.cs" />
203+ <Compile Include="TFSTestFilter.cs" />
204+ </ItemGroup>
205+ <ItemGroup>
206+ <WCFMetadata Include="Service References\" />
207+ </ItemGroup>
208+ <ItemGroup>
209+ <None Include="NUnitAdapter.snk" />
210+ </ItemGroup>
211+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
212+ <PropertyGroup>
213+ <PostBuildEvent>
214+ </PostBuildEvent>
215+ </PropertyGroup>
216 </Project>
217\ No newline at end of file
218
219=== added file 'src/NUnitTestAdapter/NUnitTestAdapter.csproj.vspscc'
220--- src/NUnitTestAdapter/NUnitTestAdapter.csproj.vspscc 1970-01-01 00:00:00 +0000
221+++ src/NUnitTestAdapter/NUnitTestAdapter.csproj.vspscc 2012-12-20 20:51:21 +0000
222@@ -0,0 +1,10 @@
223+""
224+{
225+"FILE_VERSION" = "9237"
226+"ENLISTMENT_CHOICE" = "NEVER"
227+"PROJECT_FILE_RELATIVE_PATH" = ""
228+"NUMBER_OF_EXCLUDED_FILES" = "0"
229+"ORIGINAL_PROJECT_FILE_PATH" = ""
230+"NUMBER_OF_NESTED_PROJECTS" = "0"
231+"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
232+}
233
234=== modified file 'src/NUnitTestAdapter/NUnitTestExecutor.cs'
235--- src/NUnitTestAdapter/NUnitTestExecutor.cs 2012-11-04 19:16:15 +0000
236+++ src/NUnitTestAdapter/NUnitTestExecutor.cs 2012-12-20 20:51:21 +0000
237@@ -29,6 +29,7 @@
238
239 #region ITestExecutor
240
241+ private bool isCalledFromTfsBuild;
242 /// <summary>
243 /// Called by the test platform to run all tests.
244 /// </summary>
245@@ -39,64 +40,37 @@
246 {
247 // Ensure any channels registered by other adapters are unregistered
248 CleanUpRegisteredChannels();
249-
250+ var tfsfilter = new TFSTestFilter(runContext);
251+ isCalledFromTfsBuild = tfsfilter.TfsTestCaseFilterExpression != null;
252 foreach (var source in sources)
253- {
254- RunAssembly(source, frameworkHandle, TestFilter.Empty);
255- }
256- }
257-
258- /// <summary>
259- /// Called by the TestPlatform when selected tests are to be run.
260- /// </summary>
261- /// <param name="selectedTests">The tests to be run</param>
262- /// <param name="runContext">The RunContext</param>
263- /// <param name="frameworkHandle">The FrameworkHandle</param>
264- public void RunTests(IEnumerable<TestCase> selectedTests, IRunContext runContext, IFrameworkHandle frameworkHandle)
265- {
266- // Ensure any channels registered by other adapters are unregistered
267- CleanUpRegisteredChannels();
268-
269- var assemblyGroups = selectedTests.GroupBy(tc => tc.Source);
270-
271- foreach (var assemblyGroup in assemblyGroups)
272- RunAssembly(assemblyGroup.Key, frameworkHandle, MakeTestFilter(assemblyGroup));
273- }
274-
275- void ITestExecutor.Cancel()
276- {
277- if (runner != null && runner.Running)
278- runner.CancelRun();
279- }
280-
281- #endregion
282-
283- #region Private Methods
284-
285- /// <summary>
286- /// Runs the tests in an assembly under control of a filter
287- /// </summary>
288- /// <param name="assemblyName">The assembly file name and path</param>
289- /// <param name="testLog">The destination for all messages and events</param>
290- /// <param name="filter">A test filter controlling what tests are run</param>
291- private void RunAssembly(string assemblyName, ITestExecutionRecorder testLog, TestFilter filter)
292- {
293- // Set the logger to use for messages
294+ RunAssembly(source, frameworkHandle, TestFilter.Empty, runContext);
295+ }
296+
297+ private void RunAssembly(string assemblyName, ITestExecutionRecorder testLog, TestFilter filter, IRunContext runContext)
298+ {
299+
300 SetLogger(testLog);
301
302 try
303 {
304 this.runner = new TestDomain();
305- TestPackage package = new TestPackage(assemblyName);
306-
307+ var package = new TestPackage(assemblyName);
308+ var testDictionary = new Dictionary<string, TestNode>();
309+ var converter = new TestConverter(assemblyName, testDictionary);
310 if (runner.Load(package))
311 {
312- var testCaseMap = CreateTestCaseMap(runner.Test as TestNode);
313
314+ var testCaseMap = CreateTestCaseMap(runner.Test as TestNode, converter);
315 var listener = new NUnitEventListener(testLog, testCaseMap, assemblyName);
316
317 try
318 {
319+ if (isCalledFromTfsBuild)
320+ {
321+ var testfilter = new TFSTestFilter(runContext);
322+ var filteredTestCases = testfilter.CheckFilter(testCases);
323+ filter = MakeTestFilter(filteredTestCases);
324+ }
325 runner.Run(listener, filter, false, LoggingThreshold.Off);
326 }
327 catch (NullReferenceException)
328@@ -125,28 +99,62 @@
329 }
330 }
331
332- private Dictionary<string, NUnit.Core.TestNode> CreateTestCaseMap(TestNode topLevelTest)
333- {
334- var map = new Dictionary<string, NUnit.Core.TestNode>();
335- AddTestCasesToMap(map, topLevelTest);
336+
337+ /// <summary>
338+ /// Called by the TestPlatform when selected tests are to be run.
339+ /// This method is called from Visual Studio when you select a group of tests to run. It is never called from Tfs Build.
340+ /// </summary>
341+ /// <param name="selectedTests">The tests to be run</param>
342+ /// <param name="runContext">The RunContext</param>
343+ /// <param name="frameworkHandle">The FrameworkHandle</param>
344+ public void RunTests(IEnumerable<TestCase> selectedTests, IRunContext runContext, IFrameworkHandle frameworkHandle)
345+ {
346+ // Ensure any channels registered by other adapters are unregistered
347+ CleanUpRegisteredChannels();
348+ isCalledFromTfsBuild = false;
349+ var assemblyGroups = selectedTests.GroupBy(tc => tc.Source);
350+
351+ foreach (var assemblyGroup in assemblyGroups)
352+ RunAssembly(assemblyGroup.Key, frameworkHandle, MakeTestFilter(assemblyGroup), runContext);
353+ }
354+
355+ void ITestExecutor.Cancel()
356+ {
357+ if (runner != null && runner.Running)
358+ runner.CancelRun();
359+ }
360+
361+ #endregion
362+
363+ #region Private Methods
364+
365+ private Dictionary<string, NUnit.Core.TestNode> CreateTestCaseMap(TestNode topLevelTest, TestConverter converter)
366+ {
367+ var map = new Dictionary<string, NUnit.Core.TestNode>();
368+ testCases = new List<TestCase>();
369+ AddTestCasesToMap(map, topLevelTest, converter);
370
371 return map;
372 }
373
374- private void AddTestCasesToMap(Dictionary<string, NUnit.Core.TestNode> map, TestNode test)
375+
376+ private List<TestCase> testCases;
377+ private void AddTestCasesToMap(Dictionary<string, NUnit.Core.TestNode> map, TestNode test, TestConverter converter)
378 {
379- if (test.IsSuite)
380- foreach (TestNode child in test.Tests)
381- AddTestCasesToMap(map, child);
382+ if (test.IsSuite)
383+ foreach (TestNode child in test.Tests) AddTestCasesToMap(map, child, converter);
384 else
385+ {
386+ testCases.Add(converter.ConvertTestCase(test));
387 map.Add(test.TestName.UniqueName, test);
388+ }
389 }
390
391- private TestFilter MakeTestFilter(IEnumerable<TestCase> testCases)
392+ private TestFilter MakeTestFilter(IEnumerable<TestCase> ptestCases)
393 {
394 var filter = new NameFilter();
395
396- foreach (TestCase testCase in testCases)
397+ foreach (TestCase testCase in ptestCases)
398 filter.Add(TestName.Parse(testCase.FullyQualifiedName));
399
400 return filter;
401
402=== added file 'src/NUnitTestAdapter/TFSTestFilter.cs'
403--- src/NUnitTestAdapter/TFSTestFilter.cs 1970-01-01 00:00:00 +0000
404+++ src/NUnitTestAdapter/TFSTestFilter.cs 2012-12-20 20:51:21 +0000
405@@ -0,0 +1,200 @@
406+using System;
407+using System.Collections.Generic;
408+using System.Linq;
409+using System.Reflection;
410+using System.Text;
411+using Microsoft.VisualStudio.TestPlatform.ObjectModel;
412+using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
413+
414+namespace NUnit.VisualStudio.TestAdapter
415+{
416+ using System.Collections;
417+
418+ public class TFSTestFilter
419+ {
420+ /// <summary>
421+ /// Supported properties for filtering
422+
423+ ///</summary>
424+ private static readonly Dictionary<string, TestProperty> supportedPropertiesCache;
425+ private static readonly Dictionary<string, NTrait> supportedTraitCache;
426+ private static readonly Dictionary<NTrait, TestProperty> traitPropertyMap;
427+ private static readonly List<string> supportedProperties;
428+
429+ static TFSTestFilter()
430+ {
431+ // Initialize the property cache
432+ supportedPropertiesCache = new Dictionary<string, TestProperty>(StringComparer.OrdinalIgnoreCase);
433+ supportedPropertiesCache["FullyQualifiedName"] = TestCaseProperties.FullyQualifiedName;
434+ supportedPropertiesCache["Name"] = TestCaseProperties.DisplayName;
435+ // Intialize the trait cache
436+ var priorityTrait = new NTrait("Priority", "");
437+ var categoryTrait = new NTrait("Category", "");
438+ supportedTraitCache = new Dictionary<string, NTrait>(StringComparer.OrdinalIgnoreCase);
439+ supportedTraitCache["Priority"] = priorityTrait;
440+ supportedTraitCache["TestCategory"] = categoryTrait;
441+ // Initalize the trait property map, since TFS doesnt know about traits
442+ traitPropertyMap = new Dictionary<NTrait, TestProperty>(new NTraitNameComparer());
443+ var priorityProperty = TestProperty.Find("Priority") ??
444+ TestProperty.Register("Priority", "Priority", typeof(string), typeof(TestCase));
445+ traitPropertyMap[priorityTrait] = priorityProperty;
446+ var categoryProperty = TestProperty.Find("TestCategory") ??
447+ TestProperty.Register("TestCategory", "TestCategory", typeof(string), typeof(TestCase));
448+ traitPropertyMap[categoryTrait] = categoryProperty;
449+ // Initialize a merged list of properties and traits to fool TFS Build to think traits is properties
450+ supportedProperties = new List<string>();
451+ supportedProperties.AddRange(supportedPropertiesCache.Keys);
452+ supportedProperties.AddRange(supportedTraitCache.Keys);
453+ }
454+
455+ private IRunContext runContext;
456+ public TFSTestFilter(IRunContext runContext)
457+ {
458+ this.runContext = runContext;
459+ }
460+
461+
462+ private ITestCaseFilterExpression testCaseFilterExpression;
463+ public ITestCaseFilterExpression TfsTestCaseFilterExpression
464+ {
465+ get
466+ {
467+ return testCaseFilterExpression ??
468+ (testCaseFilterExpression = runContext.GetTestCaseFilter(supportedProperties, PropertyProvider));
469+ }
470+ }
471+ public IEnumerable<TestCase> CheckFilter(IEnumerable<TestCase> tests)
472+ {
473+
474+ return TfsTestCaseFilterExpression == null ? tests : tests.Where(underTest => !TfsTestCaseFilterExpression.MatchTestCase(underTest, p => PropertyValueProvider(underTest, p)) == false).ToList();
475+ }
476+
477+ /// <summary>
478+ /// Provides value of TestProperty corresponding to property name 'propertyName' as used in filter.
479+ /// /// Return value should be a string for single valued property or array of strings for multi valued property (e.g. TestCategory)
480+ /// /// </summary>
481+ public static object PropertyValueProvider(TestCase currentTest, string propertyName)
482+ {
483+
484+ var testProperty = LocalPropertyProvider(propertyName);
485+ if (testProperty != null)
486+ {
487+
488+ // Test case might not have defined this property. In that case GetPropertyValue()
489+ // would return default value. For filtering, if property is not defined return null.
490+ if (currentTest.Properties.Contains(testProperty))
491+ {
492+ return currentTest.GetPropertyValue(testProperty);
493+ }
494+ }
495+ // Now it may be a trait, so we check the trait collection as well
496+ var testTrait = TraitProvider(propertyName);
497+ if (testTrait != null)
498+ {
499+ var val = traitContains(currentTest, testTrait.Name);
500+ if (val.Length == 0) return null;
501+ if (val.Length == 1) // Contains a single string
502+ return val[0]; // return that string
503+ return val; // otherwise return the whole array
504+ }
505+ return null;
506+ }
507+
508+ static readonly Func<TestCase, string, string[]> traitContains = TraitContains();
509+
510+ /// <summary>
511+ /// TestCase: To be checked
512+ /// traitName: Name of trait to be checked against
513+ /// </summary>
514+ /// <returns>Value of trait</returns>
515+ private static Func<TestCase, string, string[]> TraitContains()
516+ {
517+
518+ return (testCase, traitName) =>
519+ {
520+ var testCaseType = typeof(TestCase);
521+ var property = testCaseType.GetProperty("Traits");
522+ if (property == null)
523+ return null;
524+ var traits = property.GetValue(testCase, null) as IEnumerable;
525+ var values = new List<string>();
526+ foreach (var t in traits)
527+ {
528+ var name = t.GetType().GetProperty("Name").GetValue(t, null) as string;
529+ if (name == traitName)
530+ {
531+ var value = t.GetType().GetProperty("Value").GetValue(t, null) as string;
532+ values.Add(value);
533+ }
534+ }
535+ return values.ToArray();
536+ };
537+ }
538+
539+ /// <summary>
540+ /// Provides TestProperty for property name 'propertyName' as used in filter.
541+ /// </summary>
542+ public static TestProperty LocalPropertyProvider(string propertyName)
543+ {
544+ TestProperty testProperty;
545+ supportedPropertiesCache.TryGetValue(propertyName, out testProperty);
546+ return testProperty;
547+ }
548+
549+ public static TestProperty PropertyProvider(string propertyName)
550+ {
551+ var testProperty = LocalPropertyProvider(propertyName);
552+ if (testProperty != null)
553+ {
554+ return testProperty;
555+ }
556+ var testTrait = TraitProvider(propertyName);
557+ if (testTrait != null)
558+ {
559+ TestProperty tp;
560+ if (traitPropertyMap.TryGetValue(testTrait, out tp))
561+ {
562+ return tp;
563+ }
564+ }
565+ return null;
566+ }
567+
568+ public static NTrait TraitProvider(string traitName)
569+ {
570+ NTrait testTrait;
571+ supportedTraitCache.TryGetValue(traitName, out testTrait);
572+ return testTrait;
573+ }
574+
575+
576+
577+ }
578+
579+ public class NTraitNameComparer : IEqualityComparer<NTrait>
580+ {
581+
582+ public bool Equals(NTrait n, NTrait y)
583+ {
584+ return n.Name == y.Name;
585+ }
586+
587+ public int GetHashCode(NTrait obj)
588+ {
589+ return obj.Name.GetHashCode();
590+ }
591+ }
592+
593+ public class NTrait
594+ {
595+ public string Name { get; private set; }
596+ public string Value { get; private set; }
597+
598+ public NTrait(string name, string value)
599+ {
600+ Name = name;
601+ Value = value;
602+ }
603+ }
604+
605+}
606
607=== added file 'src/NUnitTestAdapterInstall/NUnitTestAdapterInstall.csproj.vspscc'
608--- src/NUnitTestAdapterInstall/NUnitTestAdapterInstall.csproj.vspscc 1970-01-01 00:00:00 +0000
609+++ src/NUnitTestAdapterInstall/NUnitTestAdapterInstall.csproj.vspscc 2012-12-20 20:51:21 +0000
610@@ -0,0 +1,10 @@
611+""
612+{
613+"FILE_VERSION" = "9237"
614+"ENLISTMENT_CHOICE" = "NEVER"
615+"PROJECT_FILE_RELATIVE_PATH" = ""
616+"NUMBER_OF_EXCLUDED_FILES" = "0"
617+"ORIGINAL_PROJECT_FILE_PATH" = ""
618+"NUMBER_OF_NESTED_PROJECTS" = "0"
619+"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
620+}
621
622=== modified file 'src/NUnitTestAdapterInstall/source.extension.vsixmanifest'
623--- src/NUnitTestAdapterInstall/source.extension.vsixmanifest 2012-11-03 01:44:23 +0000
624+++ src/NUnitTestAdapterInstall/source.extension.vsixmanifest 2012-12-20 20:51:21 +0000
625@@ -3,7 +3,7 @@
626 <Identifier Id="NUnitTestAdapterInstall..7c53286e-ac4f-485f-915c-5ec5a4c47b0c">
627 <Name>NUnit Test Adapter (Beta 3-2)</Name>
628 <Author>Charlie Poole</Author>
629- <Version>0.93.2</Version>
630+ <Version>0.93.29</Version>
631 <Description xml:space="preserve">NUnit adapter for integrated test execution under Visual Studio 2012. Compatible with NUnit 2.0 through 2.6.2</Description>
632 <Locale>1033</Locale>
633 <MoreInfoUrl>http://nunit.org/index.php?p=vsTestAdapter&amp;r=2.6.2</MoreInfoUrl>
634
635=== modified file 'src/NUnitTestAdapterTests/Fakes/FakeRunContext.cs'
636--- src/NUnitTestAdapterTests/Fakes/FakeRunContext.cs 2012-10-14 21:26:49 +0000
637+++ src/NUnitTestAdapterTests/Fakes/FakeRunContext.cs 2012-12-20 20:51:21 +0000
638@@ -1,57 +1,63 @@
639-// ****************************************************************
640-// Copyright (c) 2012 NUnit Software. All rights reserved.
641-// ****************************************************************
642-
643-using System;
644-using System.Collections.Generic;
645-using Microsoft.VisualStudio.TestPlatform.ObjectModel;
646-using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
647-
648-namespace NUnit.VisualStudio.TestAdapter.Tests.Fakes
649-{
650- class FakeRunContext : IRunContext
651- {
652- #region IRunContext Members
653-
654- bool IRunContext.InIsolation
655- {
656- get { throw new NotImplementedException(); }
657- }
658-
659- bool IRunContext.IsBeingDebugged
660- {
661- get { throw new NotImplementedException(); }
662- }
663-
664- bool IRunContext.IsDataCollectionEnabled
665- {
666- get { throw new NotImplementedException(); }
667- }
668-
669- bool IRunContext.KeepAlive
670- {
671- get { throw new NotImplementedException(); }
672- }
673-
674- string IRunContext.TestRunDirectory
675- {
676- get { throw new NotImplementedException(); }
677- }
678-
679- ITestCaseFilterExpression IRunContext.GetTestCaseFilter(IEnumerable<string> supportedProperties, Func<string, TestProperty> propertyProvider)
680- {
681- throw new NotImplementedException();
682- }
683-
684- #endregion
685-
686- #region IDiscoveryContextMembers
687-
688- IRunSettings IDiscoveryContext.RunSettings
689- {
690- get { throw new NotImplementedException(); }
691- }
692-
693- #endregion
694- }
695-}
696+// ****************************************************************
697+// Copyright (c) 2012 NUnit Software. All rights reserved.
698+// ****************************************************************
699+
700+using System;
701+using System.Collections.Generic;
702+using Microsoft.VisualStudio.TestPlatform.ObjectModel;
703+using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
704+
705+namespace NUnit.VisualStudio.TestAdapter.Tests.Fakes
706+{
707+ class FakeRunContext : IRunContext
708+ {
709+ #region IRunContext Members
710+
711+ bool IRunContext.InIsolation
712+ {
713+ get { throw new NotImplementedException(); }
714+ }
715+
716+ bool IRunContext.IsBeingDebugged
717+ {
718+ get { throw new NotImplementedException(); }
719+ }
720+
721+ bool IRunContext.IsDataCollectionEnabled
722+ {
723+ get { throw new NotImplementedException(); }
724+ }
725+
726+ bool IRunContext.KeepAlive
727+ {
728+ get { throw new NotImplementedException(); }
729+ }
730+
731+ string IRunContext.TestRunDirectory
732+ {
733+ get { throw new NotImplementedException(); }
734+ }
735+
736+ ITestCaseFilterExpression IRunContext.GetTestCaseFilter(IEnumerable<string> supportedProperties, Func<string, TestProperty> propertyProvider)
737+ {
738+ return null; // as if we don't have a TFS Build, equal to testing from VS
739+ }
740+
741+ #endregion
742+
743+ #region IDiscoveryContextMembers
744+
745+ IRunSettings IDiscoveryContext.RunSettings
746+ {
747+ get { throw new NotImplementedException(); }
748+ }
749+
750+ #endregion
751+
752+
753+ public string SolutionDirectory
754+ {
755+ get { throw new NotImplementedException(); }
756+ }
757+ }
758+}
759
760=== modified file 'src/NUnitTestAdapterTests/NUnitTestAdapterTests.csproj'
761--- src/NUnitTestAdapterTests/NUnitTestAdapterTests.csproj 2012-12-18 04:44:45 +0000
762+++ src/NUnitTestAdapterTests/NUnitTestAdapterTests.csproj 2012-12-20 20:51:21 +0000
763@@ -1,92 +1,97 @@
764-<?xml version="1.0" encoding="utf-8"?>
765-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
766- <PropertyGroup>
767- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
768- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
769- <ProductVersion>8.0.30703</ProductVersion>
770- <SchemaVersion>2.0</SchemaVersion>
771- <ProjectGuid>{D261700A-5950-46AB-BA3A-304ADBED0DE6}</ProjectGuid>
772- <OutputType>Library</OutputType>
773- <AppDesignerFolder>Properties</AppDesignerFolder>
774- <RootNamespace>NUnit.VisualStudio.TestAdapter.Tests</RootNamespace>
775- <AssemblyName>NUnit.VisualStudio.TestAdapter.Tests</AssemblyName>
776- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
777- <FileAlignment>512</FileAlignment>
778- <TargetFrameworkProfile />
779- </PropertyGroup>
780- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
781- <DebugSymbols>true</DebugSymbols>
782- <DebugType>full</DebugType>
783- <Optimize>false</Optimize>
784- <OutputPath>bin\Debug\</OutputPath>
785- <DefineConstants>TRACE;DEBUG</DefineConstants>
786- <ErrorReport>prompt</ErrorReport>
787- <WarningLevel>4</WarningLevel>
788- <Prefer32Bit>false</Prefer32Bit>
789- </PropertyGroup>
790- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
791- <DebugType>pdbonly</DebugType>
792- <Optimize>true</Optimize>
793- <OutputPath>bin\Release\</OutputPath>
794- <DefineConstants>TRACE</DefineConstants>
795- <ErrorReport>prompt</ErrorReport>
796- <WarningLevel>4</WarningLevel>
797- <Prefer32Bit>false</Prefer32Bit>
798- </PropertyGroup>
799- <ItemGroup>
800- <Reference Include="Microsoft.VisualStudio.TestPlatform.ObjectModel">
801- <HintPath>C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll</HintPath>
802- </Reference>
803- <Reference Include="mock-assembly, Version=2.6.2.12295, Culture=neutral, processorArchitecture=MSIL">
804- <SpecificVersion>False</SpecificVersion>
805- <HintPath>..\..\lib\mock-assembly.dll</HintPath>
806- </Reference>
807- <Reference Include="nunit.core, Version=2.6.2.12295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
808- <SpecificVersion>False</SpecificVersion>
809- <HintPath>..\..\lib\nunit.core.dll</HintPath>
810- </Reference>
811- <Reference Include="nunit.core.interfaces, Version=2.6.2.12295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
812- <SpecificVersion>False</SpecificVersion>
813- <HintPath>..\..\lib\nunit.core.interfaces.dll</HintPath>
814- </Reference>
815- <Reference Include="nunit.framework, Version=2.6.2.12295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
816- <SpecificVersion>False</SpecificVersion>
817- <HintPath>..\..\lib\nunit.framework.dll</HintPath>
818- </Reference>
819- <Reference Include="System" />
820- <Reference Include="System.Core" />
821- <Reference Include="System.Xml.Linq" />
822- <Reference Include="System.Data.DataSetExtensions" />
823- <Reference Include="Microsoft.CSharp" />
824- <Reference Include="System.Data" />
825- <Reference Include="System.Xml" />
826- </ItemGroup>
827- <ItemGroup>
828- <Compile Include="AsyncTests.cs" />
829- <Compile Include="NavigationTestData.cs" />
830- <Compile Include="NavigationDataTests.cs" />
831- <Compile Include="Fakes\FakeFrameworkHandle.cs" />
832- <Compile Include="Fakes\FakeRunContext.cs" />
833- <Compile Include="Fakes\FakeRunSettings.cs" />
834- <Compile Include="TestConverterTests_StaticHelpers.cs" />
835- <Compile Include="TestConverterTests.cs" />
836- <Compile Include="TestDiscoveryTests.cs" />
837- <Compile Include="NUnitEventListenerTests.cs" />
838- <Compile Include="Properties\AssemblyInfo.cs" />
839- <Compile Include="TestExecutionTests.cs" />
840- </ItemGroup>
841- <ItemGroup>
842- <ProjectReference Include="..\NUnitTestAdapter\NUnitTestAdapter.csproj">
843- <Project>{8A85E26A-C706-48B1-BC36-06EBDE3EFD25}</Project>
844- <Name>NUnitTestAdapter</Name>
845- </ProjectReference>
846- </ItemGroup>
847- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
848- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
849- Other similar extension points exist, see Microsoft.Common.targets.
850- <Target Name="BeforeBuild">
851- </Target>
852- <Target Name="AfterBuild">
853- </Target>
854- -->
855+<?xml version="1.0" encoding="utf-8"?>
856+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
857+ <PropertyGroup>
858+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
859+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
860+ <ProductVersion>8.0.30703</ProductVersion>
861+ <SchemaVersion>2.0</SchemaVersion>
862+ <ProjectGuid>{D261700A-5950-46AB-BA3A-304ADBED0DE6}</ProjectGuid>
863+ <OutputType>Library</OutputType>
864+ <AppDesignerFolder>Properties</AppDesignerFolder>
865+ <RootNamespace>NUnit.VisualStudio.TestAdapter.Tests</RootNamespace>
866+ <AssemblyName>NUnit.VisualStudio.TestAdapter.Tests</AssemblyName>
867+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
868+ <FileAlignment>512</FileAlignment>
869+ <TargetFrameworkProfile />
870+ <SccProjectName>%24/BlogCode/TestAdapters/trunk/trunkadapter/src/NUnitTestAdapterTests</SccProjectName>
871+ <SccLocalPath>.</SccLocalPath>
872+ <SccAuxPath>https://terje.tfspreview.com/defaultcollection</SccAuxPath>
873+ <SccProvider>{4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}</SccProvider>
874+ </PropertyGroup>
875+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
876+ <DebugSymbols>true</DebugSymbols>
877+ <DebugType>full</DebugType>
878+ <Optimize>false</Optimize>
879+ <OutputPath>bin\Debug\</OutputPath>
880+ <DefineConstants>TRACE;DEBUG</DefineConstants>
881+ <ErrorReport>prompt</ErrorReport>
882+ <WarningLevel>4</WarningLevel>
883+ <Prefer32Bit>false</Prefer32Bit>
884+ </PropertyGroup>
885+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
886+ <DebugType>pdbonly</DebugType>
887+ <Optimize>true</Optimize>
888+ <OutputPath>bin\Release\</OutputPath>
889+ <DefineConstants>TRACE</DefineConstants>
890+ <ErrorReport>prompt</ErrorReport>
891+ <WarningLevel>4</WarningLevel>
892+ <Prefer32Bit>false</Prefer32Bit>
893+ </PropertyGroup>
894+ <ItemGroup>
895+ <Reference Include="Microsoft.VisualStudio.TestPlatform.ObjectModel">
896+ <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll</HintPath>
897+ </Reference>
898+ <Reference Include="mock-assembly, Version=2.4.8.0, Culture=neutral, processorArchitecture=MSIL">
899+ <SpecificVersion>False</SpecificVersion>
900+ <HintPath>..\..\lib\mock-assembly.dll</HintPath>
901+ </Reference>
902+ <Reference Include="nunit.core, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
903+ <SpecificVersion>False</SpecificVersion>
904+ <HintPath>..\..\lib\nunit.core.dll</HintPath>
905+ </Reference>
906+ <Reference Include="nunit.core.interfaces, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
907+ <SpecificVersion>False</SpecificVersion>
908+ <HintPath>..\..\lib\nunit.core.interfaces.dll</HintPath>
909+ </Reference>
910+ <Reference Include="nunit.framework, Version=2.6.2.12295, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
911+ <SpecificVersion>False</SpecificVersion>
912+ <HintPath>..\..\lib\nunit.framework.dll</HintPath>
913+ </Reference>
914+ <Reference Include="System" />
915+ <Reference Include="System.Core" />
916+ <Reference Include="System.Xml.Linq" />
917+ <Reference Include="System.Data.DataSetExtensions" />
918+ <Reference Include="Microsoft.CSharp" />
919+ <Reference Include="System.Data" />
920+ <Reference Include="System.Xml" />
921+ </ItemGroup>
922+ <ItemGroup>
923+ <Compile Include="AsyncTests.cs" />
924+ <Compile Include="NavigationTestData.cs" />
925+ <Compile Include="NavigationDataTests.cs" />
926+ <Compile Include="Fakes\FakeFrameworkHandle.cs" />
927+ <Compile Include="Fakes\FakeRunContext.cs" />
928+ <Compile Include="Fakes\FakeRunSettings.cs" />
929+ <Compile Include="TestConverterTests_StaticHelpers.cs" />
930+ <Compile Include="TestConverterTests.cs" />
931+ <Compile Include="TestDiscoveryTests.cs" />
932+ <Compile Include="NUnitEventListenerTests.cs" />
933+ <Compile Include="Properties\AssemblyInfo.cs" />
934+ <Compile Include="TestExecutionTests.cs" />
935+ <Compile Include="TestTFSBuild.cs" />
936+ </ItemGroup>
937+ <ItemGroup>
938+ <ProjectReference Include="..\NUnitTestAdapter\NUnitTestAdapter.csproj">
939+ <Project>{8A85E26A-C706-48B1-BC36-06EBDE3EFD25}</Project>
940+ <Name>NUnitTestAdapter</Name>
941+ </ProjectReference>
942+ </ItemGroup>
943+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
944+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
945+ Other similar extension points exist, see Microsoft.Common.targets.
946+ <Target Name="BeforeBuild">
947+ </Target>
948+ <Target Name="AfterBuild">
949+ </Target>
950+ -->
951 </Project>
952\ No newline at end of file
953
954=== added file 'src/NUnitTestAdapterTests/NUnitTestAdapterTests.csproj.vspscc'
955--- src/NUnitTestAdapterTests/NUnitTestAdapterTests.csproj.vspscc 1970-01-01 00:00:00 +0000
956+++ src/NUnitTestAdapterTests/NUnitTestAdapterTests.csproj.vspscc 2012-12-20 20:51:21 +0000
957@@ -0,0 +1,10 @@
958+""
959+{
960+"FILE_VERSION" = "9237"
961+"ENLISTMENT_CHOICE" = "NEVER"
962+"PROJECT_FILE_RELATIVE_PATH" = ""
963+"NUMBER_OF_EXCLUDED_FILES" = "0"
964+"ORIGINAL_PROJECT_FILE_PATH" = ""
965+"NUMBER_OF_NESTED_PROJECTS" = "0"
966+"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
967+}
968
969=== added file 'src/NUnitTestAdapterTests/TestTFSBuild.cs'
970--- src/NUnitTestAdapterTests/TestTFSBuild.cs 1970-01-01 00:00:00 +0000
971+++ src/NUnitTestAdapterTests/TestTFSBuild.cs 2012-12-20 20:51:21 +0000
972@@ -0,0 +1,136 @@
973+using System;
974+using System.Collections.Generic;
975+using System.Linq;
976+using System.Text;
977+using System.Threading.Tasks;
978+using NUnit.Framework;
979+
980+namespace NUnit.VisualStudio.TestAdapter.Tests
981+{
982+ using System.Reflection;
983+
984+ using Microsoft.VisualStudio.TestPlatform.ObjectModel;
985+
986+
987+ [TestFixture]
988+ public class TestFilterTests
989+ {
990+ private MethodInfo traitsCollectionAdd;
991+ private readonly PropertyInfo traitsProperty;
992+
993+ private readonly bool isRTM = false;
994+
995+ public TestFilterTests()
996+ {
997+ traitsProperty = typeof(TestCase).GetProperty("Traits");
998+ if (traitsProperty != null)
999+ {
1000+ var traitCollectionType = traitsProperty.PropertyType;
1001+ if (traitCollectionType != null)
1002+ traitsCollectionAdd = traitCollectionType.GetMethod("Add", new Type[] { typeof(string), typeof(string) });
1003+ }
1004+ else
1005+ isRTM = true;
1006+ }
1007+
1008+ private void AddTrait(TestCase testCase, string traitname, string traitvalue)
1009+ {
1010+ object traitsCollection = traitsProperty.GetValue(testCase, new object[0]);
1011+ if (traitsCollection == null) return;
1012+ traitsCollectionAdd.Invoke(traitsCollection, new object[] { traitname, traitvalue });
1013+ }
1014+
1015+
1016+ [Test]
1017+ [Category("TFS")]
1018+ public void PropertyProvider()
1019+ {
1020+ var testfilter = new TFSTestFilter(null);
1021+ var prop = TFSTestFilter.PropertyProvider("Priority");
1022+ Assert.NotNull(prop);
1023+ prop = TFSTestFilter.PropertyProvider("TestCategory");
1024+ Assert.NotNull(prop);
1025+ }
1026+ [Test]
1027+ [Category("TFS")]
1028+ public void TraitProvider()
1029+ {
1030+ if (isRTM) return;
1031+ var testFilter = new TFSTestFilter(null);
1032+ var trait = TFSTestFilter.TraitProvider("TestCategory");
1033+ Assert.NotNull(trait);
1034+ }
1035+
1036+ [Test]
1037+ [Category("TFS")]
1038+ public void TraitProviderWithNoCategory()
1039+ {
1040+ var testFilter = new TFSTestFilter(null);
1041+ var trait = TFSTestFilter.TraitProvider("JustKidding");
1042+ Assert.Null(trait);
1043+ }
1044+
1045+ [Test]
1046+ [Category("TFS")]
1047+ public void PropertyValueProviderFqn()
1048+ {
1049+ if (isRTM) return;
1050+ var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX");
1051+ var testFilter = new TFSTestFilter(null);
1052+ var obj = TFSTestFilter.PropertyValueProvider(tc, "FullyQualifiedName");
1053+ Assert.AreSame("Test1", obj);
1054+ }
1055+
1056+ [Test]
1057+ [Category("TFS")]
1058+ public void PropertyValueProviderCategoryWithOneCategory()
1059+ {
1060+ if (isRTM) return;
1061+ var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX");
1062+ this.AddTrait(tc, "Category", "CI");
1063+ var testFilter = new TFSTestFilter(null);
1064+ var obj = TFSTestFilter.PropertyValueProvider(tc, "TestCategory");
1065+ Assert.AreSame("CI", obj);
1066+ }
1067+
1068+ [Test]
1069+ [Category("TFS")]
1070+ public void PropertyValueProviderCategoryWithNoTraits()
1071+ {
1072+ var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX");
1073+ var testFilter = new TFSTestFilter(null);
1074+ var obj = TFSTestFilter.PropertyValueProvider(tc, "TestCategory");
1075+ Assert.IsNull(obj);
1076+ }
1077+
1078+ [Test]
1079+ [Category("TFS")]
1080+ public void PropertyValueProviderCategoryWithMultipleCategories()
1081+ {
1082+ if (isRTM) return;
1083+ var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX");
1084+ this.AddTrait(tc, "Category", "CI");
1085+ this.AddTrait(tc, "Category", "MyOwn");
1086+ var testFilter = new TFSTestFilter(null);
1087+ var obj = TFSTestFilter.PropertyValueProvider(tc, "TestCategory") as string[];
1088+ Assert.IsNotNull(obj);
1089+ Assert.AreEqual(obj.Length, 2);
1090+ Assert.AreSame("CI", obj[0]);
1091+ Assert.AreSame("MyOwn", obj[1]);
1092+ }
1093+
1094+ [Test]
1095+ [Category("TFS")]
1096+ public void PropertyValueProviderCategoryFail()
1097+ {
1098+ if (isRTM) return;
1099+ var tc = new TestCase("Test1", new Uri("executor://NUnitTestExecutor"), "NUnit.VSIX");
1100+ this.AddTrait(tc, "Category", "CI");
1101+ var testFilter = new TFSTestFilter(null);
1102+ var obj = TFSTestFilter.PropertyValueProvider(tc, "Garbage");
1103+ Assert.Null(obj);
1104+ }
1105+
1106+
1107+ }
1108+}

Subscribers

People subscribed via source and target branches