Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Commit

Permalink
logging and debugs for null reference exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Elliot authored and Ed Elliot committed Oct 3, 2017
1 parent 43f328c commit 0c7ced9
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestWindow.Core">
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Core.dll</HintPath>
<HintPath>..\lib\Microsoft.VisualStudio.TestWindow.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
2 changes: 1 addition & 1 deletion XMLTestAdapterVSIX/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="AgileSQLClub.tSQLtTestAdapter15" Version="0.80" Language="en-US" Publisher="EdElliott" />
<Identity Id="AgileSQLClub.tSQLtTestAdapter15" Version="0.90" Language="en-US" Publisher="EdElliott" />
<DisplayName>tSQLt Test Adapter for Visual Studio 2017</DisplayName>
<Description xml:space="preserve">Unit Test Adapter for tSQLt Tests</Description>
<MoreInfo>https://the.agilsql.club/projects/tSQLt-Test-Adapter</MoreInfo>
Expand Down
2 changes: 1 addition & 1 deletion XmlTestAdapter/Helpers/RunSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RunSettings
public RunSettings(IRunSettings runSettings)
{

if (String.IsNullOrEmpty(runSettings.SettingsXml))
if (runSettings == null || runSettings.SettingsXml == null || String.IsNullOrEmpty(runSettings.SettingsXml))
{
return;
}
Expand Down
19 changes: 8 additions & 11 deletions XmlTestAdapter/tSQLtTestAdapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,15 @@
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio 14.0\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Shell.Immutable.10.0.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Shell.Immutable.10.0.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio 14.0\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Shell.Immutable.11.0.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Shell.Immutable.11.0.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.14.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.12.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio 14.0\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Shell.Immutable.14.0.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Shell.Immutable.12.0.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<SpecificVersion>False</SpecificVersion>
Expand All @@ -91,19 +88,19 @@
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\TestPlatform\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll</HintPath>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestWindow, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.dll</HintPath>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestWindow.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Core.dll</HintPath>
<HintPath>..\lib\Microsoft.VisualStudio.TestWindow.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestWindow.Interfaces, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Interfaces.dll</HintPath>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Interfaces.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
Expand Down
33 changes: 21 additions & 12 deletions XmlTestAdapter/tSQLtTestDiscoverer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class XmlTestDiscoverer : ITestDiscoverer
private static readonly TestCache _tests = new TestCache();

private static readonly List<Regex> _includePaths = new List<Regex>();


public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
{
Expand All @@ -29,7 +30,7 @@ public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discove
logger.SendMessage(TestMessageLevel.Informational, "tSQLt Test Adapter, searching for tests...");

var includePath = new RunSettings(discoveryContext.RunSettings).GetSetting("IncludePath");
SetPathFilter(includePath);
SetPathFilter(includePath, logger);

lock (_lock)
{
Expand All @@ -42,23 +43,31 @@ public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discove
logger.SendMessage(TestMessageLevel.Informational, "tSQLt Test Adapter, searching for tests...done - none found");
}

public static void SetPathFilter(string includePath)
public static void SetPathFilter(string includePath, IMessageLogger logger)
{
_includePaths.Clear();

if (!string.IsNullOrEmpty(includePath))
try
{
if (includePath.IndexOf(";", StringComparison.Ordinal) >= 0)
_includePaths.Clear();

if (!string.IsNullOrEmpty(includePath))
{
foreach (var part in includePath.Split(';'))
if (includePath.IndexOf(";", StringComparison.Ordinal) >= 0)
{
_includePaths.Add(new Regex(part));
foreach (var part in includePath.Split(';'))
{
logger.SendMessage(TestMessageLevel.Informational, string.Format("tSQLt Test Adapter, adding filter...- {0}", part));
_includePaths.Add(new Regex(part));
}
}
else
{
logger.SendMessage(TestMessageLevel.Informational, string.Format("tSQLt Test Adapter, adding filter...- {0}", includePath));
_includePaths.Add(new Regex(includePath));
}
}
else
{
_includePaths.Add(new Regex(includePath));
}
}catch(Exception e)
{
logger.SendMessage(TestMessageLevel.Informational, string.Format("tSQLt Test Adapter, *ERROR* adding filter...- {0}", includePath));
}
}

Expand Down
4 changes: 2 additions & 2 deletions XmlTestAdapter/tSQLtTestExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class tSQLtTestExecutor : ITestExecutor
{
public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
XmlTestDiscoverer.SetPathFilter(new RunSettings(runContext.RunSettings).GetSetting("IncludePath"));
XmlTestDiscoverer.SetPathFilter(new RunSettings(runContext.RunSettings).GetSetting("IncludePath"), frameworkHandle);
IEnumerable<TestCase> tests = XmlTestDiscoverer.GetTests(sources, null);
RunTests(tests, runContext, frameworkHandle);
}
Expand Down Expand Up @@ -71,7 +71,7 @@ public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrame

private static TestSuites Run(tSQLtTestRunner testSession, TestCase test)
{
if(test.DisplayName.Contains("."))
if(test != null && test.DisplayName != null && test.DisplayName.Contains("."))
return testSession.Run(test.DisplayName.Split('.')[0], test.DisplayName.Split('.')[1]);
return null;
}
Expand Down
Binary file modified lib/tSQLt.Client.Net.dll
Binary file not shown.

0 comments on commit 0c7ced9

Please sign in to comment.