public void ConvertExceptionToVSTestResult() { LogEntryException exception = new LogEntryException("C string: some error", new SourceFileInfo("unknown location", 0)); exception.LastCheckpoint = new SourceFileInfo("boostunittestsample.cpp", 13); exception.CheckpointDetail = "Going to throw an exception"; BoostTestResult testCaseResult = new BoostTestResultBuilder(). For(this.TestCase). Aborted(). Duration(0). Log(exception). Build(); VSTestResult result = testCaseResult.AsVSTestResult(this.TestCase); AssertVSTestModelProperties(result); Assert.That(result.Outcome, Is.EqualTo(TestOutcome.Failed)); // A 0 duration should list as 1 tick to avoid UI issues in the test adapter Assert.That(result.Duration, Is.EqualTo(TimeSpan.FromTicks(1))); AssertVsTestModelError(result, exception); Assert.That(result.Messages.Count, Is.EqualTo(1)); TestResultMessage message = result.Messages.First(); Assert.That(message.Category, Is.EqualTo(TestResultMessage.StandardErrorCategory)); }
public void ConvertMemoryLeakToVSTestResult() { LogEntryMemoryLeak leak = new LogEntryMemoryLeak(); leak.LeakLineNumber = 32; leak.LeakMemoryAllocationNumber = 836; leak.LeakLeakedDataContents = " Data: <`- Leak... > 60 2D BD 00 4C 65 61 6B 2E 2E 2E 00 CD CD CD CD "; leak.LeakSourceFilePath = @"C:\boostunittestsample.cpp"; leak.LeakSourceFileName = "boostunittestsample.cpp"; BoostTestResult testCaseResult = new BoostTestResultBuilder(). For(this.TestCase). Passed(). Duration(1000). Log(leak). Build(); VSTestResult result = testCaseResult.AsVSTestResult(this.TestCase); AssertVSTestModelProperties(result); Assert.That(result.Outcome, Is.EqualTo(TestOutcome.Passed)); Assert.That(result.Duration, Is.EqualTo(Microseconds(1000))); Assert.That(result.Messages.Count, Is.EqualTo(1)); TestResultMessage message = result.Messages.First(); Assert.That(message.Category, Is.EqualTo(TestResultMessage.StandardErrorCategory)); }
public void ConvertFailToVSTestResult() { LogEntryError error = new LogEntryError("Error: 1 != 2", new SourceFileInfo("file.cpp", 10)); BoostTestResult testCaseResult = new BoostTestResultBuilder(). For(this.TestCase). Failed(). Duration(2500). Log(error). Build(); VSTestResult result = testCaseResult.AsVSTestResult(this.TestCase); AssertVSTestModelProperties(result); Assert.That(result.Outcome, Is.EqualTo(TestOutcome.Failed)); Assert.That(result.Duration, Is.EqualTo(Microseconds(2500))); AssertVsTestModelError(result, error); Assert.That(result.Messages.Count, Is.EqualTo(1)); TestResultMessage message = result.Messages.First(); Assert.That(message.Category, Is.EqualTo(TestResultMessage.StandardErrorCategory)); }
/// <summary> /// Given a LogEntry instance, identifies the respective Visual Studio /// TestResult message category. /// </summary> /// <param name="entry">The LogEntry instance to test</param> /// <returns>The respective Visual Studio Message category for the provided LogEntry</returns> private string GetCategory(LogEntry entry) { BoostTestResult testCaseResult = new BoostTestResultBuilder(). For(this.TestCase). Log(entry). Build(); VSTestResult result = testCaseResult.AsVSTestResult(this.TestCase); return(result.Messages.First().Category); }
public void ConvertSkipToVSTestResult() { BoostTestResult testCaseResult = new BoostTestResultBuilder(). For(this.TestCase). Skipped(). Build(); VSTestResult result = testCaseResult.AsVSTestResult(this.TestCase); AssertVSTestModelProperties(result); Assert.That(result.Outcome, Is.EqualTo(TestOutcome.Skipped)); Assert.That(result.Duration, Is.EqualTo(TimeSpan.FromTicks(1))); Assert.That(result.Messages.Count, Is.EqualTo(0)); }
public void ConvertPassToVSTestResult() { BoostTestResult testCaseResult = new BoostTestResultBuilder(). For(this.TestCase). Passed(). Duration(1000). Log(new LogEntryMessage("BOOST_MESSAGE output")). Build(); VSTestResult result = testCaseResult.AsVSTestResult(this.TestCase); AssertVSTestModelProperties(result); Assert.That(result.Outcome, Is.EqualTo(TestOutcome.Passed)); Assert.That(result.Duration, Is.EqualTo(Microseconds(1000))); Assert.That(result.Messages.Count, Is.EqualTo(1)); TestResultMessage message = result.Messages.First(); Assert.That(message.Category, Is.EqualTo(TestResultMessage.StandardOutCategory)); }
/// <summary> /// Given a LogEntry instance, identifies the respective Visual Studio /// TestResult message category. /// </summary> /// <param name="entry">The LogEntry instance to test</param> /// <returns>The respective Visual Studio Message category for the provided LogEntry</returns> private string GetCategory(LogEntry entry) { BoostTestResult testCaseResult = new BoostTestResultBuilder(). For(this.TestCase). Log(entry). Build(); VSTestResult result = testCaseResult.AsVSTestResult(this.TestCase); return result.Messages.First().Category; }