22
22
import org .utplsql .maven .plugin .model .ReporterParameter ;
23
23
import org .utplsql .maven .plugin .reporter .ReporterWriter ;
24
24
25
+ import java .io .ByteArrayOutputStream ;
25
26
import java .io .File ;
27
+ import java .io .PrintStream ;
26
28
import java .sql .Connection ;
27
29
import java .util .ArrayList ;
28
30
import java .util .List ;
39
41
import static org .powermock .api .mockito .PowerMockito .when ;
40
42
41
43
@ RunWith (PowerMockRunner .class )
42
- @ PrepareForTest ({ DBHelper .class , ReporterFactory .class })
44
+ @ PrepareForTest ({DBHelper .class , ReporterFactory .class })
43
45
public class UtPLSQLMojoTest {
44
46
45
47
@ Rule
@@ -68,7 +70,7 @@ public void setUp() throws Exception {
68
70
69
71
/**
70
72
* testInvalidSourcesDirectory.
71
- *
73
+ * <p>
72
74
* Given : a pom.xml with invalid sources' directory When : pom is read and
73
75
* buildSourcesOptions is run Then : it should throw a MojoExecutionException
74
76
*/
@@ -84,12 +86,11 @@ public void testInvalidSourcesDirectory() throws Exception {
84
86
thrown .expectMessage ("Invalid <SOURCES> in your pom.xml" );
85
87
86
88
Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" );
87
-
88
89
}
89
90
90
91
/**
91
92
* testInvalidTestsDirectory.
92
- *
93
+ * <p>
93
94
* Given : a pom.xml with invalid tests' directory When : pom is read and
94
95
* buildTestsOptions is run Then : it should throw a MojoExecutionException
95
96
*/
@@ -109,7 +110,7 @@ public void testInvalidTestsDirectory() throws Exception {
109
110
110
111
/**
111
112
* testSourcesTestsParameters.
112
- *
113
+ * <p>
113
114
* Given : a pom.xml with sources and tests with a lot of parameters When : pom
114
115
* is read and buildSourcesOptions / buildTestsOptions are run Then : it should
115
116
* fill all parameters correctly
@@ -150,12 +151,11 @@ public void testSourcesTestsParameters() throws Exception {
150
151
assertEquals (1 , tests .getTypeMappings ().size ());
151
152
assertEquals ("def" , tests .getTypeMappings ().get (0 ).getKey ());
152
153
assertEquals ("abc" , tests .getTypeMappings ().get (0 ).getValue ());
153
-
154
154
}
155
155
156
156
/**
157
157
* testSourcesAndTestsParameterDoesNotExist.
158
- *
158
+ * <p>
159
159
* Given : a pom.xml with no sources / tests tags and default directory does not
160
160
* exist. When : pom is read and buildSourcesOptions / buildTestsOptions are run
161
161
* Then : it should not find any source files
@@ -177,7 +177,7 @@ public void testSourcesAndTestsParameterDoesNotExist() throws Exception {
177
177
178
178
/**
179
179
* testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists.
180
- *
180
+ * <p>
181
181
* Given : a pom.xml with no sources / tests tags but default directory exists.
182
182
* When : pom is read and buildSourcesOptions / buildTestsOptions are run Then :
183
183
* it should find all sources/tests files in default directories
@@ -199,12 +199,11 @@ public void testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists()
199
199
assertEquals (2 , tests .getFilePaths ().size ());
200
200
assertTrue (tests .getFilePaths ().contains ("src/test/plsql/foo/f1.pkg" ));
201
201
assertTrue (tests .getFilePaths ().contains ("src/test/plsql/f2.pkg" ));
202
-
203
202
}
204
203
205
204
/**
206
205
* testSourcesAndTestsParameterHaveNotDirectoryTag.
207
- *
206
+ * <p>
208
207
* Given : a pom.xml with source and test tag not containing a directory tag.
209
208
* When : pom is read and buildSourcesOptions / buildTestsOptions are run Then :
210
209
* it should find all sources/tests files in default directories
@@ -231,7 +230,7 @@ public void testSourcesAndTestsParameterHaveNotDirectoryTag() throws Exception {
231
230
232
231
/**
233
232
* testSourcesAndTestsParameterHaveNotDirectoryTag.
234
- *
233
+ * <p>
235
234
* Given : a pom.xml with source and test tag not containing a directory tag.
236
235
* When : pom is read and buildSourcesOptions / buildTestsOptions are run Then :
237
236
* it should find all sources/tests files in default directories
@@ -284,8 +283,7 @@ public void testDefaultConsoleBehaviour() throws Exception {
284
283
285
284
// Assert that we added only the necessary reporters to the writer.
286
285
ReporterWriter reporterWritter = Whitebox .getInternalState (utplsqlMojo , "reporterWriter" );
287
- List <Pair <Reporter , ReporterParameter >> listReporters =
288
- Whitebox .getInternalState (reporterWritter , "listReporters" );
286
+ List <Pair <Reporter , ReporterParameter >> listReporters = Whitebox .getInternalState (reporterWritter , "listReporters" );
289
287
assertEquals (3 , listReporters .size ());
290
288
291
289
ReporterParameter reporterParameter1 = listReporters .get (0 ).getRight ();
@@ -324,4 +322,20 @@ public void testAddDefaultReporter() throws Exception {
324
322
assertEquals ("UT_DOCUMENTATION_REPORTER" , reporterList .get (0 ).getTypeName ());
325
323
verify (reporterList .get (0 )).init (mockConnection );
326
324
}
325
+
326
+ @ Test
327
+ public void testSkipUtplsqlTests () throws Exception {
328
+ UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
329
+ .lookupConfiguredMojo (new File ("src/test/resources/skipUtplsqlTests/" ), "test" );
330
+ Assert .assertNotNull (utplsqlMojo );
331
+
332
+ final ByteArrayOutputStream console = new ByteArrayOutputStream ();
333
+ System .setOut (new PrintStream (console ));
334
+
335
+ utplsqlMojo .execute ();
336
+
337
+ String standardOutput = console .toString ();
338
+
339
+ Assert .assertTrue (standardOutput .contains ("utPLSQLTests are skipped." ));
340
+ }
327
341
}
0 commit comments