Skip to content

Commit

Permalink
Removing asserts on elaspsed time.
Browse files Browse the repository at this point in the history
  • Loading branch information
mayankbansal018 committed Feb 1, 2018
1 parent 3ac3ae2 commit 1251029
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions test/vstest.console.PlatformTests/AssemblyMetadataProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ public void GetArchitectureForNativeDll(string platform)
var arch = this.assemblyMetadataProvider.GetArchitecture(assemblyPath);
stopWatch.Stop();

Assert.AreEqual(Enum.Parse(typeof(Architecture), platform, ignoreCase: true), arch);
Console.WriteLine("Platform:{0}, {1}", platform, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds));
Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds));
Assert.AreEqual(Enum.Parse(typeof(Architecture), platform, ignoreCase: true), arch);

// We should not assert on time elapsed, it will vary depending on machine, & their state, commenting below assert
// Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds));
}

[TestMethod]
Expand Down Expand Up @@ -109,7 +111,9 @@ public void GetFrameWorkForDotNetAssembly(string framework)
}

Console.WriteLine("Framework:{0}, {1}", framework, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds));
Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds));

// We should not assert on time elapsed, it will vary depending on machine, & their state.
// Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds));
}

[TestMethod]
Expand All @@ -121,10 +125,12 @@ public void GetFrameWorkForNativeDll()
var stopWatch = Stopwatch.StartNew();
var fx = this.assemblyMetadataProvider.GetFrameWork(assemblyPath);
stopWatch.Stop();
Assert.AreEqual(Framework.DefaultFramework.Name, fx.FullName);

Console.WriteLine(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds);
Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds));
Assert.AreEqual(Framework.DefaultFramework.Name, fx.FullName);

// We should not assert on time elapsed, it will vary depending on machine, & their state.
// Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds));
}

private void TestDotnetAssemblyArch(string projectName, string framework, Architecture expectedArch, long expectedElapsedTime)
Expand All @@ -134,11 +140,12 @@ private void TestDotnetAssemblyArch(string projectName, string framework, Archit
var stopWatch = Stopwatch.StartNew();
var arch = this.assemblyMetadataProvider.GetArchitecture(assemblyPath);
stopWatch.Stop();
Assert.AreEqual(expectedArch, arch, $"Expected: {expectedArch} Actual: {arch}");

Console.WriteLine("Framework:{0}, {1}", framework, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds));
Assert.IsTrue(
stopWatch.ElapsedMilliseconds < expectedElapsedTime,
string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds));
Assert.AreEqual(expectedArch, arch, $"Expected: {expectedArch} Actual: {arch}");

// We should not assert on time elapsed, it will vary depending on machine, & their state.
// Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds));
}

private void LoadAssemblyIntoMemory(string assemblyPath)
Expand Down

0 comments on commit 1251029

Please sign in to comment.