11using System . IO ;
22using System . Runtime . InteropServices ;
3+ using System . Runtime . Serialization ;
34using System . Text ;
45using System . Windows . Forms ;
56using 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