Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion source/AccUnit/CodeCoverage/CodeCoverageTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ public CodeCoverageTracker(VBProject vbProject)

public void Clear(string codeModuleName = null)
{
if (codeModuleName.Length > 0)
if (!string.IsNullOrEmpty(codeModuleName))
{
RemoveCodeCoverageTracker(codeModuleName);
if (_codeModules.TryGetValue(codeModuleName, out var codeModuleTracker))
{
codeModuleTracker.Procedures.Clear();
_codeModules.Remove(codeModuleName);
}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Vbe.Interop">
<HintPath>..\..\libvbide\Microsoft.Vbe.Interop.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.13.3.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.3.13.3\lib\net45\nunit.framework.dll</HintPath>
</Reference>
Expand All @@ -114,6 +117,7 @@
<ItemGroup>
<Compile Include="AssertExceptionTests.cs" />
<Compile Include="AssertTests.cs" />
<Compile Include="CodeCoverageTrackerTests.cs" />
<Compile Include="ConstraintTests.cs" />
<Compile Include="InteropContraintTest.cs" />
<Compile Include="TestHelper\InteropTestCollector.cs" />
Expand Down
34 changes: 34 additions & 0 deletions source/Tests/AccUnit.Assertions.Tests/CodeCoverageTrackerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using AccessCodeLib.AccUnit.CodeCoverage;
using NUnit.Framework;

namespace AccessCodeLib.AccUnit.Assertions.Tests
{
public class CodeCoverageTrackerTests
{
// An empty tracker needs no VBProject: nothing has to be removed from a code module.

[Test]
public void Clear_WithoutArgument_ClearsAllModulesWithoutException()
{
var tracker = new CodeCoverageTracker(null);

Assert.DoesNotThrow(() => tracker.Clear());
}

[Test]
public void Clear_WithNull_ClearsAllModulesWithoutException()
{
var tracker = new CodeCoverageTracker(null);

Assert.DoesNotThrow(() => tracker.Clear(null));
}

[Test]
public void Clear_WithEmptyString_ClearsAllModulesWithoutException()
{
var tracker = new CodeCoverageTracker(null);

Assert.DoesNotThrow(() => tracker.Clear(""));
}
}
}
2 changes: 2 additions & 0 deletions vbe-add-In/AccUnit.VbeAddIn/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Allgemeine Informationen über eine Assembly werden über die folgenden
Expand All @@ -16,6 +17,7 @@
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: InternalsVisibleTo("AccUnit.VbeAddIn.Tests")]
[assembly: ComVisible(false)]

// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,14 @@ public VbideUserControl<TestListAndResultView> TestListAndResultWindow
{
_testListAndResultVbideControl = new VbideUserControl<TestListAndResultView>(AddIn, Resources.UserControls.TestResultUserControlInfoCaption, TestListAndResultViewUserControlInfo.PositionGuid);
_testListAndResultView = _testListAndResultVbideControl.Control;
_testListAndResultView.RunBreakOnErrorMenuItemEnabled = (TestSuiteManager.TestSuite is AccessTestSuite);
try
{
_testListAndResultView.RunBreakOnErrorMenuItemEnabled = (TestSuiteManager.TestSuite is AccessTestSuite);
}
catch (Exception ex)
{
UITools.ShowException(ex);
}

_testListAndResultView.RunTests += TestListAndResultViewRunTests;
_testListAndResultView.ShowSourceCodeInvoked += TestListAndResultViewShowSourceCodeInvoked;
Expand Down
11 changes: 6 additions & 5 deletions vbe-add-In/AccUnit.VbeAddIn/TestSuiteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ private void InitTestSuite()
try
{
_vbaTestSuite = CreateVbaTestSuite(OfficeApplicationHelper);
TestSuiteInitialized?.Invoke(_vbaTestSuite);
}
catch (Exception ex)
{
UITools.ShowException(ex);
}
finally
{
TestSuiteInitialized?.Invoke(_vbaTestSuite);
// Do not hand out a silent null: VBA would fail later with a meaningless message.
// The exception reaches VBA as COM error (Err.Description contains the message);
// UI callers show it themselves.
Logger.Log(ex);
throw new InvalidOperationException("AccUnit test suite could not be initialized: " + ex.Message, ex);
}
}
}
Expand Down
25 changes: 25 additions & 0 deletions vbe-add-In/Tests/AccUnit.VbeAddIn.Tests/TestSuiteManagerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using NUnit.Framework;
using System;

namespace AccessCodeLib.AccUnit.VbeAddIn.Tests
{
public class TestSuiteManagerTests
{
[Test]
public void TestSuite_WhenInitializationFails_ThrowsWithOriginalMessageInsteadOfReturningNull()
{
using (var manager = new TestSuiteManager())
{
manager.TestResultReporterRequest += (ref System.Collections.Generic.IList<Interfaces.ITestResultReporter> reporters) =>
throw new InvalidOperationException("reporter failure");
// no OfficeApplicationHelper => the suite cannot be created

var exception = Assert.Throws<InvalidOperationException>(() => { var _ = manager.TestSuite; });

Assert.That(exception.Message, Does.StartWith("AccUnit test suite could not be initialized"));
Assert.That(exception.InnerException, Is.Not.Null);
Assert.That(exception.Message, Does.Contain(exception.InnerException.Message));
}
}
}
}