Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ build/
[Oo]bj/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
Expand Down Expand Up @@ -163,3 +162,4 @@ OpenCover/
*.VC.opendb
*.VC.db-shm
*.VC.db-wal
/SampleTests/TestResults
2 changes: 1 addition & 1 deletion GoogleTestAdapter/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ build/
[Oo]bj/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
Expand Down Expand Up @@ -159,3 +158,4 @@ $RECYCLE.BIN/
/Keys/Key_Release.snk
GoogleTestAdapter.VC.db
GoogleTestAdapter.VC.VC.opendb
/TestResults
1 change: 0 additions & 1 deletion GoogleTestAdapter/Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
<ItemGroup>
<Compile Include="ILogger.cs" />
<Compile Include="LoggerBase.cs" />
<Compile Include="ProcessWaiter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions GoogleTestAdapter/Common/LoggerBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace GoogleTestAdapter.Common
Expand Down Expand Up @@ -69,6 +70,12 @@ public void DebugError(string message)
if (_inDebugMode())
LogError(message);
}

public static void TimestampMessage(ref string message)
{
string timestamp = DateTime.Now.ToString("HH:mm:ss.fff", CultureInfo.InvariantCulture);
message = $"{timestamp} - {message ?? ""}";
}
}

}
36 changes: 36 additions & 0 deletions GoogleTestAdapter/Core.Tests/Common/LoggerBaseTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using static GoogleTestAdapter.Tests.Common.TestMetadata.TestCategories;

namespace GoogleTestAdapter.Common
{
[TestClass]
public class LoggerBaseTests
{

[TestMethod]
[TestCategory(Unit)]
public void TimestampMessage_MessageIsNullOrEmpty_ResultIsTheSame()
{
string timestampSeparator = " - ";
string resultRegex = @"[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}" + timestampSeparator;

string nullMessage = null;
LoggerBase.TimestampMessage(ref nullMessage);
nullMessage.Should().MatchRegex(resultRegex);
nullMessage.Should().EndWith(timestampSeparator);

string emptyMessage = "";
LoggerBase.TimestampMessage(ref emptyMessage);
emptyMessage.Should().MatchRegex(resultRegex);
emptyMessage.Should().EndWith(timestampSeparator);

string fooMessage = "foo";
LoggerBase.TimestampMessage(ref fooMessage);
fooMessage.Should().MatchRegex(resultRegex);
fooMessage.Should().EndWith(timestampSeparator + "foo");
}

}

}
10 changes: 4 additions & 6 deletions GoogleTestAdapter/Core.Tests/Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,25 @@
</Choose>
<ItemGroup>
<Compile Include="AbstractGoogleTestDiscovererTraitTests.cs" />
<Compile Include="Common\LoggerBaseTests.cs" />
<Compile Include="GoogleTestDiscoverReleaseTraitTests.cs" />
<Compile Include="GoogleTestDiscoverDebugTraitTests.cs" />
<Compile Include="GoogleTestDiscovererTests.cs" />
<Compile Include="GoogleTestExecutorTests.cs" />
<Compile Include="Helpers\DebugUtilsTests.cs" />
<Compile Include="Helpers\ProcessExecutorTests.cs" />
<Compile Include="Helpers\RegexTraitParserTests.cs" />
<Compile Include="Settings\RegexTraitParserTests.cs" />
<Compile Include="Helpers\TestEnvironmentTests.cs" />
<Compile Include="Helpers\UtilsTests.cs" />
<Compile Include="Runners\CommandLineGeneratorTests.cs" />
<Compile Include="Runners\SequentialTestRunnerTests.cs" />
<Compile Include="TestCases\TestCaseFactoryTests.cs" />
<Compile Include="TestCases\ListTestsParserTests.cs" />
<Compile Include="TestResults\StreamingStandardOutputTestResultParserTests.cs" />
<Compile Include="TestResults\StandardOutputTestResultParserTests.cs" />
<Compile Include="TestCases\StreamingListTestsParserTests.cs" />
<Compile Include="TestResults\StreamingTestOutputParserTests.cs" />
<Compile Include="TestResults\ErrorMessageParserTests.cs" />
<Compile Include="TestResults\XmlTestResultParserTests.cs" />
<Compile Include="Scheduling\DurationBasedTestsSplitterTests.cs" />
<Compile Include="Scheduling\NumberBasedTestsSplitterTests.cs" />
<Compile Include="Settings\SettingsWrapperTests.cs" />
<Compile Include="Helpers\TestProcessLauncherTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Scheduling\TestDurationSerializerTests.cs" />
</ItemGroup>
Expand Down
6 changes: 2 additions & 4 deletions GoogleTestAdapter/Core.Tests/GoogleTestExecutorTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.IO;
using System.Linq;
using FluentAssertions;
using GoogleTestAdapter.Helpers;
using GoogleTestAdapter.Model;
using GoogleTestAdapter.Scheduling;
using GoogleTestAdapter.Tests.Common;
Expand Down Expand Up @@ -40,11 +39,10 @@ private void AssertDurationsFileIsCreated(bool parallelExecution)

MockOptions.Setup(o => o.ParallelTestExecution).Returns(parallelExecution);
MockOptions.Setup(o => o.MaxNrOfThreads).Returns(2);
var processExecutor = new ProcessExecutor(null, TestEnvironment.Logger);

var collectingReporter = new FakeFrameworkReporter();
var testExecutor = new GoogleTestExecutor(TestEnvironment.Logger, TestEnvironment.Options);
testExecutor.RunTests(TestDataCreator.AllTestCasesExceptLoadTests, TestDataCreator.AllTestCasesExceptLoadTests, collectingReporter, null, false, TestResources.SampleTestsSolutionDir, processExecutor);
var testExecutor = new GoogleTestExecutor(TestEnvironment.Logger, TestEnvironment.Options, null);
testExecutor.RunTests(TestDataCreator.AllTestCasesExceptLoadTests, TestDataCreator.AllTestCasesExceptLoadTests, collectingReporter, false, TestResources.SampleTestsSolutionDir);

sampleTestsDurationsFile.AsFileInfo()
.Should()
Expand Down
30 changes: 0 additions & 30 deletions GoogleTestAdapter/Core.Tests/Helpers/DebugUtilsTests.cs

This file was deleted.

69 changes: 0 additions & 69 deletions GoogleTestAdapter/Core.Tests/Helpers/TestProcessLauncherTests.cs

This file was deleted.

29 changes: 11 additions & 18 deletions GoogleTestAdapter/Core.Tests/Helpers/UtilsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,18 @@ public void GetTempDirectory__DirectoryDoesExistAndCanBeDeleted()

[TestMethod]
[TestCategory(Unit)]
public void TimestampMessage_MessageIsNullOrEmpty_ResultIsTheSame()
public void AssertIsNotNull_Null_ThrowsException()
{
string timestampSeparator = " - ";
string resultRegex = @"[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}" + timestampSeparator;

string nullMessage = null;
Utils.TimestampMessage(ref nullMessage);
nullMessage.Should().MatchRegex(resultRegex);
nullMessage.Should().EndWith(timestampSeparator);

string emptyMessage = "";
Utils.TimestampMessage(ref emptyMessage);
emptyMessage.Should().MatchRegex(resultRegex);
emptyMessage.Should().EndWith(timestampSeparator);

string fooMessage = "foo";
Utils.TimestampMessage(ref fooMessage);
fooMessage.Should().MatchRegex(resultRegex);
fooMessage.Should().EndWith(timestampSeparator + "foo");
Action action = () => Utils.AssertIsNotNull(null, "foo");
action.ShouldThrow<ArgumentNullException>();
}

[TestMethod]
[TestCategory(Unit)]
public void AssertIsNull_NotNull_ThrowsException()
{
Action action = () => Utils.AssertIsNull("", "foo");
action.ShouldThrow<ArgumentException>();
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Diagnostics;
using System.Threading;
using FluentAssertions;
using GoogleTestAdapter.Helpers;
using GoogleTestAdapter.Model;
using GoogleTestAdapter.Scheduling;
using GoogleTestAdapter.Tests.Common;
Expand Down Expand Up @@ -43,9 +42,8 @@ private void DoRunCancelingTests(bool killProcesses, int lower, int upper)
List<TestCase> testCasesToRun = TestDataCreator.GetTestCases("Crashing.LongRunning", "LongRunningTests.Test2");

var stopwatch = new Stopwatch();
var runner = new SequentialTestRunner("", MockFrameworkReporter.Object, TestEnvironment.Logger, TestEnvironment.Options, new SchedulingAnalyzer(TestEnvironment.Logger));
var executor = new ProcessExecutor(null, MockLogger.Object);
var thread = new Thread(() => runner.RunTests(allTestCases, testCasesToRun, "", "", "", false, null, executor));
var runner = new SequentialTestRunner("", null, MockFrameworkReporter.Object, new SchedulingAnalyzer(TestEnvironment.Logger), TestEnvironment.Options, TestEnvironment.Logger);
var thread = new Thread(() => runner.RunTests(allTestCases, testCasesToRun, "", "", ""));

stopwatch.Start();
thread.Start();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System.Collections.Generic;
using FluentAssertions;
using GoogleTestAdapter.Settings;
using GoogleTestAdapter.Tests.Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using static GoogleTestAdapter.Tests.Common.TestMetadata.TestCategories;

namespace GoogleTestAdapter.Helpers
namespace GoogleTestAdapter.Settings
{
[TestClass]
public class RegexTraitParserTests : TestsBase
Expand All @@ -22,7 +20,7 @@ public override void SetUp()


[TestMethod]
[TestCategory(Unit)]
[TestCategory(TestMetadata.TestCategories.Unit)]
public void ParseTraitsRegexesString_UnparsableString_FailsNicely()
{
List<RegexTraitPair> result = Parser.ParseTraitsRegexesString("vrr<erfwe");
Expand All @@ -32,7 +30,7 @@ public void ParseTraitsRegexesString_UnparsableString_FailsNicely()
}

[TestMethod]
[TestCategory(Unit)]
[TestCategory(TestMetadata.TestCategories.Unit)]
public void ParseTraitsRegexesString_EmptyString_EmptyResult()
{
List<RegexTraitPair> result = Parser.ParseTraitsRegexesString("");
Expand All @@ -42,7 +40,7 @@ public void ParseTraitsRegexesString_EmptyString_EmptyResult()
}

[TestMethod]
[TestCategory(Unit)]
[TestCategory(TestMetadata.TestCategories.Unit)]
public void ParseTraitsRegexesString_OneRegex_ParsedCorrectly()
{
string optionsString = CreateTraitsRegex("MyTest*", "Type", "Small");
Expand All @@ -57,7 +55,7 @@ public void ParseTraitsRegexesString_OneRegex_ParsedCorrectly()
}

[TestMethod]
[TestCategory(Unit)]
[TestCategory(TestMetadata.TestCategories.Unit)]
public void ParseTraitsRegexesString_TwoRegexes_ParsedCorrectly()
{
string optionsString = ConcatTraitsRegexes(
Expand Down
2 changes: 0 additions & 2 deletions GoogleTestAdapter/Core.Tests/Settings/SettingsWrapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using FluentAssertions;
using GoogleTestAdapter.Helpers;
using GoogleTestAdapter.Tests.Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
Expand Down Expand Up @@ -334,7 +333,6 @@ public void ToString_PrintsCorrectly()
MockXmlOptions.Setup(s => s.MaxNrOfThreads).Returns(1);

string optionsString = TheOptions.ToString();
optionsString.Should().Contain("UseNewTestExecutionFramework: True");
optionsString.Should().Contain("PrintTestOutput: False");
optionsString.Should().Contain("TestDiscoveryRegex: ''");
optionsString.Should().Contain("WorkingDir: '$(ExecutableDir)'");
Expand Down
Loading