Skip to content

Commit 0a12f82

Browse files
committed
Throw exception if there are already running tests
1 parent 6202be0 commit 0a12f82

File tree

1 file changed

+34
-14
lines changed
  • PlsqlDeveloperUtPlsqlPlugin/PlsqlDeveloperUtPlsqlPlugin/TestRunner

1 file changed

+34
-14
lines changed

PlsqlDeveloperUtPlsqlPlugin/PlsqlDeveloperUtPlsqlPlugin/TestRunner/TestRunner.cs

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.IO;
22
using System.Runtime.InteropServices;
3+
using System.Runtime.Serialization;
34
using System.Text;
45
using System.Windows.Forms;
56
using System.Xml.Serialization;
@@ -8,26 +9,37 @@ namespace PlsqlDeveloperUtPlsqlPlugin
89
{
910
class TestRunner
1011
{
12+
bool running;
13+
1114
internal void Run(string type, string owner, string name, string subType)
1215
{
13-
string testsToRun = null;
14-
15-
if (type.Equals("USER"))
16-
{
17-
testsToRun = name;
18-
}
19-
else if (type.Equals("PACKAGE"))
16+
if (running)
2017
{
21-
testsToRun = $"{owner}.{name}";
18+
throw new TestsAlreadyRunningException();
2219
}
23-
else if (type.Equals("_ALL"))
20+
else
2421
{
25-
testsToRun = owner;
26-
}
22+
running = true;
2723

28-
if (testsToRun != null)
29-
{
30-
ExecuteSql($"select * from table(ut.run('{name}', ut_junit_reporter()))");
24+
string testsToRun = null;
25+
26+
if (type.Equals("USER"))
27+
{
28+
testsToRun = name;
29+
}
30+
else if (type.Equals("PACKAGE"))
31+
{
32+
testsToRun = $"{owner}.{name}";
33+
}
34+
else if (type.Equals("_ALL"))
35+
{
36+
testsToRun = owner;
37+
}
38+
39+
if (testsToRun != null)
40+
{
41+
ExecuteSql($"select * from table(ut.run('{name}', ut_junit_reporter()))");
42+
}
3143
}
3244
}
3345

@@ -47,6 +59,9 @@ internal JUnitTestSuites GetJUnitResult()
4759

4860
var serializer = new XmlSerializer(typeof(JUnitTestSuites));
4961
var testSuites = (JUnitTestSuites)serializer.Deserialize(new StringReader(result));
62+
63+
running = false;
64+
5065
return testSuites;
5166
}
5267

@@ -61,4 +76,9 @@ private void ExecuteSql(string sql)
6176
}
6277

6378
}
79+
80+
[System.Serializable]
81+
internal class TestsAlreadyRunningException : System.Exception
82+
{
83+
}
6484
}

0 commit comments

Comments
 (0)