1
1
using System . IO ;
2
2
using System . Runtime . InteropServices ;
3
+ using System . Runtime . Serialization ;
3
4
using System . Text ;
4
5
using System . Windows . Forms ;
5
6
using System . Xml . Serialization ;
@@ -8,26 +9,37 @@ namespace PlsqlDeveloperUtPlsqlPlugin
8
9
{
9
10
class TestRunner
10
11
{
12
+ bool running ;
13
+
11
14
internal void Run ( string type , string owner , string name , string subType )
12
15
{
13
- string testsToRun = null ;
14
-
15
- if ( type . Equals ( "USER" ) )
16
- {
17
- testsToRun = name ;
18
- }
19
- else if ( type . Equals ( "PACKAGE" ) )
16
+ if ( running )
20
17
{
21
- testsToRun = $ " { owner } . { name } " ;
18
+ throw new TestsAlreadyRunningException ( ) ;
22
19
}
23
- else if ( type . Equals ( "_ALL" ) )
20
+ else
24
21
{
25
- testsToRun = owner ;
26
- }
22
+ running = true ;
27
23
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
+ }
31
43
}
32
44
}
33
45
@@ -47,6 +59,9 @@ internal JUnitTestSuites GetJUnitResult()
47
59
48
60
var serializer = new XmlSerializer ( typeof ( JUnitTestSuites ) ) ;
49
61
var testSuites = ( JUnitTestSuites ) serializer . Deserialize ( new StringReader ( result ) ) ;
62
+
63
+ running = false ;
64
+
50
65
return testSuites ;
51
66
}
52
67
@@ -61,4 +76,9 @@ private void ExecuteSql(string sql)
61
76
}
62
77
63
78
}
79
+
80
+ [ System . Serializable ]
81
+ internal class TestsAlreadyRunningException : System . Exception
82
+ {
83
+ }
64
84
}
0 commit comments