Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bd91e3f

Browse files
committed
Improved status handling
1 parent e25cbee commit bd91e3f

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

PlsqlDeveloperUtPlsqlPlugin/PlsqlDeveloperUtPlsqlPlugin/TestRunnerWindow.cs

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Text;
77
using System.Threading.Tasks;
88
using System.Windows.Forms;
9-
using utPLSQL;
109

1110
namespace utPLSQL
1211
{
@@ -39,22 +38,24 @@ public TestRunnerWindow(RealTimeTestRunner testRunner)
3938
gridResults.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
4039
}
4140

42-
internal async Task RunTestsAsync(string type, string owner, string name, string procedure, bool coverage)
41+
internal void RunTestsAsync(string type, string owner, string name, string procedure, bool coverage)
4342
{
44-
Running = true;
45-
4643
ResetComponents();
4744

4845
testResults.Clear();
4946

5047
setWindowTitle(type, owner, name, procedure);
5148

49+
Running = true;
50+
5251
if (coverage)
5352
{
5453
var codeCoverateReportDialog = new CodeCoverateReportDialog(getPath(type, owner, name, procedure));
5554
DialogResult dialogResult = codeCoverateReportDialog.ShowDialog();
5655
if (dialogResult == DialogResult.OK)
5756
{
57+
txtStatus.Text = "Running tests with coverage...";
58+
5859
RunWithCoverage(type, owner, name, procedure, codeCoverateReportDialog);
5960

6061
Show();
@@ -65,6 +66,8 @@ internal async Task RunTestsAsync(string type, string owner, string name, string
6566
}
6667
else
6768
{
69+
txtStatus.Text = "Running tests...";
70+
6871
RunTests(type, owner, name, procedure);
6972

7073
Show();
@@ -93,30 +96,35 @@ private void CollectResults(bool coverage)
9396

9497
Task.Factory.StartNew(() => testRunner.ConsumeResult(@event =>
9598
{
96-
gridResults.BeginInvoke((MethodInvoker)delegate ()
99+
if (@event.type.Equals("pre-run"))
97100
{
98-
if (@event.type.Equals("pre-run"))
101+
gridResults.BeginInvoke((MethodInvoker)delegate ()
99102
{
100103
totalNumberOfTests = @event.totalNumberOfTests;
101104

102105
progressBar.Minimum = 0;
103106
progressBar.Maximum = totalNumberOfTests * STEPS;
104107
progressBar.Step = STEPS;
105-
106108
CreateTestResults(@event);
107109

108110
gridResults.Rows[0].Selected = false;
109-
}
110-
else if (@event.type.Equals("post-test"))
111+
});
112+
}
113+
else if (@event.type.Equals("post-test"))
114+
{
115+
gridResults.BeginInvoke((MethodInvoker)delegate ()
111116
{
112117
completetedTests++;
113-
txtTests.Text = (completetedTests > totalNumberOfTests ? totalNumberOfTests : completetedTests) + "/" + totalNumberOfTests;
114118

119+
txtTests.Text = (completetedTests > totalNumberOfTests ? totalNumberOfTests : completetedTests) + "/" + totalNumberOfTests;
115120
UpdateProgressBar(completetedTests);
116121

117122
UpdateTestResult(@event);
118-
}
119-
else if (@event.type.Equals("post-run"))
123+
});
124+
}
125+
else if (@event.type.Equals("post-run"))
126+
{
127+
gridResults.BeginInvoke((MethodInvoker)delegate ()
120128
{
121129
txtStart.Text = @event.run.startTime.ToString();
122130
txtEnd.Text = @event.run.endTime.ToString();
@@ -135,20 +143,18 @@ private void CollectResults(bool coverage)
135143
if (!coverage)
136144
{
137145
txtStatus.Text = "Finished";
146+
138147
Running = false;
139148
}
140-
}
141-
});
149+
});
150+
}
142151
}));
143152
}
144153

145154
private void CollectReport()
146155
{
147156
Task.Factory.StartNew(() =>
148157
{
149-
var start = DateTime.Now;
150-
txtStatus.Text = "Running with Coverage...";
151-
152158
string report = testRunner.GetCoverageReport();
153159

154160
string filePath = $"{Path.GetTempPath()}\\utPLSQL_Coverage_Report_{Guid.NewGuid()}.html";
@@ -157,7 +163,11 @@ private void CollectReport()
157163
sw.WriteLine(report);
158164
}
159165

160-
txtStatus.Text = $"Finished in {(DateTime.Now - start)}";
166+
txtStatus.BeginInvoke((MethodInvoker)delegate ()
167+
{
168+
txtStatus.Text = "Finished";
169+
});
170+
161171
Running = false;
162172

163173
System.Diagnostics.Process.Start(filePath);
@@ -293,7 +303,7 @@ private void ResetComponents()
293303
txtErrors.Text = "";
294304
txtDisabled.Text = "";
295305
txtStatus.Text = "";
296-
txtStatus.Text = "Running...";
306+
txtStatus.Text = "";
297307

298308
txtTestOwner.Text = "";
299309
txtTestPackage.Text = "";

0 commit comments

Comments
 (0)