Skip to content

Commit 51b5d30

Browse files
committed
Code clean up and Test restructuring
1 parent a476c52 commit 51b5d30

File tree

3 files changed

+28
-24
lines changed

3 files changed

+28
-24
lines changed

utPLSQL.Api/utPLSQL.Api.Test/RealTimeTestRunnerTest.cs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
23
using Oracle.ManagedDataAccess.Client;
34
using System.Collections.Generic;
45
using System.Linq;
@@ -9,10 +10,23 @@ namespace utPLSQL
910
[TestClass]
1011
public class RealTimeTestRunnerTest
1112
{
13+
private RealTimeTestRunner testRunner;
14+
15+
[TestInitialize]
16+
public void Before()
17+
{
18+
testRunner = new RealTimeTestRunner();
19+
}
20+
21+
[TestCleanup]
22+
public void After()
23+
{
24+
testRunner.Close();
25+
}
26+
1227
[TestMethod]
1328
public async Task TestRunTests()
1429
{
15-
var testRunner = new RealTimeTestRunner();
1630
testRunner.Connect(username: "toscamtest", password: "toscamtest", database: "CA40");
1731

1832
var events = new List<@event>();
@@ -26,9 +40,8 @@ await testRunner.RunTestsAsync("toscamtest", @event =>
2640
}
2741

2842
[TestMethod]
29-
public async Task TestConnectAsAsync()
43+
public async Task TestConnectAs()
3044
{
31-
var testRunner = new RealTimeTestRunner();
3245
testRunner.Connect(username: "sys", password: "Oradoc_db1", database: "ORCLPDB1", connectAs: "SYSDBA");
3346

3447
try
@@ -44,9 +57,8 @@ public async Task TestConnectAsAsync()
4457
}
4558

4659
[TestMethod]
47-
public async Task TestRunTestsWithCoverageAsync()
60+
public async Task TestRunTestsWithCoverage()
4861
{
49-
var testRunner = new RealTimeTestRunner();
5062
testRunner.Connect(username: "toscamtest", password: "toscamtest", database: "CA40");
5163

5264
var events = new List<@event>();
@@ -57,25 +69,21 @@ public async Task TestRunTestsWithCoverageAsync()
5769
Assert.AreEqual("pre-run", events[0].type);
5870
Assert.AreEqual("post-run", events.Last().type);
5971

60-
System.Diagnostics.Trace.WriteLine(report);
72+
Logger.LogMessage(report);
6173
}
6274

6375

6476
[TestMethod]
6577
public void TestRunTestsAndAbort()
6678
{
67-
var testRunner = new RealTimeTestRunner();
6879
testRunner.Connect(username: "toscamtest", password: "toscamtest", database: "CA40");
6980

7081
testRunner.RunTestsAsync("toscamtest", @event => { });
71-
72-
testRunner.Close();
7382
}
7483

7584
[TestMethod]
76-
public async Task TestRunTestsTwoTimesAsync()
85+
public async Task TestRunTestsTwoTimes()
7786
{
78-
var testRunner = new RealTimeTestRunner();
7987
testRunner.Connect(username: "toscamtest", password: "toscamtest", database: "CA40");
8088

8189
testRunner.RunTestsAsync("toscamtest", @event => { });
@@ -86,7 +94,6 @@ public async Task TestRunTestsTwoTimesAsync()
8694
[TestMethod]
8795
public void TestGetVersion()
8896
{
89-
var testRunner = new RealTimeTestRunner();
9097
testRunner.Connect(username: "toscamtest", password: "toscamtest", database: "CA40");
9198

9299
string version = testRunner.GetVersion();
@@ -97,7 +104,6 @@ public void TestGetVersion()
97104
// [TestMethod] Disabled
98105
public void TestGetVersionWhenNotInstalled()
99106
{
100-
var testRunner = new RealTimeTestRunner();
101107
testRunner.Connect(username: "sakila", password: "sakila", database: "ORCLPDB1");
102108

103109
try

utPLSQL.Api/utPLSQL.Api/RealTimeTestRunner.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,23 @@ public override async Task<string> RunTestsWithCoverageAsync(List<string> paths,
4343

4444
Task taskConsume = ConsumeResultAsync(realtimeReporterId, consumer);
4545

46-
await Task.WhenAll(taskRun, taskConsume);
46+
Task<string> taskCoverateReport = GetCoverageReportAsync(coverageReporterId);
47+
48+
await Task.WhenAll(taskRun, taskConsume, taskCoverateReport);
4749

48-
return await GetCoverageReportAsync(coverageReporterId);
50+
return taskCoverateReport.Result;
4951
}
5052
else
5153
{
5254
return null;
5355
}
5456
}
5557

58+
public override async Task<string> RunTestsWithCoverageAsync(string path, Action<@event> consumer, string coverageSchema = null, List<string> includeObjects = null, List<string> excludeObjects = null)
59+
{
60+
return await RunTestsWithCoverageAsync(new List<string>() { path }, consumer, new List<string>() { coverageSchema }, includeObjects, excludeObjects);
61+
}
62+
5663
private async Task UtRunWithCoverageAsync(string realtimeReporterId, string coverageReporterId, List<string> paths, List<string> coverageSchemas, List<string> includeObjects, List<string> excludeObjects)
5764
{
5865
await Task.Run(() =>
@@ -100,11 +107,6 @@ await Task.Run(() =>
100107
});
101108
}
102109

103-
public override async Task<string> RunTestsWithCoverageAsync(string path, Action<@event> consumer, string coverageSchema = null, List<string> includeObjects = null, List<string> excludeObjects = null)
104-
{
105-
return await RunTestsWithCoverageAsync(new List<string>() { path }, consumer, new List<string>() { coverageSchema }, includeObjects, excludeObjects);
106-
}
107-
108110
private async Task UtRunAsync(string id, List<string> paths)
109111
{
110112
await Task.Run(() =>

utPLSQL.Api/utPLSQL.Api/TestRunner.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ public String GetVersion()
116116
/// <returns>Report as HTML</returns>
117117
public abstract Task<string> RunTestsWithCoverageAsync(string path, Action<T> consumer, string coverageSchema = null, List<string> includeObjects = null, List<string> excludeObjects = null);
118118

119-
/// <summary>
120-
/// Consumes the results and calls the callback action on each result
121-
/// </summary>
122-
123119
protected async Task<string> GetCoverageReportAsync(string id)
124120
{
125121
return await Task.Run(() =>

0 commit comments

Comments
 (0)