public async Task RunTest_ByUniqueName() { // Arrange var host = new TestHostWrapper(_testProject); await host.StartAsync(); await host.ListTestsAsync(); var test = host.Output .Where(m => m.MessageType == "TestDiscovery.TestFound") .First() .Payload.ToObject <Test>(); host.Output.Clear(); host = new TestHostWrapper(_testProject); await host.StartAsync(); // Act var result = await host.RunTestsAsync(_testProject, test.FullyQualifiedName); // Assert Assert.Equal(0, result); Assert.Equal(3, host.Output.Count); Assert.Single(host.Output, m => TestStarted(m, test.DisplayName)); Assert.Single(host.Output, m => TestPassed(m, test.DisplayName)); Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); }
public async Task RunTest_All() { // Arrange var host = new TestHostWrapper(_testProject); await host.StartAsync(); // Act var result = await host.RunTestsAsync(); // Assert Assert.Equal(0, result); Assert.Equal(19, host.Output.Count); Assert.Single(host.Output, m => TestStarted(m, "SampleTest.True_is_true")); Assert.Single(host.Output, m => TestPassed(m, "SampleTest.True_is_true")); Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest1(x: 1)")); Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest1(x: 1)")); Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest1(x: 2)")); Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest1(x: 2)")); Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest1(x: 3)")); Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest1(x: 3)")); Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest2(x: 1, s: \"Hi\")")); Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest2(x: 1, s: \"Hi\")")); Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest2(x: 2, s: \"Hi\")")); Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest2(x: 2, s: \"Hi\")")); Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest2(x: 3, s: \"Hi\")")); Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest2(x: 3, s: \"Hi\")")); Assert.Single(host.Output, m => TestStarted(m, "SampleTest.SampleAsyncTest")); Assert.Single(host.Output, m => TestPassed(m, "SampleTest.SampleAsyncTest")); Assert.Single(host.Output, m => TestStarted(m, "DerivedTest.ThisGetsInherited")); Assert.Single(host.Output, m => TestPassed(m, "DerivedTest.ThisGetsInherited")); Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); }
private void ExecuteRunAllTests(object _) { try { Status = "Running All Tests..."; var timer = Stopwatch.StartNew(); var task = _host.RunTestsAsync(); task.ContinueWith(t => { if (t.IsFaulted) { Status = "Running All Tests failed."; ShowErrorDialog(t.Exception); } else { Status = string.Format("Ran All Tests in {0}ms", timer.ElapsedMilliseconds); } Reset(); }, _scheduler); } catch (Exception ex) { ShowErrorDialog(ex); Reset(); } }
public async Task RunTest_IncludesStartAndEndTime() { // Arrange var host = new TestHostWrapper(_testProject); await host.StartAsync(); // Act var result = await host.RunTestsAsync(); // Assert Assert.Equal(0, result); var results = GetTestResults(host.Output).ToArray(); Assert.Equal(9, results.Length); foreach (var testResult in results) { Assert.NotEqual(default(DateTimeOffset), testResult.StartTime); Assert.NotEqual(default(DateTimeOffset), testResult.EndTime); } }